diff --git a/src/thirdparty/quickjs-ng/quickjs-amalgam.c b/src/thirdparty/quickjs-ng/quickjs-amalgam.c index 9b7d70673c..d90b64cda9 100644 --- a/src/thirdparty/quickjs-ng/quickjs-amalgam.c +++ b/src/thirdparty/quickjs-ng/quickjs-amalgam.c @@ -252,6 +252,16 @@ static inline int64_t min_int64(int64_t a, int64_t b) return b; } +static inline uint32_t hash32(uint32_t a) +{ + // use the negative of the golden ratio, it spreads out the bits nicely + // and is what the linux kernel does + // + // the golden ratio phi is defined as (1+sqrt(5))/2 or 1 + (sqrt(5)-1)/2 + // (approx. 1.618033988), and negated is round(2**32/phi**2) = 0x61c88647 + return a * 0x61c88647; +} + /* WARNING: undefined if a = 0 */ static inline int clz32(unsigned int a) { @@ -333,6 +343,17 @@ static inline uint32_t get_u32(const uint8_t *tab) return v; } +static inline uint32_t get_u32_le(const uint8_t *tab) +{ + uint32_t a, b, c, d; + + a = (uint32_t)tab[0]; + b = (uint32_t)tab[1]; + c = (uint32_t)tab[2]; + d = (uint32_t)tab[3]; + return a | b<<8 | c<<16 | d<<24; +} + static inline int32_t get_i32(const uint8_t *tab) { int32_t v; @@ -345,6 +366,14 @@ static inline void put_u32(uint8_t *tab, uint32_t val) memcpy(tab, &val, sizeof(val)); } +static inline void put_u32_le(uint8_t *tab, uint32_t val) +{ + tab[0] = val >> 0; + tab[1] = val >> 8; + tab[2] = val >> 16; + tab[3] = val >> 24; +} + static inline uint32_t get_u16(const uint8_t *tab) { uint16_t v; @@ -408,14 +437,6 @@ static inline uint64_t bswap64(uint64_t v) } #endif -static inline void inplace_bswap16(uint8_t *tab) { - put_u16(tab, bswap16(get_u16(tab))); -} - -static inline void inplace_bswap32(uint8_t *tab) { - put_u32(tab, bswap32(get_u32(tab))); -} - static inline double fromfp16(uint16_t v) { double d, s; int e; @@ -2414,8 +2435,9 @@ extern "C" { #define LRE_FLAG_NAMED_GROUPS (1 << 7) /* named groups are present in the regexp */ #define LRE_FLAG_UNICODE_SETS (1 << 8) -#define LRE_RET_MEMORY_ERROR (-1) -#define LRE_RET_TIMEOUT (-2) +#define LRE_RET_MEMORY_ERROR (-1) +#define LRE_RET_TIMEOUT (-2) +#define LRE_RET_BYTECODE_ERROR (-3) uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size, const char *buf, size_t buf_len, int re_flags, @@ -2430,8 +2452,6 @@ int lre_exec(uint8_t **capture, int lre_parse_escape(const uint8_t **pp, int allow_utf16); bool lre_is_space(int c); -void lre_byte_swap(uint8_t *buf, size_t len, bool is_byte_swapped); - /* must be provided by the user */ bool lre_check_stack_overflow(void *opaque, size_t alloca_size); /* must be provided by the user, return non zero if time out */ @@ -7176,10 +7196,10 @@ static const uint16_t unicode_prop_len_table[] = { /* * QuickJS Javascript Engine * - * Copyright (c) 2017-2024 Fabrice Bellard + * Copyright (c) 2017-2026 Fabrice Bellard * Copyright (c) 2017-2024 Charlie Gordon - * Copyright (c) 2023-2025 Ben Noordhuis - * Copyright (c) 2023-2025 Saúl Ibarra Corretgé + * Copyright (c) 2023-2026 Ben Noordhuis + * Copyright (c) 2023-2026 Saúl Ibarra Corretgé * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -7720,20 +7740,20 @@ JS_EXTERN JSValue JS_GetFunctionProto(JSContext *ctx); /* the following functions are used to select the intrinsic object to save memory */ JS_EXTERN JSContext *JS_NewContextRaw(JSRuntime *rt); -JS_EXTERN void JS_AddIntrinsicBaseObjects(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicDate(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicEval(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicBaseObjects(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicDate(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicEval(JSContext *ctx); JS_EXTERN void JS_AddIntrinsicRegExpCompiler(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicRegExp(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicJSON(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicProxy(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicMapSet(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicTypedArrays(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicPromise(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicBigInt(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicWeakRef(JSContext *ctx); -JS_EXTERN void JS_AddPerformance(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicDOMException(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicRegExp(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicJSON(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicProxy(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicMapSet(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicTypedArrays(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicPromise(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicBigInt(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicWeakRef(JSContext *ctx); +JS_EXTERN int JS_AddPerformance(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicDOMException(JSContext *ctx); /* for equality comparisons and sameness */ JS_EXTERN int JS_IsEqual(JSContext *ctx, JSValueConst op1, JSValueConst op2); @@ -8236,6 +8256,10 @@ JS_EXTERN JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size JS_EXTERN void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj); JS_EXTERN uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj); JS_EXTERN bool JS_IsArrayBuffer(JSValueConst obj); +// returns true or false if obj is an ArrayBuffer, -1 otherwise +JS_EXTERN int JS_IsImmutableArrayBuffer(JSValueConst obj); +// returns 0 if obj is an ArrayBuffer, -1 otherwise +JS_EXTERN int JS_SetImmutableArrayBuffer(JSValueConst obj, bool immutable); JS_EXTERN uint8_t *JS_GetUint8Array(JSContext *ctx, size_t *psize, JSValueConst obj); typedef enum JSTypedArrayEnum { @@ -8286,6 +8310,7 @@ JS_EXTERN JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValueConst promise); JS_EXTERN JSValue JS_PromiseResult(JSContext *ctx, JSValueConst promise); JS_EXTERN bool JS_IsPromise(JSValueConst val); +JS_EXTERN JSValue JS_NewSettledPromise(JSContext *ctx, bool is_reject, JSValueConst value); JS_EXTERN JSValue JS_NewSymbol(JSContext *ctx, const char *description, bool is_global); @@ -8327,6 +8352,11 @@ typedef struct JSModuleDef JSModuleDef; typedef char *JSModuleNormalizeFunc(JSContext *ctx, const char *module_base_name, const char *module_name, void *opaque); +typedef char *JSModuleNormalizeFunc2(JSContext *ctx, + const char *module_base_name, + const char *module_name, + JSValueConst attributes, + void *opaque); typedef JSModuleDef *JSModuleLoaderFunc(JSContext *ctx, const char *module_name, void *opaque); @@ -8352,6 +8382,10 @@ JS_EXTERN void JS_SetModuleLoaderFunc2(JSRuntime *rt, JSModuleCheckSupportedImportAttributes *module_check_attrs, void *opaque); +/* Set an attributes-aware module normalizer. Call after JS_SetModuleLoaderFunc2. */ +JS_EXTERN void JS_SetModuleNormalizeFunc2(JSRuntime *rt, + JSModuleNormalizeFunc2 *module_normalize); + /* return the import.meta object of a module */ JS_EXTERN JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m); JS_EXTERN JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m); @@ -8446,7 +8480,7 @@ JS_EXTERN JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func, JS_EXTERN JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func, const char *name, int length, JSCFunctionEnum cproto, int magic, - JSValueConst proto_val); + JSValueConst proto_val, int n_fields); JS_EXTERN JSValue JS_NewCFunctionData(JSContext *ctx, JSCFunctionData *func, int length, int magic, int data_len, JSValueConst *data); @@ -8475,8 +8509,8 @@ static inline JSValue JS_NewCFunctionMagic(JSContext *ctx, JSCFunctionMagic *fun ft.generic_magic = func; return JS_NewCFunction2(ctx, ft.generic, name, length, cproto, magic); } -JS_EXTERN void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj, - JSValueConst proto); +JS_EXTERN int JS_SetConstructor(JSContext *ctx, JSValueConst func_obj, + JSValueConst proto); /* C property definition */ @@ -8521,6 +8555,8 @@ typedef struct JSCFunctionListEntry { #define JS_DEF_PROP_UNDEFINED 7 #define JS_DEF_OBJECT 8 #define JS_DEF_ALIAS 9 +#define JS_DEF_PROP_SYMBOL 10 +#define JS_DEF_PROP_BOOL 11 /* Note: c++ does not like nested designators */ #define JS_CFUNC_DEF(name, length, func1) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, 0, { .func = { length, JS_CFUNC_generic, { .generic = func1 } } } } @@ -8537,6 +8573,8 @@ typedef struct JSCFunctionListEntry { #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_PROP_SYMBOL_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_SYMBOL, 0, { .i32 = val } } +#define JS_PROP_BOOL_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_BOOL, 0, { .i32 = val } } #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 } } } #define JS_ALIAS_BASE_DEF(name, from, base) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, { .alias = { from, base } } } @@ -8564,8 +8602,8 @@ JS_EXTERN int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m, /* Version */ #define QJS_VERSION_MAJOR 0 -#define QJS_VERSION_MINOR 12 -#define QJS_VERSION_PATCH 1 +#define QJS_VERSION_MINOR 13 +#define QJS_VERSION_PATCH 0 #define QJS_VERSION_SUFFIX "" JS_EXTERN const char* JS_GetVersion(void); @@ -8581,10 +8619,10 @@ JS_EXTERN uintptr_t js_std_cmd(int cmd, ...); /* * QuickJS Javascript Engine * - * Copyright (c) 2017-2025 Fabrice Bellard + * Copyright (c) 2017-2026 Fabrice Bellard * Copyright (c) 2017-2025 Charlie Gordon - * Copyright (c) 2023-2025 Ben Noordhuis - * Copyright (c) 2023-2025 Saúl Ibarra Corretgé + * Copyright (c) 2023-2026 Ben Noordhuis + * Copyright (c) 2023-2026 Saúl Ibarra Corretgé * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -8901,7 +8939,11 @@ struct JSRuntime { struct list_head job_list; /* list of JSJobEntry.link */ - JSModuleNormalizeFunc *module_normalize_func; + bool module_normalize_has_attr; + union { + JSModuleNormalizeFunc *module_normalize_func; + JSModuleNormalizeFunc2 *module_normalize_func2; + } normalize_u; bool module_loader_has_attr; union { JSModuleLoaderFunc *module_loader_func; @@ -9580,7 +9622,6 @@ typedef struct JSProperty { #define JS_PROP_INITIAL_SIZE 2 #define JS_PROP_INITIAL_HASH_SIZE 4 /* must be a power of two */ -#define JS_ARRAY_INITIAL_SIZE 2 typedef struct JSShapeProperty { uint32_t hash_next : 26; /* 0 if last in list */ @@ -11572,6 +11613,8 @@ static bool is_typed_array(JSClassID class_id); static bool typed_array_is_immutable(JSObject *p); static bool typed_array_is_oob(JSObject *p); static uint32_t typed_array_length(JSObject *p); +static int typed_array_init(JSContext *ctx, JSValue obj, JSValue buffer, + uint64_t offset, uint64_t len, bool track_rab); static JSValue JS_ThrowTypeErrorDetachedArrayBuffer(JSContext *ctx); static JSValue JS_ThrowTypeErrorImmutableArrayBuffer(JSContext *ctx); static JSValue JS_ThrowTypeErrorArrayBufferOOB(JSContext *ctx); @@ -11623,7 +11666,7 @@ static JSValue JS_GetOwnPropertyNames2(JSContext *ctx, JSValueConst obj1, static void js_free_desc(JSContext *ctx, JSPropertyDescriptor *desc); static void async_func_mark(JSRuntime *rt, JSAsyncFunctionState *s, JS_MarkFunc *mark_func); -static void JS_AddIntrinsicBasicObjects(JSContext *ctx); +static int JS_AddIntrinsicBasicObjects(JSContext *ctx); static void js_free_shape(JSRuntime *rt, JSShape *sh); static void js_free_shape_null(JSRuntime *rt, JSShape *sh); static int js_shape_prepare_update(JSContext *ctx, JSObject *p, @@ -11666,6 +11709,8 @@ static JSValue js_module_ns_autoinit(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque); static JSValue JS_InstantiateFunctionListItem2(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque); +static JSValue JS_NewObjectProtoList(JSContext *ctx, JSValueConst proto, + const JSCFunctionListEntry *fields, int n_fields); static void js_set_uncatchable_error(JSContext *ctx, JSValueConst val, bool flag); @@ -11673,7 +11718,7 @@ static void js_set_uncatchable_error(JSContext *ctx, JSValueConst val, static JSValue js_new_callsite(JSContext *ctx, JSCallSiteData *csd); static void js_new_callsite_data(JSContext *ctx, JSCallSiteData *csd, JSStackFrame *sf); static void js_new_callsite_data2(JSContext *ctx, JSCallSiteData *csd, const char *filename, int line_num, int col_num); -static void _JS_AddIntrinsicCallSite(JSContext *ctx); +static int _JS_AddIntrinsicCallSite(JSContext *ctx); static void JS_SetOpaqueInternal(JSValueConst obj, void *opaque); @@ -11851,8 +11896,13 @@ void js_free_rt(JSRuntime *rt, void *ptr) return; s = &rt->malloc_state; + size_t free_size = rt->mf.js_malloc_usable_size(ptr) + MALLOC_OVERHEAD; + if (unlikely(free_size > s->malloc_size)) { + printf("js_free_rt: malloc_size underflow: freeing %zu but only %zu tracked\n", free_size, s->malloc_size); + abort(); + } s->malloc_count--; - s->malloc_size -= rt->mf.js_malloc_usable_size(ptr) + MALLOC_OVERHEAD; + s->malloc_size -= free_size; rt->mf.js_free(s->opaque, ptr); } @@ -12695,7 +12745,10 @@ JSContext *JS_NewContextRaw(JSRuntime *rt) ctx->error_stack_trace_limit = js_int32(10); init_list_head(&ctx->loaded_modules); - JS_AddIntrinsicBasicObjects(ctx); + if (JS_AddIntrinsicBasicObjects(ctx)) { + JS_FreeContext(ctx); + return NULL; + } return ctx; } @@ -12707,20 +12760,21 @@ JSContext *JS_NewContext(JSRuntime *rt) if (!ctx) return NULL; - JS_AddIntrinsicBaseObjects(ctx); - JS_AddIntrinsicDate(ctx); - JS_AddIntrinsicEval(ctx); - JS_AddIntrinsicRegExp(ctx); - JS_AddIntrinsicJSON(ctx); - JS_AddIntrinsicProxy(ctx); - JS_AddIntrinsicMapSet(ctx); - JS_AddIntrinsicTypedArrays(ctx); - JS_AddIntrinsicPromise(ctx); - JS_AddIntrinsicBigInt(ctx); - JS_AddIntrinsicWeakRef(ctx); - JS_AddIntrinsicDOMException(ctx); - - JS_AddPerformance(ctx); + if (JS_AddIntrinsicBaseObjects(ctx) || + JS_AddIntrinsicDate(ctx) || + JS_AddIntrinsicEval(ctx) || + JS_AddIntrinsicRegExp(ctx) || + JS_AddIntrinsicJSON(ctx) || + JS_AddIntrinsicProxy(ctx) || + JS_AddIntrinsicMapSet(ctx) || + JS_AddIntrinsicTypedArrays(ctx) || + JS_AddIntrinsicPromise(ctx) || + JS_AddIntrinsicWeakRef(ctx) || + JS_AddIntrinsicDOMException(ctx) || + JS_AddPerformance(ctx)) { + JS_FreeContext(ctx); + return NULL; + } return ctx; } @@ -13171,7 +13225,7 @@ static int JS_InitAtoms(JSRuntime *rt) rt->atom_count = 0; rt->atom_size = 0; rt->atom_free_index = 0; - if (JS_ResizeAtomHash(rt, 256)) /* there are at least 195 predefined atoms */ + if (JS_ResizeAtomHash(rt, 512)) /* there are at least 504 predefined atoms */ return -1; p = js_atom_init; @@ -13313,9 +13367,9 @@ static JSAtom __JS_NewAtom(JSRuntime *rt, JSString *str, int atom_type) /* alloc new with size progression 3/2: 4 6 9 13 19 28 42 63 94 141 211 316 474 711 1066 1599 2398 3597 5395 8092 - preallocating space for predefined atoms (at least 195). + preallocating space for predefined atoms (at least 504). */ - new_size = max_int(211, rt->atom_size * 3 / 2); + new_size = max_int(711, rt->atom_size * 3 / 2); if (new_size > JS_ATOM_MAX) goto fail; /* XXX: should use realloc2 to use slack space */ @@ -15375,11 +15429,6 @@ static inline void *get_alloc_from_shape(JSShape *sh) return prop_hash_end(sh) - ((intptr_t)sh->prop_hash_mask + 1); } -static inline JSShapeProperty *get_shape_prop(JSShape *sh) -{ - return sh->prop; -} - static int init_shape_hash(JSRuntime *rt) { rt->shape_hash_bits = 6; /* 64 shapes */ @@ -15395,7 +15444,7 @@ static int init_shape_hash(JSRuntime *rt) /* same magic hash multiplier as the Linux kernel */ static uint32_t shape_hash(uint32_t h, uint32_t val) { - return (h + val) * 0x9e370001; + return hash32(h + val); } /* truncate the shape hash to 'hash_bits' bits */ @@ -15461,19 +15510,14 @@ static void js_shape_hash_unlink(JSRuntime *rt, JSShape *sh) rt->shape_hash_count--; } -/* create a new empty shape with prototype 'proto' */ -static no_inline JSShape *js_new_shape2(JSContext *ctx, JSObject *proto, - int hash_size, int prop_size) +/* create a new empty shape with prototype 'proto'. It is not hashed */ +static inline JSShape *js_new_shape_nohash(JSContext *ctx, JSObject *proto, + int hash_size, int prop_size) { JSRuntime *rt = ctx->rt; void *sh_alloc; JSShape *sh; - /* resize the shape hash table if necessary */ - if (2 * (rt->shape_hash_count + 1) > rt->shape_hash_size) { - resize_shape_hash(rt, rt->shape_hash_bits + 1); - } - sh_alloc = js_malloc(ctx, get_shape_size(hash_size, prop_size)); if (!sh_alloc) return NULL; @@ -15489,6 +15533,25 @@ static no_inline JSShape *js_new_shape2(JSContext *ctx, JSObject *proto, sh->prop_size = prop_size; sh->prop_count = 0; sh->deleted_prop_count = 0; + sh->is_hashed = false; + return sh; +} + +/* create a new empty shape with prototype 'proto' */ +static no_inline JSShape *js_new_shape2(JSContext *ctx, JSObject *proto, + int hash_size, int prop_size) +{ + JSRuntime *rt = ctx->rt; + JSShape *sh; + + /* resize the shape hash table if necessary */ + if (2 * (rt->shape_hash_count + 1) > rt->shape_hash_size) { + resize_shape_hash(rt, rt->shape_hash_bits + 1); + } + + sh = js_new_shape_nohash(ctx, proto, hash_size, prop_size); + if (!sh) + return NULL; /* insert in the hash table */ sh->hash = shape_initial_hash(proto); @@ -15503,6 +15566,40 @@ static JSShape *js_new_shape(JSContext *ctx, JSObject *proto) JS_PROP_INITIAL_SIZE); } +static JSObject *object_or_null(JSValueConst val) +{ + if (JS_TAG_OBJECT == JS_VALUE_GET_TAG(val)) + return JS_VALUE_GET_OBJ(val); + return NULL; +} + +static int add_shape_property(JSContext *ctx, JSShape **psh, + JSObject *p, JSAtom atom, int prop_flags); + +static JSShape *js_new_shape_with2(JSContext *ctx, JSObject *proto, + int prop_count, const JSShapeProperty props[]) { + JSShape *sh; + int i; + + sh = js_new_shape2(ctx, proto, JS_PROP_INITIAL_HASH_SIZE, prop_count); + if (sh) + for (i = 0; i < prop_count; i++) + if (add_shape_property(ctx, &sh, NULL, props[i].atom, props[i].flags)) + goto fail; + return sh; +fail: + js_free_shape(ctx->rt, sh); + return NULL; +} + +static int js_new_shape_with(JSContext *ctx, JSShape **psh, JSValueConst proto, + int prop_count, const JSShapeProperty props[]) { + *psh = js_new_shape_with2(ctx, object_or_null(proto), prop_count, props); + if (*psh) + return 0; + return -1; +} + /* The shape is cloned. The new shape is not inserted in the shape hash table */ static JSShape *js_clone_shape(JSContext *ctx, JSShape *sh1) @@ -15527,7 +15624,7 @@ static JSShape *js_clone_shape(JSContext *ctx, JSShape *sh1) if (sh->proto) { js_dup(JS_MKPTR(JS_TAG_OBJECT, sh->proto)); } - for(i = 0, pr = get_shape_prop(sh); i < sh->prop_count; i++, pr++) { + for(i = 0, pr = sh->prop; i < sh->prop_count; i++, pr++) { JS_DupAtom(ctx, pr->atom); } return sh; @@ -15550,7 +15647,7 @@ static void js_free_shape0(JSRuntime *rt, JSShape *sh) if (sh->proto != NULL) { JS_FreeValueRT(rt, JS_MKPTR(JS_TAG_OBJECT, sh->proto)); } - pr = get_shape_prop(sh); + pr = sh->prop; for(i = 0; i < sh->prop_count; i++) { JS_FreeAtomRT(rt, pr->atom); pr++; @@ -15738,7 +15835,7 @@ static int add_shape_property(JSContext *ctx, JSShape **psh, } /* Initialize the new shape property. The object property at p->prop[sh->prop_count] is uninitialized */ - prop = get_shape_prop(sh); + prop = sh->prop; pr = &prop[sh->prop_count++]; pr->atom = JS_DupAtom(ctx, atom); pr->flags = prop_flags; @@ -15877,7 +15974,7 @@ static JSValue JS_NewObjectFromShape(JSContext *ctx, JSShape *sh, JSClassID clas js_free(ctx, p); fail: if (props) { - JSShapeProperty *prs = get_shape_prop(sh); + JSShapeProperty *prs = sh->prop; for(i = 0; i < sh->prop_count; i++) { free_property(ctx->rt, &props[i], prs->flags); prs++; @@ -15967,14 +16064,6 @@ static JSValue JS_NewObjectFromShape(JSContext *ctx, JSShape *sh, JSClassID clas return JS_MKPTR(JS_TAG_OBJECT, p); } -static JSObject *get_proto_obj(JSValueConst proto_val) -{ - if (JS_VALUE_GET_TAG(proto_val) != JS_TAG_OBJECT) - return NULL; - else - return JS_VALUE_GET_OBJ(proto_val); -} - /* WARNING: proto must be an object or JS_NULL */ JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValueConst proto_val, JSClassID class_id) @@ -15982,7 +16071,7 @@ JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValueConst proto_val, JSShape *sh; JSObject *proto; - proto = get_proto_obj(proto_val); + proto = object_or_null(proto_val); sh = find_hashed_shape_proto(ctx->rt, proto); if (likely(sh)) { sh = js_dup_shape(sh); @@ -15994,6 +16083,29 @@ JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValueConst proto_val, return JS_NewObjectFromShape(ctx, sh, class_id, NULL); } +/* WARNING: the shape is not hashed. It is used for objects where + factorizing the shape is not relevant (prototypes, constructors) */ +static JSValue JS_NewObjectProtoClassAlloc(JSContext *ctx, JSValueConst proto_val, + JSClassID class_id, int n_alloc_props) +{ + JSShape *sh; + JSObject *proto; + int hash_size, hash_bits; + + if (n_alloc_props <= JS_PROP_INITIAL_SIZE) { + n_alloc_props = JS_PROP_INITIAL_SIZE; + hash_size = JS_PROP_INITIAL_HASH_SIZE; + } else { + hash_bits = 32 - clz32(n_alloc_props - 1); /* ceil(log2(radix)) */ + hash_size = 1 << hash_bits; + } + proto = object_or_null(proto_val); + sh = js_new_shape_nohash(ctx, proto, hash_size, n_alloc_props); + if (!sh) + return JS_EXCEPTION; + return JS_NewObjectFromShape(ctx, sh, class_id, NULL); +} + static int JS_SetObjectData(JSContext *ctx, JSValueConst obj, JSValue val) { JSObject *p; @@ -16240,13 +16352,17 @@ static int js_method_set_properties(JSContext *ctx, JSValue func_obj, JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func, const char *name, int length, JSCFunctionEnum cproto, int magic, - JSValueConst proto_val) + JSValueConst proto_val, int n_fields) { JSValue func_obj; JSObject *p; JSAtom name_atom; - func_obj = JS_NewObjectProtoClass(ctx, proto_val, JS_CLASS_C_FUNCTION); + if (n_fields > 0) { + func_obj = JS_NewObjectProtoClassAlloc(ctx, proto_val, JS_CLASS_C_FUNCTION, n_fields); + } else { + func_obj = JS_NewObjectProtoClass(ctx, proto_val, JS_CLASS_C_FUNCTION); + } if (JS_IsException(func_obj)) return func_obj; p = JS_VALUE_GET_OBJ(func_obj); @@ -16278,7 +16394,7 @@ JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func, int length, JSCFunctionEnum cproto, int magic) { return JS_NewCFunction3(ctx, func, name, length, cproto, magic, - ctx->function_proto); + ctx->function_proto, 0); } typedef struct JSCFunctionDataRecord { @@ -16543,7 +16659,7 @@ static inline JSShapeProperty *find_own_property1(JSObject *p, JSAtom atom) sh = p->shape; h = (uintptr_t)atom & sh->prop_hash_mask; h = prop_hash_end(sh)[-h - 1]; - prop = get_shape_prop(sh); + prop = sh->prop; while (h) { pr = &prop[h - 1]; if (likely(pr->atom == atom)) { @@ -16564,7 +16680,7 @@ static inline JSShapeProperty *find_own_property(JSProperty **ppr, sh = p->shape; h = (uintptr_t)atom & sh->prop_hash_mask; h = prop_hash_end(sh)[-h - 1]; - prop = get_shape_prop(sh); + prop = sh->prop; while (h) { pr = &prop[h - 1]; if (likely(pr->atom == atom)) { @@ -16753,7 +16869,7 @@ static void free_object(JSRuntime *rt, JSObject *p) freeing cycles */ /* free all the fields */ sh = p->shape; - pr = get_shape_prop(sh); + pr = sh->prop; for(i = 0; i < sh->prop_count; i++) { free_property(rt, &p->prop[i], pr->flags); pr++; @@ -16960,7 +17076,7 @@ static void mark_children(JSRuntime *rt, JSGCObjectHeader *gp, sh = p->shape; mark_func(rt, &sh->header); /* mark all the fields */ - prs = get_shape_prop(sh); + prs = sh->prop; for(i = 0; i < sh->prop_count; i++) { JSProperty *pr = &p->prop[i]; if (prs->atom != JS_ATOM_NULL) { @@ -17344,7 +17460,7 @@ void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s) s->memory_used_count++; s->prop_size += sh->prop_size * sizeof(*p->prop); s->prop_count += sh->prop_count; - prs = get_shape_prop(sh); + prs = sh->prop; for(i = 0; i < sh->prop_count; i++) { JSProperty *pr = &p->prop[i]; if (prs->atom != JS_ATOM_NULL && !(prs->flags & JS_PROP_TMASK)) { @@ -17555,8 +17671,8 @@ void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s) void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt) { - fprintf(fp, "QuickJS-ng memory usage -- %s version, %d-bit, %s Endian, malloc limit: %"PRId64"\n\n", - JS_GetVersion(), (int)sizeof(void *) * 8, is_be() ? "Big" : "Little", s->malloc_limit); + fprintf(fp, "QuickJS-ng memory usage -- %s version, %d-bit, malloc limit: %"PRId64"\n\n", + JS_GetVersion(), (int)sizeof(void *) * 8, s->malloc_limit); if (rt) { static const struct { const char *name; @@ -18594,541 +18710,213 @@ int JS_IsInstanceOf(JSContext *ctx, JSValueConst val, JSValueConst obj) #include -const uint32_t qjsc_builtin_array_fromasync_size = 871; +const uint32_t qjsc_builtin_array_fromasync_size = 875; -const uint8_t qjsc_builtin_array_fromasync[871] = { - 0x17, 0x0e, 0x01, 0x28, 0x53, 0x79, 0x6d, 0x62, - 0x6f, 0x6c, 0xb7, 0x61, 0x73, 0x79, 0x6e, 0x63, +const uint8_t qjsc_builtin_array_fromasync[875] = { + 0x18, 0x19, 0x88, 0x92, 0xde, 0x0e, 0x01, 0x28, + 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0xb7, 0x61, + 0x73, 0x79, 0x6e, 0x63, 0x49, 0x74, 0x65, 0x72, + 0x61, 0x74, 0x6f, 0x72, 0x01, 0x2a, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0xb7, 0x64, 0x65, 0x66, + 0x69, 0x6e, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x79, 0x01, 0x1e, 0x53, 0x79, 0x6d, + 0x62, 0x6f, 0x6c, 0xb7, 0x69, 0x74, 0x65, 0x72, + 0x61, 0x74, 0x6f, 0x72, 0x01, 0x12, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x4c, 0x69, 0x6b, 0x65, 0x01, + 0x0a, 0x6d, 0x61, 0x70, 0x46, 0x6e, 0x01, 0x0e, + 0x74, 0x68, 0x69, 0x73, 0x41, 0x72, 0x67, 0x01, + 0x0c, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x01, + 0x02, 0x69, 0x01, 0x1a, 0x69, 0x73, 0x43, 0x6f, + 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x6f, + 0x72, 0x01, 0x08, 0x73, 0x79, 0x6e, 0x63, 0x01, + 0x0c, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x01, + 0x08, 0x69, 0x74, 0x65, 0x72, 0x01, 0x1c, 0x6e, + 0x6f, 0x74, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6e, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x01, 0x08, 0x63, + 0x61, 0x6c, 0x6c, 0x0c, 0x00, 0x02, 0x00, 0xa2, + 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, + 0x04, 0x01, 0xa4, 0x01, 0x00, 0x00, 0x00, 0x0c, + 0x43, 0x02, 0x01, 0x00, 0x05, 0x00, 0x05, 0x01, + 0x05, 0x00, 0x01, 0x03, 0x05, 0xae, 0x02, 0x00, + 0x01, 0x40, 0x03, 0xa4, 0x03, 0x00, 0x01, 0x40, + 0x00, 0xca, 0x03, 0x00, 0x01, 0x40, 0x01, 0xcc, + 0x03, 0x00, 0x01, 0x40, 0x04, 0xce, 0x03, 0x00, + 0x01, 0x40, 0x02, 0x0c, 0x60, 0x02, 0x01, 0xf8, + 0x01, 0x03, 0x0e, 0x01, 0x06, 0x00, 0x05, 0x00, + 0x86, 0x04, 0x11, 0xd0, 0x03, 0x00, 0x01, 0x00, + 0xd2, 0x03, 0x00, 0x01, 0x00, 0xd4, 0x03, 0x00, + 0x01, 0x00, 0xd0, 0x03, 0x01, 0xff, 0xff, 0xff, + 0xff, 0x0f, 0x20, 0xd2, 0x03, 0x01, 0x01, 0x20, + 0xd4, 0x03, 0x01, 0x02, 0x20, 0xd6, 0x03, 0x02, + 0x00, 0x20, 0xd8, 0x03, 0x02, 0x04, 0x20, 0xda, + 0x03, 0x02, 0x05, 0x20, 0xdc, 0x03, 0x02, 0x06, + 0x20, 0xde, 0x03, 0x02, 0x07, 0x20, 0x64, 0x06, + 0x08, 0x20, 0x82, 0x01, 0x07, 0x09, 0x20, 0xe0, + 0x03, 0x0a, 0x08, 0x30, 0x82, 0x01, 0x0d, 0x0b, + 0x20, 0xd4, 0x01, 0x0d, 0x0c, 0x20, 0x10, 0x00, + 0x01, 0x00, 0xa4, 0x03, 0x01, 0x01, 0xca, 0x03, + 0x02, 0x01, 0xce, 0x03, 0x04, 0x01, 0xae, 0x02, + 0x00, 0x01, 0xcc, 0x03, 0x03, 0x01, 0x08, 0xc2, + 0x0d, 0x60, 0x02, 0x00, 0x60, 0x01, 0x00, 0x60, + 0x00, 0x00, 0xd1, 0xc9, 0xd2, 0x11, 0xf2, 0xea, + 0x08, 0x0e, 0x38, 0x46, 0x00, 0x00, 0x00, 0xda, + 0xca, 0xd3, 0x11, 0xf2, 0xea, 0x08, 0x0e, 0x38, + 0x46, 0x00, 0x00, 0x00, 0xdb, 0xcb, 0x60, 0x07, + 0x00, 0x60, 0x06, 0x00, 0x60, 0x05, 0x00, 0x60, + 0x04, 0x00, 0x60, 0x03, 0x00, 0xd2, 0x38, 0x46, + 0x00, 0x00, 0x00, 0xae, 0xea, 0x16, 0xd2, 0x96, + 0x04, 0x1b, 0x00, 0x00, 0x00, 0xae, 0xea, 0x0c, + 0xdd, 0x11, 0x04, 0xf1, 0x00, 0x00, 0x00, 0x21, + 0x01, 0x00, 0x30, 0x06, 0xcc, 0xb4, 0xc2, 0x04, + 0xc1, 0x0d, 0xf5, 0xc2, 0x05, 0x09, 0xc2, 0x06, + 0xd1, 0xde, 0x46, 0xc2, 0x07, 0x61, 0x07, 0x00, + 0x07, 0xab, 0xea, 0x0f, 0x0a, 0x11, 0x62, 0x06, + 0x00, 0x0e, 0xd1, 0xdf, 0x46, 0x11, 0x62, 0x07, + 0x00, 0x0e, 0x61, 0x07, 0x00, 0x07, 0xab, 0x68, + 0xa6, 0x00, 0x00, 0x00, 0x60, 0x08, 0x00, 0x06, + 0x11, 0xf2, 0xeb, 0x0c, 0x6f, 0x41, 0x32, 0x00, + 0x00, 0x00, 0xc2, 0x08, 0x0e, 0xec, 0x05, 0x0e, + 0xd1, 0xec, 0xf2, 0x61, 0x08, 0x00, 0x8c, 0x11, + 0xeb, 0x03, 0x0e, 0xb4, 0x11, 0x62, 0x08, 0x00, + 0x0e, 0x61, 0x05, 0x00, 0xea, 0x0c, 0xc1, 0x0d, + 0x11, 0x61, 0x08, 0x00, 0x21, 0x01, 0x00, 0xec, + 0x06, 0xe0, 0x61, 0x08, 0x00, 0xef, 0x11, 0x62, + 0x03, 0x00, 0x0e, 0x61, 0x04, 0x00, 0x61, 0x08, + 0x00, 0xa5, 0x68, 0x2a, 0x01, 0x00, 0x00, 0x60, + 0x09, 0x00, 0xd1, 0x61, 0x04, 0x00, 0x46, 0xc2, + 0x09, 0x61, 0x06, 0x00, 0xea, 0x0a, 0x61, 0x09, + 0x00, 0x8a, 0x11, 0x62, 0x09, 0x00, 0x0e, 0xd2, + 0xea, 0x17, 0xd2, 0x41, 0xf2, 0x00, 0x00, 0x00, + 0xd3, 0x61, 0x09, 0x00, 0x61, 0x04, 0x00, 0x24, + 0x03, 0x00, 0x8a, 0x11, 0x62, 0x09, 0x00, 0x0e, + 0x5d, 0x04, 0x00, 0x61, 0x03, 0x00, 0x61, 0x04, + 0x00, 0x90, 0x62, 0x04, 0x00, 0x0b, 0x61, 0x09, + 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, + 0x3e, 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x3f, 0x00, + 0x00, 0x00, 0xf1, 0x0e, 0xec, 0x9e, 0x60, 0x0a, + 0x00, 0x61, 0x07, 0x00, 0x41, 0xf2, 0x00, 0x00, + 0x00, 0xd1, 0x24, 0x01, 0x00, 0xc2, 0x0a, 0x61, + 0x05, 0x00, 0xea, 0x09, 0xc1, 0x0d, 0x11, 0x21, + 0x00, 0x00, 0xec, 0x03, 0xe0, 0xee, 0x11, 0x62, + 0x03, 0x00, 0x0e, 0x6b, 0x8c, 0x00, 0x00, 0x00, + 0x60, 0x0c, 0x00, 0x60, 0x0b, 0x00, 0x06, 0x11, + 0xf2, 0xeb, 0x13, 0x6f, 0x41, 0x41, 0x00, 0x00, + 0x00, 0xc2, 0x0b, 0x41, 0x6a, 0x00, 0x00, 0x00, + 0xc2, 0x0c, 0x0e, 0xec, 0x10, 0x0e, 0x61, 0x0a, + 0x00, 0x41, 0x6b, 0x00, 0x00, 0x00, 0x24, 0x00, + 0x00, 0x8a, 0xec, 0xe0, 0x61, 0x0c, 0x00, 0xeb, + 0x4e, 0x61, 0x06, 0x00, 0xea, 0x0a, 0x61, 0x0b, + 0x00, 0x8a, 0x11, 0x62, 0x0b, 0x00, 0x0e, 0xd2, + 0xea, 0x17, 0xd2, 0x41, 0xf2, 0x00, 0x00, 0x00, + 0xd3, 0x61, 0x0b, 0x00, 0x61, 0x04, 0x00, 0x24, + 0x03, 0x00, 0x8a, 0x11, 0x62, 0x0b, 0x00, 0x0e, + 0x5d, 0x04, 0x00, 0x61, 0x03, 0x00, 0x61, 0x04, + 0x00, 0x90, 0x62, 0x04, 0x00, 0x0b, 0x61, 0x0b, + 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, + 0x3e, 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x3f, 0x00, + 0x00, 0x00, 0xf1, 0x0e, 0xec, 0x83, 0x0e, 0x06, + 0x6c, 0x0d, 0x00, 0x00, 0x00, 0x0e, 0xec, 0x1e, + 0x6c, 0x05, 0x00, 0x00, 0x00, 0x30, 0x61, 0x0a, + 0x00, 0x40, 0x06, 0x00, 0x00, 0x00, 0xea, 0x0d, + 0x61, 0x0a, 0x00, 0x41, 0x06, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x0e, 0x6d, 0x61, 0x03, 0x00, + 0x61, 0x04, 0x00, 0x42, 0x32, 0x00, 0x00, 0x00, + 0x61, 0x03, 0x00, 0x2f, 0xbf, 0x00, 0x28, 0xbf, + 0x00, 0xcd, 0x28, +}; + + +/* File generated automatically by the QuickJS-ng compiler. */ + +#include + +const uint32_t qjsc_builtin_iterator_zip_keyed_size = 2582; + +const uint8_t qjsc_builtin_iterator_zip_keyed[2582] = { + 0x18, 0x17, 0x21, 0x08, 0xd4, 0x2b, 0x01, 0x1c, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, - 0x01, 0x2a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0xb7, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x50, - 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x01, - 0x1e, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0xb7, - 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, - 0x01, 0x12, 0x61, 0x72, 0x72, 0x61, 0x79, 0x4c, - 0x69, 0x6b, 0x65, 0x01, 0x0a, 0x6d, 0x61, 0x70, - 0x46, 0x6e, 0x01, 0x0e, 0x74, 0x68, 0x69, 0x73, - 0x41, 0x72, 0x67, 0x01, 0x0c, 0x72, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x01, 0x02, 0x69, 0x01, 0x1a, - 0x69, 0x73, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, - 0x75, 0x63, 0x74, 0x6f, 0x72, 0x01, 0x08, 0x73, - 0x79, 0x6e, 0x63, 0x01, 0x0c, 0x6d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x01, 0x08, 0x69, 0x74, 0x65, - 0x72, 0x01, 0x1c, 0x6e, 0x6f, 0x74, 0x20, 0x61, - 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x01, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x0c, - 0x00, 0x02, 0x00, 0xa2, 0x01, 0x00, 0x01, 0x00, - 0x01, 0x00, 0x00, 0x01, 0x04, 0x01, 0xa4, 0x01, - 0x00, 0x00, 0x00, 0x0c, 0x43, 0x02, 0x01, 0x00, - 0x05, 0x00, 0x05, 0x01, 0x05, 0x00, 0x01, 0x03, - 0x05, 0xae, 0x02, 0x00, 0x01, 0x40, 0x03, 0xa4, - 0x03, 0x00, 0x01, 0x40, 0x00, 0xca, 0x03, 0x00, - 0x01, 0x40, 0x01, 0xcc, 0x03, 0x00, 0x01, 0x40, - 0x04, 0xce, 0x03, 0x00, 0x01, 0x40, 0x02, 0x0c, - 0x60, 0x02, 0x01, 0xf8, 0x01, 0x03, 0x0e, 0x01, - 0x06, 0x00, 0x05, 0x00, 0x86, 0x04, 0x11, 0xd0, - 0x03, 0x00, 0x01, 0x00, 0xd2, 0x03, 0x00, 0x01, - 0x00, 0xd4, 0x03, 0x00, 0x01, 0x00, 0xd0, 0x03, - 0x01, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x20, 0xd2, - 0x03, 0x01, 0x01, 0x20, 0xd4, 0x03, 0x01, 0x02, - 0x20, 0xd6, 0x03, 0x02, 0x00, 0x20, 0xd8, 0x03, - 0x02, 0x04, 0x20, 0xda, 0x03, 0x02, 0x05, 0x20, - 0xdc, 0x03, 0x02, 0x06, 0x20, 0xde, 0x03, 0x02, - 0x07, 0x20, 0x64, 0x06, 0x08, 0x20, 0x82, 0x01, - 0x07, 0x09, 0x20, 0xe0, 0x03, 0x0a, 0x08, 0x30, - 0x82, 0x01, 0x0d, 0x0b, 0x20, 0xd4, 0x01, 0x0d, - 0x0c, 0x20, 0x10, 0x00, 0x01, 0x00, 0xa4, 0x03, - 0x01, 0x01, 0xca, 0x03, 0x02, 0x01, 0xce, 0x03, - 0x04, 0x01, 0xae, 0x02, 0x00, 0x01, 0xcc, 0x03, - 0x03, 0x01, 0x08, 0xc2, 0x0d, 0x60, 0x02, 0x00, - 0x60, 0x01, 0x00, 0x60, 0x00, 0x00, 0xd1, 0xc9, - 0xd2, 0x11, 0xf2, 0xea, 0x08, 0x0e, 0x38, 0x46, - 0x00, 0x00, 0x00, 0xda, 0xca, 0xd3, 0x11, 0xf2, - 0xea, 0x08, 0x0e, 0x38, 0x46, 0x00, 0x00, 0x00, - 0xdb, 0xcb, 0x60, 0x07, 0x00, 0x60, 0x06, 0x00, - 0x60, 0x05, 0x00, 0x60, 0x04, 0x00, 0x60, 0x03, - 0x00, 0xd2, 0x38, 0x46, 0x00, 0x00, 0x00, 0xae, - 0xea, 0x16, 0xd2, 0x96, 0x04, 0x1b, 0x00, 0x00, - 0x00, 0xae, 0xea, 0x0c, 0xdd, 0x11, 0x04, 0xf1, - 0x00, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x06, - 0xcc, 0xb4, 0xc2, 0x04, 0xc1, 0x0d, 0xf5, 0xc2, - 0x05, 0x09, 0xc2, 0x06, 0xd1, 0xde, 0x46, 0xc2, - 0x07, 0x61, 0x07, 0x00, 0x07, 0xab, 0xea, 0x0f, - 0x0a, 0x11, 0x62, 0x06, 0x00, 0x0e, 0xd1, 0xdf, - 0x46, 0x11, 0x62, 0x07, 0x00, 0x0e, 0x61, 0x07, - 0x00, 0x07, 0xab, 0x68, 0xa6, 0x00, 0x00, 0x00, - 0x60, 0x08, 0x00, 0x06, 0x11, 0xf2, 0xeb, 0x0c, - 0x6f, 0x41, 0x32, 0x00, 0x00, 0x00, 0xc2, 0x08, - 0x0e, 0xec, 0x05, 0x0e, 0xd1, 0xec, 0xf2, 0x61, - 0x08, 0x00, 0x8c, 0x11, 0xeb, 0x03, 0x0e, 0xb4, - 0x11, 0x62, 0x08, 0x00, 0x0e, 0x61, 0x05, 0x00, - 0xea, 0x0c, 0xc1, 0x0d, 0x11, 0x61, 0x08, 0x00, - 0x21, 0x01, 0x00, 0xec, 0x06, 0xe0, 0x61, 0x08, - 0x00, 0xef, 0x11, 0x62, 0x03, 0x00, 0x0e, 0x61, - 0x04, 0x00, 0x61, 0x08, 0x00, 0xa5, 0x68, 0x2a, - 0x01, 0x00, 0x00, 0x60, 0x09, 0x00, 0xd1, 0x61, - 0x04, 0x00, 0x46, 0xc2, 0x09, 0x61, 0x06, 0x00, - 0xea, 0x0a, 0x61, 0x09, 0x00, 0x8a, 0x11, 0x62, - 0x09, 0x00, 0x0e, 0xd2, 0xea, 0x17, 0xd2, 0x41, - 0xf2, 0x00, 0x00, 0x00, 0xd3, 0x61, 0x09, 0x00, - 0x61, 0x04, 0x00, 0x24, 0x03, 0x00, 0x8a, 0x11, - 0x62, 0x09, 0x00, 0x0e, 0x5d, 0x04, 0x00, 0x61, - 0x03, 0x00, 0x61, 0x04, 0x00, 0x90, 0x62, 0x04, - 0x00, 0x0b, 0x61, 0x09, 0x00, 0x4b, 0x41, 0x00, - 0x00, 0x00, 0x0a, 0x4b, 0x3e, 0x00, 0x00, 0x00, - 0x0a, 0x4b, 0x3f, 0x00, 0x00, 0x00, 0xf1, 0x0e, - 0xec, 0x9e, 0x60, 0x0a, 0x00, 0x61, 0x07, 0x00, - 0x41, 0xf2, 0x00, 0x00, 0x00, 0xd1, 0x24, 0x01, - 0x00, 0xc2, 0x0a, 0x61, 0x05, 0x00, 0xea, 0x09, - 0xc1, 0x0d, 0x11, 0x21, 0x00, 0x00, 0xec, 0x03, - 0xe0, 0xee, 0x11, 0x62, 0x03, 0x00, 0x0e, 0x6b, - 0x8c, 0x00, 0x00, 0x00, 0x60, 0x0c, 0x00, 0x60, - 0x0b, 0x00, 0x06, 0x11, 0xf2, 0xeb, 0x13, 0x6f, - 0x41, 0x41, 0x00, 0x00, 0x00, 0xc2, 0x0b, 0x41, - 0x6a, 0x00, 0x00, 0x00, 0xc2, 0x0c, 0x0e, 0xec, - 0x10, 0x0e, 0x61, 0x0a, 0x00, 0x41, 0x6b, 0x00, - 0x00, 0x00, 0x24, 0x00, 0x00, 0x8a, 0xec, 0xe0, - 0x61, 0x0c, 0x00, 0xeb, 0x4e, 0x61, 0x06, 0x00, - 0xea, 0x0a, 0x61, 0x0b, 0x00, 0x8a, 0x11, 0x62, - 0x0b, 0x00, 0x0e, 0xd2, 0xea, 0x17, 0xd2, 0x41, - 0xf2, 0x00, 0x00, 0x00, 0xd3, 0x61, 0x0b, 0x00, - 0x61, 0x04, 0x00, 0x24, 0x03, 0x00, 0x8a, 0x11, - 0x62, 0x0b, 0x00, 0x0e, 0x5d, 0x04, 0x00, 0x61, - 0x03, 0x00, 0x61, 0x04, 0x00, 0x90, 0x62, 0x04, - 0x00, 0x0b, 0x61, 0x0b, 0x00, 0x4b, 0x41, 0x00, - 0x00, 0x00, 0x0a, 0x4b, 0x3e, 0x00, 0x00, 0x00, - 0x0a, 0x4b, 0x3f, 0x00, 0x00, 0x00, 0xf1, 0x0e, - 0xec, 0x83, 0x0e, 0x06, 0x6c, 0x0d, 0x00, 0x00, - 0x00, 0x0e, 0xec, 0x1e, 0x6c, 0x05, 0x00, 0x00, - 0x00, 0x30, 0x61, 0x0a, 0x00, 0x40, 0x06, 0x00, - 0x00, 0x00, 0xea, 0x0d, 0x61, 0x0a, 0x00, 0x41, - 0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x0e, - 0x6d, 0x61, 0x03, 0x00, 0x61, 0x04, 0x00, 0x42, - 0x32, 0x00, 0x00, 0x00, 0x61, 0x03, 0x00, 0x2f, - 0xbf, 0x00, 0x28, 0xbf, 0x00, 0xcd, 0x28, -}; - - -/* File generated automatically by the QuickJS-ng compiler. */ - -#include - -const uint32_t qjsc_builtin_iterator_zip_keyed_size = 2578; - -const uint8_t qjsc_builtin_iterator_zip_keyed[2578] = { - 0x17, 0x2b, 0x01, 0x1c, 0x49, 0x74, 0x65, 0x72, - 0x61, 0x74, 0x6f, 0x72, 0x48, 0x65, 0x6c, 0x70, - 0x65, 0x72, 0x01, 0x08, 0x63, 0x61, 0x6c, 0x6c, - 0x01, 0x24, 0x68, 0x61, 0x73, 0x4f, 0x77, 0x6e, - 0x45, 0x6e, 0x75, 0x6d, 0x50, 0x72, 0x6f, 0x70, - 0x65, 0x72, 0x74, 0x79, 0x01, 0x24, 0x67, 0x65, - 0x74, 0x4f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x70, - 0x65, 0x72, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x73, - 0x01, 0x1e, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, - 0xb7, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, - 0x72, 0x01, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, - 0x01, 0x0a, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x01, - 0x10, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x61, 0x6c, - 0x6c, 0x01, 0x02, 0x76, 0x01, 0x02, 0x73, 0x01, - 0x08, 0x69, 0x74, 0x65, 0x72, 0x01, 0x0c, 0x6d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x01, 0x02, 0x65, - 0x01, 0x0a, 0x69, 0x74, 0x65, 0x72, 0x73, 0x01, - 0x0a, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x01, 0x04, - 0x65, 0x78, 0x01, 0x02, 0x69, 0x01, 0x12, 0x69, - 0x74, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x73, - 0x01, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x01, 0x08, 0x6d, 0x6f, 0x64, 0x65, 0x01, - 0x0e, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, - 0x01, 0x0a, 0x6e, 0x65, 0x78, 0x74, 0x73, 0x01, - 0x08, 0x70, 0x61, 0x64, 0x73, 0x01, 0x06, 0x6b, - 0x65, 0x79, 0x01, 0x06, 0x64, 0x65, 0x6c, 0x01, - 0x02, 0x6a, 0x01, 0x0a, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x01, 0x0a, 0x61, 0x6c, 0x69, 0x76, 0x65, - 0x01, 0x0a, 0x64, 0x6f, 0x6e, 0x65, 0x73, 0x01, - 0x0e, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, - 0x01, 0x0c, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x01, 0x1c, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, - 0x67, 0x20, 0x7a, 0x69, 0x70, 0x70, 0x65, 0x72, - 0x01, 0x06, 0x62, 0x75, 0x67, 0x01, 0x0e, 0x6c, - 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x01, 0x0c, - 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x01, 0x22, - 0x6d, 0x69, 0x73, 0x6d, 0x61, 0x74, 0x63, 0x68, - 0x65, 0x64, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, - 0x73, 0x01, 0x10, 0x73, 0x68, 0x6f, 0x72, 0x74, - 0x65, 0x73, 0x74, 0x01, 0x16, 0x62, 0x75, 0x67, - 0x3a, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3d, - 0x01, 0x1a, 0x62, 0x61, 0x64, 0x20, 0x69, 0x74, - 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x01, - 0x16, 0x62, 0x61, 0x64, 0x20, 0x6f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x01, 0x10, 0x62, 0x61, - 0x64, 0x20, 0x6d, 0x6f, 0x64, 0x65, 0x01, 0x16, - 0x62, 0x61, 0x64, 0x20, 0x70, 0x61, 0x64, 0x64, - 0x69, 0x6e, 0x67, 0x01, 0x18, 0x62, 0x61, 0x64, - 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, - 0x72, 0x0c, 0x00, 0x02, 0x00, 0xa2, 0x01, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x04, 0x01, - 0xa4, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x43, 0x02, - 0x00, 0x00, 0x07, 0x03, 0x07, 0x01, 0x0a, 0x00, - 0x04, 0x0c, 0x0a, 0xca, 0x03, 0x00, 0x01, 0x40, - 0x09, 0xa8, 0x03, 0x00, 0x01, 0x40, 0x03, 0xa4, - 0x03, 0x00, 0x01, 0x40, 0x00, 0xcc, 0x03, 0x00, - 0x01, 0x40, 0x01, 0xce, 0x03, 0x00, 0x01, 0x40, - 0x07, 0xd0, 0x03, 0x00, 0x01, 0x40, 0x06, 0xd2, - 0x03, 0x00, 0x01, 0x40, 0x08, 0xd4, 0x03, 0x00, - 0x00, 0x40, 0x05, 0xd6, 0x03, 0x00, 0x01, 0x40, - 0x02, 0xd8, 0x03, 0x00, 0x02, 0x40, 0x04, 0x0c, - 0x43, 0x02, 0x00, 0xd4, 0x03, 0x02, 0x00, 0x02, - 0x03, 0x00, 0x01, 0x00, 0x17, 0x02, 0xda, 0x03, - 0x00, 0x01, 0x00, 0xdc, 0x03, 0x00, 0x01, 0x00, - 0xa4, 0x03, 0x02, 0x01, 0xd1, 0x96, 0x04, 0x4a, - 0x00, 0x00, 0x00, 0xad, 0xea, 0x07, 0xd1, 0x07, - 0xae, 0xea, 0x02, 0x29, 0xdd, 0x11, 0xd2, 0x21, - 0x01, 0x00, 0x30, 0x0c, 0x43, 0x02, 0x00, 0xd6, - 0x03, 0x01, 0x02, 0x01, 0x04, 0x00, 0x01, 0x00, - 0x2e, 0x03, 0xde, 0x03, 0x00, 0x01, 0x00, 0xe0, - 0x03, 0x02, 0x00, 0x20, 0xe2, 0x03, 0x05, 0x00, - 0x03, 0xcc, 0x03, 0x03, 0x01, 0x6b, 0x23, 0x00, - 0x00, 0x00, 0x60, 0x00, 0x00, 0xd1, 0x95, 0xea, - 0x04, 0x06, 0x6e, 0x28, 0xd1, 0x40, 0x06, 0x00, - 0x00, 0x00, 0xc9, 0x61, 0x00, 0x00, 0xea, 0x08, - 0xdd, 0xd1, 0x61, 0x00, 0x00, 0xf0, 0x0e, 0x0e, - 0x29, 0xca, 0x6b, 0x07, 0x00, 0x00, 0x00, 0xc6, - 0x6e, 0x28, 0x30, 0x0c, 0x43, 0x02, 0x00, 0xd8, - 0x03, 0x02, 0x04, 0x02, 0x03, 0x00, 0x01, 0x00, - 0x55, 0x06, 0xe4, 0x03, 0x00, 0x01, 0x00, 0xe6, - 0x03, 0x00, 0x01, 0x00, 0xe8, 0x03, 0x01, 0x00, - 0x20, 0xea, 0x03, 0x02, 0x01, 0x20, 0xde, 0x03, - 0x03, 0x02, 0x20, 0xe2, 0x03, 0x03, 0x03, 0x20, - 0xd6, 0x03, 0x01, 0x00, 0x60, 0x00, 0x00, 0x38, - 0x46, 0x00, 0x00, 0x00, 0xc9, 0x60, 0x01, 0x00, - 0xd2, 0xca, 0x61, 0x01, 0x00, 0x8f, 0x62, 0x01, - 0x00, 0xb4, 0xa7, 0xea, 0x39, 0x60, 0x03, 0x00, - 0x60, 0x02, 0x00, 0xd1, 0x61, 0x01, 0x00, 0x46, - 0xcb, 0xd1, 0x61, 0x01, 0x00, 0x1b, 0x11, 0xaf, - 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x38, 0x46, - 0x00, 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0xdd, - 0x61, 0x02, 0x00, 0xef, 0xcc, 0x61, 0x00, 0x00, - 0x95, 0xea, 0xc8, 0x61, 0x03, 0x00, 0x11, 0x62, - 0x00, 0x00, 0x0e, 0xec, 0xbe, 0x61, 0x00, 0x00, - 0x28, 0x0c, 0x41, 0x02, 0x00, 0xaa, 0x02, 0x02, - 0x15, 0x01, 0x06, 0x08, 0x09, 0x02, 0xc9, 0x05, - 0x17, 0xec, 0x03, 0x00, 0x01, 0x00, 0xee, 0x03, - 0x00, 0x01, 0x00, 0xec, 0x03, 0x01, 0xff, 0xff, - 0xff, 0xff, 0x0f, 0x20, 0xee, 0x03, 0x01, 0x01, - 0x20, 0xf0, 0x03, 0x02, 0x00, 0x60, 0x04, 0xf2, - 0x03, 0x02, 0x03, 0x20, 0x60, 0x02, 0x04, 0x60, - 0x02, 0xe6, 0x03, 0x02, 0x05, 0x60, 0x01, 0xe4, - 0x03, 0x02, 0x06, 0x60, 0x03, 0xf4, 0x03, 0x02, - 0x07, 0x60, 0x06, 0xf6, 0x03, 0x02, 0x08, 0x60, - 0x05, 0xf8, 0x03, 0x09, 0x15, 0x20, 0xea, 0x03, - 0x0b, 0x15, 0x20, 0xfa, 0x03, 0x0c, 0x0b, 0x20, - 0xf8, 0x03, 0x0c, 0x0c, 0x20, 0xde, 0x03, 0x0e, - 0x0d, 0x20, 0xe0, 0x03, 0x10, 0x0e, 0x20, 0xfc, - 0x03, 0x14, 0x0d, 0x20, 0xea, 0x03, 0x19, 0x15, - 0x20, 0xea, 0x03, 0x1b, 0x15, 0x20, 0xe2, 0x03, - 0x1c, 0x15, 0x03, 0xfe, 0x03, 0x02, 0x09, 0x60, - 0x00, 0x80, 0x04, 0x02, 0x14, 0x60, 0x07, 0xa4, - 0x03, 0x02, 0x01, 0xa8, 0x03, 0x01, 0x01, 0xcc, - 0x03, 0x03, 0x01, 0xd8, 0x03, 0x02, 0x00, 0xd4, - 0x03, 0x00, 0x00, 0xd0, 0x03, 0x05, 0x01, 0xce, - 0x03, 0x04, 0x01, 0xd2, 0x03, 0x06, 0x01, 0xca, - 0x03, 0x00, 0x01, 0x0c, 0x42, 0x03, 0x00, 0x00, - 0x00, 0x09, 0x00, 0x05, 0x00, 0x0c, 0x00, 0xf7, - 0x04, 0x09, 0x82, 0x04, 0x01, 0x00, 0x20, 0xd8, - 0x01, 0x01, 0x01, 0x20, 0x84, 0x04, 0x01, 0x02, - 0x20, 0xea, 0x03, 0x03, 0x03, 0x20, 0xf8, 0x03, - 0x04, 0x04, 0x20, 0xde, 0x03, 0x04, 0x05, 0x20, - 0x86, 0x04, 0x04, 0x06, 0x20, 0xe2, 0x03, 0x09, - 0x07, 0x03, 0xe8, 0x03, 0x10, 0x07, 0x20, 0xfe, - 0x03, 0x13, 0x10, 0xa4, 0x03, 0x00, 0x02, 0xa8, - 0x03, 0x01, 0x02, 0xe6, 0x03, 0x05, 0x10, 0x60, - 0x04, 0x10, 0xe4, 0x03, 0x06, 0x10, 0xf0, 0x03, - 0x02, 0x10, 0xf6, 0x03, 0x08, 0x10, 0xcc, 0x03, - 0x02, 0x02, 0xf4, 0x03, 0x07, 0x10, 0x80, 0x04, - 0x14, 0x10, 0xd8, 0x03, 0x03, 0x02, 0x60, 0x02, - 0x00, 0x60, 0x01, 0x00, 0x60, 0x00, 0x00, 0x64, - 0x00, 0x00, 0x11, 0xb4, 0xad, 0xeb, 0x06, 0x11, - 0xb5, 0xad, 0xea, 0x09, 0xb6, 0x11, 0x65, 0x00, - 0x00, 0x0e, 0xec, 0x33, 0x11, 0xb6, 0xad, 0xea, - 0x0c, 0xde, 0x11, 0x04, 0x04, 0x01, 0x00, 0x00, - 0x21, 0x01, 0x00, 0x30, 0x11, 0xb7, 0xad, 0xea, - 0x13, 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, - 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, 0x00, - 0x00, 0x00, 0x28, 0xdf, 0x11, 0x04, 0x05, 0x01, - 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x0e, 0xb4, - 0xc9, 0xb4, 0xca, 0x0c, 0x07, 0xcb, 0x60, 0x03, - 0x00, 0xb4, 0xcc, 0x61, 0x03, 0x00, 0x64, 0x03, - 0x00, 0xa5, 0x68, 0xdd, 0x01, 0x00, 0x00, 0x60, - 0x06, 0x00, 0x60, 0x05, 0x00, 0x60, 0x04, 0x00, - 0x64, 0x04, 0x00, 0x61, 0x03, 0x00, 0x46, 0xc2, - 0x04, 0x64, 0x05, 0x00, 0x61, 0x03, 0x00, 0x46, - 0xc2, 0x05, 0x61, 0x05, 0x00, 0x95, 0xea, 0x34, - 0x64, 0x06, 0x00, 0x04, 0x06, 0x01, 0x00, 0x00, - 0xae, 0xea, 0x0c, 0xdf, 0x11, 0x04, 0x05, 0x01, - 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x61, 0x02, - 0x00, 0x61, 0x04, 0x00, 0x1b, 0x11, 0xaf, 0xeb, - 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x64, 0x07, 0x00, - 0x61, 0x03, 0x00, 0x46, 0x1b, 0x70, 0x1b, 0x48, - 0xed, 0x7c, 0x01, 0x06, 0xc2, 0x06, 0x6b, 0x1a, - 0x00, 0x00, 0x00, 0x5d, 0x08, 0x00, 0x61, 0x05, - 0x00, 0x64, 0x09, 0x00, 0x61, 0x03, 0x00, 0x46, - 0xf0, 0x11, 0x62, 0x06, 0x00, 0x0e, 0x0e, 0xec, - 0x35, 0xc2, 0x07, 0x6b, 0x30, 0x00, 0x00, 0x00, - 0xb4, 0x11, 0x65, 0x0a, 0x00, 0x0e, 0x64, 0x05, - 0x00, 0x61, 0x03, 0x00, 0x1b, 0x11, 0xaf, 0xeb, - 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x38, 0x46, 0x00, - 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x5d, 0x0b, - 0x00, 0x64, 0x05, 0x00, 0x64, 0x03, 0x00, 0xf0, - 0x0e, 0xc1, 0x07, 0x30, 0x30, 0x61, 0x06, 0x00, - 0x40, 0x6a, 0x00, 0x00, 0x00, 0x95, 0xea, 0x4f, - 0x64, 0x06, 0x00, 0x04, 0x07, 0x01, 0x00, 0x00, - 0xad, 0xea, 0x1e, 0x61, 0x00, 0x00, 0xb4, 0xa7, - 0xea, 0x17, 0x5d, 0x0b, 0x00, 0x64, 0x05, 0x00, - 0x64, 0x03, 0x00, 0xf0, 0x0e, 0xde, 0x11, 0x04, - 0x08, 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, - 0x61, 0x02, 0x00, 0x61, 0x04, 0x00, 0x1b, 0x11, - 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x61, - 0x06, 0x00, 0x40, 0x41, 0x00, 0x00, 0x00, 0x1b, - 0x70, 0x1b, 0x48, 0x61, 0x01, 0x00, 0x90, 0x62, - 0x01, 0x00, 0x0e, 0xed, 0xd1, 0x00, 0x64, 0x0a, - 0x00, 0x8f, 0x65, 0x0a, 0x00, 0x0e, 0x61, 0x00, - 0x00, 0x90, 0x62, 0x00, 0x00, 0x0e, 0x64, 0x05, - 0x00, 0x61, 0x03, 0x00, 0x1b, 0x11, 0xaf, 0xeb, - 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x38, 0x46, 0x00, - 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x64, 0x06, - 0x00, 0x60, 0x08, 0x00, 0x11, 0x04, 0x09, 0x01, - 0x00, 0x00, 0xad, 0xea, 0x2e, 0x5d, 0x0b, 0x00, - 0x64, 0x05, 0x00, 0x64, 0x03, 0x00, 0xf0, 0xc2, - 0x08, 0x61, 0x08, 0x00, 0xea, 0x05, 0x61, 0x08, - 0x00, 0x30, 0xb7, 0x11, 0x65, 0x00, 0x00, 0x0e, - 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, 0x41, - 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, 0x00, 0x00, - 0x00, 0x28, 0x11, 0x04, 0x06, 0x01, 0x00, 0x00, - 0xad, 0xea, 0x3c, 0x64, 0x0a, 0x00, 0xb5, 0xa5, - 0xea, 0x19, 0xb7, 0x11, 0x65, 0x00, 0x00, 0x0e, - 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, 0x41, - 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, 0x00, 0x00, - 0x00, 0x28, 0x61, 0x02, 0x00, 0x61, 0x04, 0x00, - 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, - 0x1b, 0x64, 0x07, 0x00, 0x61, 0x03, 0x00, 0x46, - 0x1b, 0x70, 0x1b, 0x48, 0xec, 0x27, 0x11, 0x04, - 0x07, 0x01, 0x00, 0x00, 0xad, 0xea, 0x1e, 0x61, - 0x01, 0x00, 0xb4, 0xa7, 0xea, 0x17, 0x5d, 0x0b, - 0x00, 0x64, 0x05, 0x00, 0x64, 0x03, 0x00, 0xf0, - 0x0e, 0xde, 0x11, 0x04, 0x08, 0x01, 0x00, 0x00, - 0x21, 0x01, 0x00, 0x30, 0x0e, 0x61, 0x03, 0x00, - 0x90, 0x62, 0x03, 0x00, 0x0e, 0xed, 0x1d, 0xfe, - 0x61, 0x01, 0x00, 0xb4, 0xad, 0xea, 0x19, 0xb7, - 0x11, 0x65, 0x00, 0x00, 0x0e, 0x0b, 0x38, 0x46, - 0x00, 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, - 0x0a, 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, 0xb5, - 0x11, 0x65, 0x00, 0x00, 0x0e, 0x0b, 0x61, 0x02, - 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x09, 0x4b, - 0x6a, 0x00, 0x00, 0x00, 0x28, 0x0c, 0x42, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x06, - 0x00, 0x88, 0x01, 0x01, 0xe8, 0x03, 0x01, 0x00, - 0x20, 0xfe, 0x03, 0x13, 0x10, 0xa4, 0x03, 0x00, - 0x02, 0xa8, 0x03, 0x01, 0x02, 0xd8, 0x03, 0x03, - 0x02, 0xe4, 0x03, 0x06, 0x10, 0xe6, 0x03, 0x05, - 0x10, 0x60, 0x00, 0x00, 0x64, 0x00, 0x00, 0x11, - 0xb4, 0xad, 0xea, 0x09, 0xb7, 0x11, 0x65, 0x00, - 0x00, 0x0e, 0xec, 0x4b, 0x11, 0xb5, 0xad, 0xea, - 0x09, 0xb6, 0x11, 0x65, 0x00, 0x00, 0x0e, 0xec, - 0x3e, 0x11, 0xb6, 0xad, 0xea, 0x0c, 0xde, 0x11, - 0x04, 0x04, 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, - 0x30, 0x11, 0xb7, 0xad, 0xea, 0x13, 0x0b, 0x38, - 0x46, 0x00, 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, - 0x00, 0x0a, 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, - 0xdf, 0x11, 0x04, 0x0a, 0x01, 0x00, 0x00, 0x41, - 0x5d, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x24, - 0x01, 0x00, 0x21, 0x01, 0x00, 0x30, 0x0e, 0xe0, - 0x64, 0x04, 0x00, 0x64, 0x05, 0x00, 0xf0, 0xc9, - 0x61, 0x00, 0x00, 0xea, 0x05, 0x61, 0x00, 0x00, - 0x30, 0xb7, 0x11, 0x65, 0x00, 0x00, 0x0e, 0x0b, - 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, 0x41, 0x00, - 0x00, 0x00, 0x0a, 0x4b, 0x6a, 0x00, 0x00, 0x00, - 0x28, 0x60, 0x01, 0x00, 0x60, 0x00, 0x00, 0xd1, - 0xc9, 0xd2, 0x11, 0xf2, 0xea, 0x08, 0x0e, 0x38, - 0x46, 0x00, 0x00, 0x00, 0xda, 0xca, 0x60, 0x14, - 0x00, 0x60, 0x13, 0x00, 0x60, 0x08, 0x00, 0x60, - 0x07, 0x00, 0x60, 0x06, 0x00, 0x60, 0x05, 0x00, - 0x60, 0x04, 0x00, 0x60, 0x03, 0x00, 0x60, 0x02, - 0x00, 0x5d, 0x04, 0x00, 0xd1, 0x04, 0x0b, 0x01, - 0x00, 0x00, 0xf0, 0x0e, 0xd2, 0x38, 0x46, 0x00, - 0x00, 0x00, 0xad, 0xea, 0x06, 0x0c, 0x07, 0xd6, - 0xec, 0x0c, 0x5d, 0x04, 0x00, 0xd2, 0x04, 0x0c, - 0x01, 0x00, 0x00, 0xf0, 0x0e, 0xd2, 0x40, 0xf8, - 0x00, 0x00, 0x00, 0xcb, 0x61, 0x02, 0x00, 0x38, - 0x46, 0x00, 0x00, 0x00, 0xad, 0xea, 0x0b, 0x04, - 0x09, 0x01, 0x00, 0x00, 0x11, 0x62, 0x02, 0x00, - 0x0e, 0x61, 0x02, 0x00, 0x04, 0x07, 0x01, 0x00, - 0x00, 0xad, 0x11, 0xeb, 0x18, 0x0e, 0x61, 0x02, - 0x00, 0x04, 0x06, 0x01, 0x00, 0x00, 0xad, 0x11, - 0xeb, 0x0b, 0x0e, 0x61, 0x02, 0x00, 0x04, 0x09, - 0x01, 0x00, 0x00, 0xad, 0x95, 0xea, 0x0c, 0xdd, - 0x11, 0x04, 0x0d, 0x01, 0x00, 0x00, 0x21, 0x01, - 0x00, 0x30, 0x38, 0x46, 0x00, 0x00, 0x00, 0xcc, - 0x61, 0x02, 0x00, 0x04, 0x06, 0x01, 0x00, 0x00, - 0xad, 0xea, 0x24, 0xd2, 0x40, 0xf9, 0x00, 0x00, - 0x00, 0x11, 0x62, 0x03, 0x00, 0x0e, 0x61, 0x03, - 0x00, 0x38, 0x46, 0x00, 0x00, 0x00, 0xae, 0xea, - 0x0e, 0x5d, 0x04, 0x00, 0x61, 0x03, 0x00, 0x04, - 0x0e, 0x01, 0x00, 0x00, 0xf0, 0x0e, 0x26, 0x00, - 0x00, 0xc2, 0x04, 0xb4, 0xc2, 0x05, 0x26, 0x00, - 0x00, 0xc2, 0x06, 0x26, 0x00, 0x00, 0xc2, 0x07, - 0x26, 0x00, 0x00, 0xc2, 0x08, 0x60, 0x09, 0x00, - 0x5d, 0x05, 0x00, 0xd1, 0xef, 0x7d, 0xec, 0x1d, - 0xc2, 0x09, 0x61, 0x04, 0x00, 0x61, 0x05, 0x00, - 0x90, 0x62, 0x05, 0x00, 0x1b, 0x11, 0xaf, 0xeb, - 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x61, 0x09, 0x00, - 0x1b, 0x70, 0x1b, 0x48, 0x80, 0x00, 0xea, 0xe1, - 0x0e, 0x83, 0x6b, 0x7d, 0x01, 0x00, 0x00, 0x60, - 0x0a, 0x00, 0xb4, 0xc2, 0x0a, 0x61, 0x0a, 0x00, - 0x61, 0x05, 0x00, 0xa5, 0x68, 0xf0, 0x00, 0x00, - 0x00, 0x60, 0x0c, 0x00, 0x60, 0x0b, 0x00, 0x0a, - 0xc2, 0x0b, 0x61, 0x04, 0x00, 0x61, 0x0a, 0x00, - 0x46, 0xc2, 0x0c, 0x5d, 0x06, 0x00, 0xd1, 0x61, - 0x0c, 0x00, 0xf0, 0xea, 0x78, 0x60, 0x0d, 0x00, - 0xd1, 0x61, 0x0c, 0x00, 0x46, 0xc2, 0x0d, 0x61, - 0x0d, 0x00, 0x38, 0x46, 0x00, 0x00, 0x00, 0xae, - 0xea, 0x63, 0x60, 0x0e, 0x00, 0x5d, 0x04, 0x00, - 0x61, 0x0d, 0x00, 0x04, 0x0f, 0x01, 0x00, 0x00, - 0xf0, 0x0e, 0x61, 0x0d, 0x00, 0x5d, 0x07, 0x00, - 0x46, 0xc2, 0x0e, 0x61, 0x0e, 0x00, 0xea, 0x0e, - 0xdf, 0x61, 0x0d, 0x00, 0x61, 0x0e, 0x00, 0xf0, - 0x11, 0x62, 0x0d, 0x00, 0x0e, 0x61, 0x06, 0x00, - 0x61, 0x0a, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, - 0x1b, 0x70, 0x1b, 0x1b, 0x61, 0x0d, 0x00, 0x1b, - 0x70, 0x1b, 0x48, 0x61, 0x07, 0x00, 0x61, 0x0a, - 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, - 0x1b, 0x1b, 0x61, 0x0d, 0x00, 0x40, 0x6b, 0x00, - 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x09, 0x11, - 0x62, 0x0b, 0x00, 0x0e, 0x61, 0x0b, 0x00, 0xea, - 0x4a, 0x60, 0x0f, 0x00, 0x61, 0x0a, 0x00, 0xb5, - 0x9c, 0xc2, 0x0f, 0x61, 0x0f, 0x00, 0x61, 0x05, - 0x00, 0xa5, 0xea, 0x27, 0x61, 0x04, 0x00, 0x61, - 0x0f, 0x00, 0xb5, 0x9d, 0x1b, 0x11, 0xaf, 0xeb, - 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x61, 0x04, 0x00, - 0x61, 0x0f, 0x00, 0x46, 0x1b, 0x70, 0x1b, 0x48, - 0x61, 0x0f, 0x00, 0x90, 0x62, 0x0f, 0x00, 0x0e, - 0xec, 0xd2, 0x61, 0x05, 0x00, 0x8f, 0x62, 0x05, - 0x00, 0x0e, 0x61, 0x0a, 0x00, 0x8f, 0x62, 0x0a, - 0x00, 0x0e, 0x61, 0x0a, 0x00, 0x90, 0x62, 0x0a, - 0x00, 0x0e, 0xed, 0x0a, 0xff, 0x61, 0x02, 0x00, - 0x04, 0x06, 0x01, 0x00, 0x00, 0xad, 0xea, 0x6e, - 0x61, 0x03, 0x00, 0xea, 0x38, 0x60, 0x10, 0x00, - 0xb4, 0xc2, 0x10, 0x61, 0x10, 0x00, 0x61, 0x05, - 0x00, 0xa5, 0xea, 0x5a, 0x61, 0x08, 0x00, 0x61, - 0x10, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, - 0x70, 0x1b, 0x1b, 0x61, 0x03, 0x00, 0x61, 0x04, - 0x00, 0x61, 0x10, 0x00, 0x46, 0x46, 0x1b, 0x70, - 0x1b, 0x48, 0x61, 0x10, 0x00, 0x90, 0x62, 0x10, - 0x00, 0x0e, 0xec, 0xd0, 0x60, 0x11, 0x00, 0xb4, - 0xc2, 0x11, 0x61, 0x11, 0x00, 0x61, 0x05, 0x00, - 0xa5, 0xea, 0x23, 0x61, 0x08, 0x00, 0x61, 0x11, - 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, - 0x1b, 0x1b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x1b, - 0x70, 0x1b, 0x48, 0x61, 0x11, 0x00, 0x90, 0x62, - 0x11, 0x00, 0x0e, 0xec, 0xd6, 0x0e, 0xec, 0x15, - 0xc2, 0x12, 0x6b, 0x10, 0x00, 0x00, 0x00, 0xe0, - 0x61, 0x06, 0x00, 0x61, 0x05, 0x00, 0xf0, 0x0e, - 0xc1, 0x12, 0x30, 0x30, 0xb4, 0xc2, 0x13, 0x61, - 0x05, 0x00, 0xc2, 0x14, 0x0b, 0x5d, 0x08, 0x00, - 0x4e, 0xbf, 0x00, 0x53, 0x6b, 0x00, 0x00, 0x00, - 0x04, 0xbf, 0x01, 0x53, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x28, 0xbf, 0x00, 0xc9, 0xbf, 0x01, 0xca, - 0xbf, 0x02, 0xcb, 0xbf, 0x03, 0x28, 0xbf, 0x00, - 0xcd, 0x28, -}; - - -/* File generated automatically by the QuickJS-ng compiler. */ - -#include - -const uint32_t qjsc_builtin_iterator_zip_size = 2617; - -const uint8_t qjsc_builtin_iterator_zip[2617] = { - 0x17, 0x2a, 0x01, 0x1c, 0x49, 0x74, 0x65, 0x72, - 0x61, 0x74, 0x6f, 0x72, 0x48, 0x65, 0x6c, 0x70, - 0x65, 0x72, 0x01, 0x08, 0x63, 0x61, 0x6c, 0x6c, - 0x01, 0x1e, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, - 0xb7, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, - 0x72, 0x01, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, - 0x01, 0x0a, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x01, - 0x10, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x61, 0x6c, - 0x6c, 0x01, 0x02, 0x76, 0x01, 0x02, 0x73, 0x01, - 0x08, 0x69, 0x74, 0x65, 0x72, 0x01, 0x0c, 0x6d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x01, 0x02, 0x65, - 0x01, 0x0a, 0x69, 0x74, 0x65, 0x72, 0x73, 0x01, - 0x0a, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x01, 0x04, - 0x65, 0x78, 0x01, 0x02, 0x69, 0x01, 0x12, 0x69, - 0x74, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x73, - 0x01, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x01, 0x08, 0x6d, 0x6f, 0x64, 0x65, 0x01, - 0x0e, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, - 0x01, 0x08, 0x70, 0x61, 0x64, 0x73, 0x01, 0x0a, - 0x6e, 0x65, 0x78, 0x74, 0x73, 0x01, 0x16, 0x70, - 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x69, 0x74, - 0x65, 0x72, 0x01, 0x1a, 0x69, 0x74, 0x65, 0x72, - 0x61, 0x62, 0x6c, 0x65, 0x73, 0x69, 0x74, 0x65, - 0x72, 0x01, 0x08, 0x69, 0x74, 0x65, 0x6d, 0x01, - 0x02, 0x74, 0x01, 0x0a, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x01, 0x0a, 0x61, 0x6c, 0x69, 0x76, 0x65, - 0x01, 0x0a, 0x64, 0x6f, 0x6e, 0x65, 0x73, 0x01, - 0x0e, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, - 0x01, 0x0c, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x01, 0x1c, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, - 0x67, 0x20, 0x7a, 0x69, 0x70, 0x70, 0x65, 0x72, - 0x01, 0x06, 0x62, 0x75, 0x67, 0x01, 0x0e, 0x6c, - 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x01, 0x0c, - 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x01, 0x22, - 0x6d, 0x69, 0x73, 0x6d, 0x61, 0x74, 0x63, 0x68, - 0x65, 0x64, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, - 0x73, 0x01, 0x10, 0x73, 0x68, 0x6f, 0x72, 0x74, - 0x65, 0x73, 0x74, 0x01, 0x16, 0x62, 0x75, 0x67, - 0x3a, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3d, - 0x01, 0x1a, 0x62, 0x61, 0x64, 0x20, 0x69, 0x74, - 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x01, - 0x16, 0x62, 0x61, 0x64, 0x20, 0x6f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x01, 0x10, 0x62, 0x61, - 0x64, 0x20, 0x6d, 0x6f, 0x64, 0x65, 0x01, 0x16, - 0x62, 0x61, 0x64, 0x20, 0x70, 0x61, 0x64, 0x64, - 0x69, 0x6e, 0x67, 0x01, 0x18, 0x62, 0x61, 0x64, - 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, - 0x72, 0x0c, 0x00, 0x02, 0x00, 0xa2, 0x01, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x04, 0x01, - 0xa4, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x43, 0x02, - 0x00, 0x00, 0x05, 0x03, 0x05, 0x01, 0x08, 0x00, - 0x04, 0x0c, 0x08, 0xca, 0x03, 0x00, 0x01, 0x40, - 0x07, 0xa8, 0x03, 0x00, 0x01, 0x40, 0x03, 0xa4, - 0x03, 0x00, 0x01, 0x40, 0x00, 0xcc, 0x03, 0x00, - 0x01, 0x40, 0x01, 0xce, 0x03, 0x00, 0x01, 0x40, - 0x06, 0xd0, 0x03, 0x00, 0x00, 0x40, 0x05, 0xd2, - 0x03, 0x00, 0x01, 0x40, 0x02, 0xd4, 0x03, 0x00, - 0x02, 0x40, 0x04, 0x0c, 0x43, 0x02, 0x00, 0xd0, + 0x48, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x01, 0x08, + 0x63, 0x61, 0x6c, 0x6c, 0x01, 0x24, 0x68, 0x61, + 0x73, 0x4f, 0x77, 0x6e, 0x45, 0x6e, 0x75, 0x6d, + 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, + 0x01, 0x24, 0x67, 0x65, 0x74, 0x4f, 0x77, 0x6e, + 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, + 0x4b, 0x65, 0x79, 0x73, 0x01, 0x1e, 0x53, 0x79, + 0x6d, 0x62, 0x6f, 0x6c, 0xb7, 0x69, 0x74, 0x65, + 0x72, 0x61, 0x74, 0x6f, 0x72, 0x01, 0x0a, 0x63, + 0x68, 0x65, 0x63, 0x6b, 0x01, 0x0a, 0x63, 0x6c, + 0x6f, 0x73, 0x65, 0x01, 0x10, 0x63, 0x6c, 0x6f, + 0x73, 0x65, 0x61, 0x6c, 0x6c, 0x01, 0x02, 0x76, + 0x01, 0x02, 0x73, 0x01, 0x08, 0x69, 0x74, 0x65, + 0x72, 0x01, 0x0c, 0x6d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x01, 0x02, 0x65, 0x01, 0x0a, 0x69, 0x74, + 0x65, 0x72, 0x73, 0x01, 0x0a, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x01, 0x04, 0x65, 0x78, 0x01, 0x02, + 0x69, 0x01, 0x12, 0x69, 0x74, 0x65, 0x72, 0x61, + 0x62, 0x6c, 0x65, 0x73, 0x01, 0x0e, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x01, 0x08, 0x6d, + 0x6f, 0x64, 0x65, 0x01, 0x0e, 0x70, 0x61, 0x64, + 0x64, 0x69, 0x6e, 0x67, 0x01, 0x0a, 0x6e, 0x65, + 0x78, 0x74, 0x73, 0x01, 0x08, 0x70, 0x61, 0x64, + 0x73, 0x01, 0x06, 0x6b, 0x65, 0x79, 0x01, 0x06, + 0x64, 0x65, 0x6c, 0x01, 0x02, 0x6a, 0x01, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x01, 0x0a, 0x61, + 0x6c, 0x69, 0x76, 0x65, 0x01, 0x0a, 0x64, 0x6f, + 0x6e, 0x65, 0x73, 0x01, 0x0e, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x73, 0x01, 0x0c, 0x72, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x01, 0x1c, 0x72, 0x75, + 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x7a, 0x69, + 0x70, 0x70, 0x65, 0x72, 0x01, 0x06, 0x62, 0x75, + 0x67, 0x01, 0x0e, 0x6c, 0x6f, 0x6e, 0x67, 0x65, + 0x73, 0x74, 0x01, 0x0c, 0x73, 0x74, 0x72, 0x69, + 0x63, 0x74, 0x01, 0x22, 0x6d, 0x69, 0x73, 0x6d, + 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x20, 0x69, + 0x6e, 0x70, 0x75, 0x74, 0x73, 0x01, 0x10, 0x73, + 0x68, 0x6f, 0x72, 0x74, 0x65, 0x73, 0x74, 0x01, + 0x16, 0x62, 0x75, 0x67, 0x3a, 0x20, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x3d, 0x01, 0x1a, 0x62, 0x61, + 0x64, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x62, + 0x6c, 0x65, 0x73, 0x01, 0x16, 0x62, 0x61, 0x64, + 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x01, 0x10, 0x62, 0x61, 0x64, 0x20, 0x6d, 0x6f, + 0x64, 0x65, 0x01, 0x16, 0x62, 0x61, 0x64, 0x20, + 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x01, + 0x18, 0x62, 0x61, 0x64, 0x20, 0x69, 0x74, 0x65, + 0x72, 0x61, 0x74, 0x6f, 0x72, 0x0c, 0x00, 0x02, + 0x00, 0xa2, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x04, 0x01, 0xa4, 0x01, 0x00, 0x00, + 0x00, 0x0c, 0x43, 0x02, 0x00, 0x00, 0x07, 0x03, + 0x07, 0x01, 0x0a, 0x00, 0x04, 0x0c, 0x0a, 0xca, + 0x03, 0x00, 0x01, 0x40, 0x09, 0xa8, 0x03, 0x00, + 0x01, 0x40, 0x03, 0xa4, 0x03, 0x00, 0x01, 0x40, + 0x00, 0xcc, 0x03, 0x00, 0x01, 0x40, 0x01, 0xce, + 0x03, 0x00, 0x01, 0x40, 0x07, 0xd0, 0x03, 0x00, + 0x01, 0x40, 0x06, 0xd2, 0x03, 0x00, 0x01, 0x40, + 0x08, 0xd4, 0x03, 0x00, 0x00, 0x40, 0x05, 0xd6, + 0x03, 0x00, 0x01, 0x40, 0x02, 0xd8, 0x03, 0x00, + 0x02, 0x40, 0x04, 0x0c, 0x43, 0x02, 0x00, 0xd4, 0x03, 0x02, 0x00, 0x02, 0x03, 0x00, 0x01, 0x00, - 0x17, 0x02, 0xd6, 0x03, 0x00, 0x01, 0x00, 0xd8, + 0x17, 0x02, 0xda, 0x03, 0x00, 0x01, 0x00, 0xdc, 0x03, 0x00, 0x01, 0x00, 0xa4, 0x03, 0x02, 0x01, 0xd1, 0x96, 0x04, 0x4a, 0x00, 0x00, 0x00, 0xad, 0xea, 0x07, 0xd1, 0x07, 0xae, 0xea, 0x02, 0x29, 0xdd, 0x11, 0xd2, 0x21, 0x01, 0x00, 0x30, 0x0c, - 0x43, 0x02, 0x00, 0xd2, 0x03, 0x01, 0x02, 0x01, - 0x04, 0x00, 0x01, 0x00, 0x2e, 0x03, 0xda, 0x03, - 0x00, 0x01, 0x00, 0xdc, 0x03, 0x02, 0x00, 0x20, - 0xde, 0x03, 0x05, 0x00, 0x03, 0xcc, 0x03, 0x03, + 0x43, 0x02, 0x00, 0xd6, 0x03, 0x01, 0x02, 0x01, + 0x04, 0x00, 0x01, 0x00, 0x2e, 0x03, 0xde, 0x03, + 0x00, 0x01, 0x00, 0xe0, 0x03, 0x02, 0x00, 0x20, + 0xe2, 0x03, 0x05, 0x00, 0x03, 0xcc, 0x03, 0x03, 0x01, 0x6b, 0x23, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xd1, 0x95, 0xea, 0x04, 0x06, 0x6e, 0x28, 0xd1, 0x40, 0x06, 0x00, 0x00, 0x00, 0xc9, 0x61, 0x00, 0x00, 0xea, 0x08, 0xdd, 0xd1, 0x61, 0x00, 0x00, 0xf0, 0x0e, 0x0e, 0x29, 0xca, 0x6b, 0x07, 0x00, 0x00, 0x00, 0xc6, 0x6e, 0x28, 0x30, 0x0c, - 0x43, 0x02, 0x00, 0xd4, 0x03, 0x02, 0x04, 0x02, - 0x03, 0x00, 0x01, 0x00, 0x55, 0x06, 0xe0, 0x03, - 0x00, 0x01, 0x00, 0xe2, 0x03, 0x00, 0x01, 0x00, - 0xe4, 0x03, 0x01, 0x00, 0x20, 0xe6, 0x03, 0x02, - 0x01, 0x20, 0xda, 0x03, 0x03, 0x02, 0x20, 0xde, - 0x03, 0x03, 0x03, 0x20, 0xd2, 0x03, 0x01, 0x00, + 0x43, 0x02, 0x00, 0xd8, 0x03, 0x02, 0x04, 0x02, + 0x03, 0x00, 0x01, 0x00, 0x55, 0x06, 0xe4, 0x03, + 0x00, 0x01, 0x00, 0xe6, 0x03, 0x00, 0x01, 0x00, + 0xe8, 0x03, 0x01, 0x00, 0x20, 0xea, 0x03, 0x02, + 0x01, 0x20, 0xde, 0x03, 0x03, 0x02, 0x20, 0xe2, + 0x03, 0x03, 0x03, 0x20, 0xd6, 0x03, 0x01, 0x00, 0x60, 0x00, 0x00, 0x38, 0x46, 0x00, 0x00, 0x00, 0xc9, 0x60, 0x01, 0x00, 0xd2, 0xca, 0x61, 0x01, 0x00, 0x8f, 0x62, 0x01, 0x00, 0xb4, 0xa7, 0xea, @@ -19140,243 +18928,572 @@ const uint8_t qjsc_builtin_iterator_zip[2617] = { 0xcc, 0x61, 0x00, 0x00, 0x95, 0xea, 0xc8, 0x61, 0x03, 0x00, 0x11, 0x62, 0x00, 0x00, 0x0e, 0xec, 0xbe, 0x61, 0x00, 0x00, 0x28, 0x0c, 0x41, 0x02, - 0x00, 0xa8, 0x02, 0x02, 0x1a, 0x01, 0x05, 0x07, - 0x08, 0x02, 0x8a, 0x06, 0x1c, 0xe8, 0x03, 0x00, - 0x01, 0x00, 0xea, 0x03, 0x00, 0x01, 0x00, 0xe8, + 0x00, 0xaa, 0x02, 0x02, 0x15, 0x01, 0x06, 0x08, + 0x09, 0x02, 0xc9, 0x05, 0x17, 0xec, 0x03, 0x00, + 0x01, 0x00, 0xee, 0x03, 0x00, 0x01, 0x00, 0xec, 0x03, 0x01, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x20, - 0xea, 0x03, 0x01, 0x01, 0x20, 0xec, 0x03, 0x02, - 0x00, 0x60, 0x03, 0xee, 0x03, 0x02, 0x03, 0x20, - 0xf0, 0x03, 0x02, 0x04, 0x60, 0x04, 0xe0, 0x03, - 0x02, 0x05, 0x60, 0x02, 0xf2, 0x03, 0x02, 0x06, - 0x60, 0x05, 0xe2, 0x03, 0x02, 0x07, 0x60, 0x01, - 0xf4, 0x03, 0x02, 0x08, 0x20, 0xf6, 0x03, 0x02, - 0x09, 0x20, 0xd6, 0x01, 0x09, 0x1a, 0x20, 0xf8, - 0x03, 0x0b, 0x0b, 0x20, 0xde, 0x03, 0x0d, 0x0f, - 0x03, 0xda, 0x03, 0x0b, 0x0c, 0x20, 0xdc, 0x03, - 0x0b, 0x0e, 0x20, 0xd6, 0x01, 0x13, 0x0b, 0x20, - 0xe6, 0x03, 0x13, 0x10, 0x20, 0xd4, 0x01, 0x13, - 0x11, 0x20, 0x82, 0x01, 0x15, 0x16, 0x20, 0xf8, - 0x03, 0x16, 0x13, 0x20, 0xde, 0x03, 0x17, 0x13, - 0x03, 0xfa, 0x03, 0x13, 0x12, 0x20, 0xe4, 0x03, - 0x1c, 0x16, 0x20, 0xde, 0x03, 0x1f, 0x1a, 0x03, - 0xfc, 0x03, 0x02, 0x0a, 0x60, 0x00, 0xfe, 0x03, - 0x02, 0x19, 0x60, 0x06, 0xa4, 0x03, 0x02, 0x01, - 0xa8, 0x03, 0x01, 0x01, 0xcc, 0x03, 0x03, 0x01, - 0xd4, 0x03, 0x02, 0x00, 0xd0, 0x03, 0x00, 0x00, - 0xce, 0x03, 0x04, 0x01, 0xd2, 0x03, 0x01, 0x00, - 0xca, 0x03, 0x00, 0x01, 0x0c, 0x42, 0x03, 0x00, - 0x00, 0x00, 0x08, 0x00, 0x05, 0x00, 0x0b, 0x00, - 0xec, 0x04, 0x08, 0x80, 0x04, 0x01, 0x00, 0x20, - 0xd8, 0x01, 0x01, 0x01, 0x20, 0x82, 0x04, 0x01, - 0x02, 0x20, 0xe6, 0x03, 0x03, 0x03, 0x20, 0xda, - 0x03, 0x04, 0x04, 0x20, 0x84, 0x04, 0x04, 0x05, - 0x20, 0xde, 0x03, 0x09, 0x06, 0x03, 0xe4, 0x03, - 0x10, 0x06, 0x20, 0xfc, 0x03, 0x18, 0x10, 0xa4, - 0x03, 0x00, 0x02, 0xa8, 0x03, 0x01, 0x02, 0xe2, - 0x03, 0x07, 0x10, 0xe0, 0x03, 0x05, 0x10, 0xec, - 0x03, 0x02, 0x10, 0xf0, 0x03, 0x04, 0x10, 0xcc, - 0x03, 0x02, 0x02, 0xf2, 0x03, 0x06, 0x10, 0xfe, - 0x03, 0x19, 0x10, 0xd4, 0x03, 0x03, 0x02, 0x60, - 0x02, 0x00, 0x60, 0x01, 0x00, 0x60, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x11, 0xb4, 0xad, 0xeb, 0x06, + 0xee, 0x03, 0x01, 0x01, 0x20, 0xf0, 0x03, 0x02, + 0x00, 0x60, 0x04, 0xf2, 0x03, 0x02, 0x03, 0x20, + 0x60, 0x02, 0x04, 0x60, 0x02, 0xe6, 0x03, 0x02, + 0x05, 0x60, 0x01, 0xe4, 0x03, 0x02, 0x06, 0x60, + 0x03, 0xf4, 0x03, 0x02, 0x07, 0x60, 0x06, 0xf6, + 0x03, 0x02, 0x08, 0x60, 0x05, 0xf8, 0x03, 0x09, + 0x15, 0x20, 0xea, 0x03, 0x0b, 0x15, 0x20, 0xfa, + 0x03, 0x0c, 0x0b, 0x20, 0xf8, 0x03, 0x0c, 0x0c, + 0x20, 0xde, 0x03, 0x0e, 0x0d, 0x20, 0xe0, 0x03, + 0x10, 0x0e, 0x20, 0xfc, 0x03, 0x14, 0x0d, 0x20, + 0xea, 0x03, 0x19, 0x15, 0x20, 0xea, 0x03, 0x1b, + 0x15, 0x20, 0xe2, 0x03, 0x1c, 0x15, 0x03, 0xfe, + 0x03, 0x02, 0x09, 0x60, 0x00, 0x80, 0x04, 0x02, + 0x14, 0x60, 0x07, 0xa4, 0x03, 0x02, 0x01, 0xa8, + 0x03, 0x01, 0x01, 0xcc, 0x03, 0x03, 0x01, 0xd8, + 0x03, 0x02, 0x00, 0xd4, 0x03, 0x00, 0x00, 0xd0, + 0x03, 0x05, 0x01, 0xce, 0x03, 0x04, 0x01, 0xd2, + 0x03, 0x06, 0x01, 0xca, 0x03, 0x00, 0x01, 0x0c, + 0x42, 0x03, 0x00, 0x00, 0x00, 0x09, 0x00, 0x05, + 0x00, 0x0c, 0x00, 0xf7, 0x04, 0x09, 0x82, 0x04, + 0x01, 0x00, 0x20, 0xd8, 0x01, 0x01, 0x01, 0x20, + 0x84, 0x04, 0x01, 0x02, 0x20, 0xea, 0x03, 0x03, + 0x03, 0x20, 0xf8, 0x03, 0x04, 0x04, 0x20, 0xde, + 0x03, 0x04, 0x05, 0x20, 0x86, 0x04, 0x04, 0x06, + 0x20, 0xe2, 0x03, 0x09, 0x07, 0x03, 0xe8, 0x03, + 0x10, 0x07, 0x20, 0xfe, 0x03, 0x13, 0x10, 0xa4, + 0x03, 0x00, 0x02, 0xa8, 0x03, 0x01, 0x02, 0xe6, + 0x03, 0x05, 0x10, 0x60, 0x04, 0x10, 0xe4, 0x03, + 0x06, 0x10, 0xf0, 0x03, 0x02, 0x10, 0xf6, 0x03, + 0x08, 0x10, 0xcc, 0x03, 0x02, 0x02, 0xf4, 0x03, + 0x07, 0x10, 0x80, 0x04, 0x14, 0x10, 0xd8, 0x03, + 0x03, 0x02, 0x60, 0x02, 0x00, 0x60, 0x01, 0x00, + 0x60, 0x00, 0x00, 0x64, 0x00, 0x00, 0x11, 0xb4, + 0xad, 0xeb, 0x06, 0x11, 0xb5, 0xad, 0xea, 0x09, + 0xb6, 0x11, 0x65, 0x00, 0x00, 0x0e, 0xec, 0x33, + 0x11, 0xb6, 0xad, 0xea, 0x0c, 0xde, 0x11, 0x04, + 0x04, 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, + 0x11, 0xb7, 0xad, 0xea, 0x13, 0x0b, 0x38, 0x46, + 0x00, 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, + 0x0a, 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, 0xdf, + 0x11, 0x04, 0x05, 0x01, 0x00, 0x00, 0x21, 0x01, + 0x00, 0x30, 0x0e, 0xb4, 0xc9, 0xb4, 0xca, 0x0c, + 0x07, 0xcb, 0x60, 0x03, 0x00, 0xb4, 0xcc, 0x61, + 0x03, 0x00, 0x64, 0x03, 0x00, 0xa5, 0x68, 0xdd, + 0x01, 0x00, 0x00, 0x60, 0x06, 0x00, 0x60, 0x05, + 0x00, 0x60, 0x04, 0x00, 0x64, 0x04, 0x00, 0x61, + 0x03, 0x00, 0x46, 0xc2, 0x04, 0x64, 0x05, 0x00, + 0x61, 0x03, 0x00, 0x46, 0xc2, 0x05, 0x61, 0x05, + 0x00, 0x95, 0xea, 0x34, 0x64, 0x06, 0x00, 0x04, + 0x06, 0x01, 0x00, 0x00, 0xae, 0xea, 0x0c, 0xdf, + 0x11, 0x04, 0x05, 0x01, 0x00, 0x00, 0x21, 0x01, + 0x00, 0x30, 0x61, 0x02, 0x00, 0x61, 0x04, 0x00, + 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, + 0x1b, 0x64, 0x07, 0x00, 0x61, 0x03, 0x00, 0x46, + 0x1b, 0x70, 0x1b, 0x48, 0xed, 0x7c, 0x01, 0x06, + 0xc2, 0x06, 0x6b, 0x1a, 0x00, 0x00, 0x00, 0x5d, + 0x08, 0x00, 0x61, 0x05, 0x00, 0x64, 0x09, 0x00, + 0x61, 0x03, 0x00, 0x46, 0xf0, 0x11, 0x62, 0x06, + 0x00, 0x0e, 0x0e, 0xec, 0x35, 0xc2, 0x07, 0x6b, + 0x30, 0x00, 0x00, 0x00, 0xb4, 0x11, 0x65, 0x0a, + 0x00, 0x0e, 0x64, 0x05, 0x00, 0x61, 0x03, 0x00, + 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, + 0x1b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x1b, 0x70, + 0x1b, 0x48, 0x5d, 0x0b, 0x00, 0x64, 0x05, 0x00, + 0x64, 0x03, 0x00, 0xf0, 0x0e, 0xc1, 0x07, 0x30, + 0x30, 0x61, 0x06, 0x00, 0x40, 0x6a, 0x00, 0x00, + 0x00, 0x95, 0xea, 0x4f, 0x64, 0x06, 0x00, 0x04, + 0x07, 0x01, 0x00, 0x00, 0xad, 0xea, 0x1e, 0x61, + 0x00, 0x00, 0xb4, 0xa7, 0xea, 0x17, 0x5d, 0x0b, + 0x00, 0x64, 0x05, 0x00, 0x64, 0x03, 0x00, 0xf0, + 0x0e, 0xde, 0x11, 0x04, 0x08, 0x01, 0x00, 0x00, + 0x21, 0x01, 0x00, 0x30, 0x61, 0x02, 0x00, 0x61, + 0x04, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, + 0x70, 0x1b, 0x1b, 0x61, 0x06, 0x00, 0x40, 0x41, + 0x00, 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x61, + 0x01, 0x00, 0x90, 0x62, 0x01, 0x00, 0x0e, 0xed, + 0xd1, 0x00, 0x64, 0x0a, 0x00, 0x8f, 0x65, 0x0a, + 0x00, 0x0e, 0x61, 0x00, 0x00, 0x90, 0x62, 0x00, + 0x00, 0x0e, 0x64, 0x05, 0x00, 0x61, 0x03, 0x00, + 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, + 0x1b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x1b, 0x70, + 0x1b, 0x48, 0x64, 0x06, 0x00, 0x60, 0x08, 0x00, + 0x11, 0x04, 0x09, 0x01, 0x00, 0x00, 0xad, 0xea, + 0x2e, 0x5d, 0x0b, 0x00, 0x64, 0x05, 0x00, 0x64, + 0x03, 0x00, 0xf0, 0xc2, 0x08, 0x61, 0x08, 0x00, + 0xea, 0x05, 0x61, 0x08, 0x00, 0x30, 0xb7, 0x11, + 0x65, 0x00, 0x00, 0x0e, 0x0b, 0x38, 0x46, 0x00, + 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, + 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, 0x11, 0x04, + 0x06, 0x01, 0x00, 0x00, 0xad, 0xea, 0x3c, 0x64, + 0x0a, 0x00, 0xb5, 0xa5, 0xea, 0x19, 0xb7, 0x11, + 0x65, 0x00, 0x00, 0x0e, 0x0b, 0x38, 0x46, 0x00, + 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, + 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, 0x61, 0x02, + 0x00, 0x61, 0x04, 0x00, 0x1b, 0x11, 0xaf, 0xeb, + 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x64, 0x07, 0x00, + 0x61, 0x03, 0x00, 0x46, 0x1b, 0x70, 0x1b, 0x48, + 0xec, 0x27, 0x11, 0x04, 0x07, 0x01, 0x00, 0x00, + 0xad, 0xea, 0x1e, 0x61, 0x01, 0x00, 0xb4, 0xa7, + 0xea, 0x17, 0x5d, 0x0b, 0x00, 0x64, 0x05, 0x00, + 0x64, 0x03, 0x00, 0xf0, 0x0e, 0xde, 0x11, 0x04, + 0x08, 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, + 0x0e, 0x61, 0x03, 0x00, 0x90, 0x62, 0x03, 0x00, + 0x0e, 0xed, 0x1d, 0xfe, 0x61, 0x01, 0x00, 0xb4, + 0xad, 0xea, 0x19, 0xb7, 0x11, 0x65, 0x00, 0x00, + 0x0e, 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, + 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, 0x00, + 0x00, 0x00, 0x28, 0xb5, 0x11, 0x65, 0x00, 0x00, + 0x0e, 0x0b, 0x61, 0x02, 0x00, 0x4b, 0x41, 0x00, + 0x00, 0x00, 0x09, 0x4b, 0x6a, 0x00, 0x00, 0x00, + 0x28, 0x0c, 0x42, 0x03, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x06, 0x00, 0x06, 0x00, 0x88, 0x01, 0x01, + 0xe8, 0x03, 0x01, 0x00, 0x20, 0xfe, 0x03, 0x13, + 0x10, 0xa4, 0x03, 0x00, 0x02, 0xa8, 0x03, 0x01, + 0x02, 0xd8, 0x03, 0x03, 0x02, 0xe4, 0x03, 0x06, + 0x10, 0xe6, 0x03, 0x05, 0x10, 0x60, 0x00, 0x00, + 0x64, 0x00, 0x00, 0x11, 0xb4, 0xad, 0xea, 0x09, + 0xb7, 0x11, 0x65, 0x00, 0x00, 0x0e, 0xec, 0x4b, 0x11, 0xb5, 0xad, 0xea, 0x09, 0xb6, 0x11, 0x65, - 0x00, 0x00, 0x0e, 0xec, 0x33, 0x11, 0xb6, 0xad, - 0xea, 0x0c, 0xde, 0x11, 0x04, 0x03, 0x01, 0x00, + 0x00, 0x00, 0x0e, 0xec, 0x3e, 0x11, 0xb6, 0xad, + 0xea, 0x0c, 0xde, 0x11, 0x04, 0x04, 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x11, 0xb7, 0xad, 0xea, 0x13, 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, - 0x00, 0x00, 0x00, 0x28, 0xdf, 0x11, 0x04, 0x04, - 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x0e, - 0xb4, 0xc9, 0xb4, 0xca, 0x26, 0x00, 0x00, 0xcb, - 0x60, 0x03, 0x00, 0xb4, 0xcc, 0x61, 0x03, 0x00, - 0x64, 0x03, 0x00, 0xa5, 0x68, 0xd1, 0x01, 0x00, - 0x00, 0x60, 0x05, 0x00, 0x60, 0x04, 0x00, 0x64, - 0x04, 0x00, 0x61, 0x03, 0x00, 0x46, 0xc2, 0x04, - 0x61, 0x04, 0x00, 0x95, 0xea, 0x34, 0x64, 0x05, - 0x00, 0x04, 0x05, 0x01, 0x00, 0x00, 0xae, 0xea, - 0x0c, 0xdf, 0x11, 0x04, 0x04, 0x01, 0x00, 0x00, - 0x21, 0x01, 0x00, 0x30, 0x61, 0x02, 0x00, 0x61, - 0x03, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, - 0x70, 0x1b, 0x1b, 0x64, 0x06, 0x00, 0x61, 0x03, - 0x00, 0x46, 0x1b, 0x70, 0x1b, 0x48, 0xed, 0x7c, - 0x01, 0x06, 0xc2, 0x05, 0x6b, 0x1a, 0x00, 0x00, - 0x00, 0x5d, 0x07, 0x00, 0x61, 0x04, 0x00, 0x64, - 0x08, 0x00, 0x61, 0x03, 0x00, 0x46, 0xf0, 0x11, - 0x62, 0x05, 0x00, 0x0e, 0x0e, 0xec, 0x35, 0xc2, - 0x06, 0x6b, 0x30, 0x00, 0x00, 0x00, 0xb4, 0x11, - 0x65, 0x09, 0x00, 0x0e, 0x64, 0x04, 0x00, 0x61, - 0x03, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, - 0x70, 0x1b, 0x1b, 0x38, 0x46, 0x00, 0x00, 0x00, - 0x1b, 0x70, 0x1b, 0x48, 0x5d, 0x0a, 0x00, 0x64, - 0x04, 0x00, 0x64, 0x03, 0x00, 0xf0, 0x0e, 0xc1, - 0x06, 0x30, 0x30, 0x61, 0x05, 0x00, 0x40, 0x6a, - 0x00, 0x00, 0x00, 0x95, 0xea, 0x4f, 0x64, 0x05, - 0x00, 0x04, 0x06, 0x01, 0x00, 0x00, 0xad, 0xea, - 0x1e, 0x61, 0x00, 0x00, 0xb4, 0xa7, 0xea, 0x17, - 0x5d, 0x0a, 0x00, 0x64, 0x04, 0x00, 0x64, 0x03, - 0x00, 0xf0, 0x0e, 0xde, 0x11, 0x04, 0x07, 0x01, - 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x61, 0x02, - 0x00, 0x61, 0x03, 0x00, 0x1b, 0x11, 0xaf, 0xeb, - 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x61, 0x05, 0x00, - 0x40, 0x41, 0x00, 0x00, 0x00, 0x1b, 0x70, 0x1b, - 0x48, 0x61, 0x01, 0x00, 0x90, 0x62, 0x01, 0x00, - 0x0e, 0xed, 0xd1, 0x00, 0x64, 0x09, 0x00, 0x8f, - 0x65, 0x09, 0x00, 0x0e, 0x61, 0x00, 0x00, 0x90, - 0x62, 0x00, 0x00, 0x0e, 0x64, 0x04, 0x00, 0x61, - 0x03, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, - 0x70, 0x1b, 0x1b, 0x38, 0x46, 0x00, 0x00, 0x00, - 0x1b, 0x70, 0x1b, 0x48, 0x64, 0x05, 0x00, 0x60, - 0x07, 0x00, 0x11, 0x04, 0x08, 0x01, 0x00, 0x00, - 0xad, 0xea, 0x2e, 0x5d, 0x0a, 0x00, 0x64, 0x04, - 0x00, 0x64, 0x03, 0x00, 0xf0, 0xc2, 0x07, 0x61, - 0x07, 0x00, 0xea, 0x05, 0x61, 0x07, 0x00, 0x30, - 0xb7, 0x11, 0x65, 0x00, 0x00, 0x0e, 0x0b, 0x38, - 0x46, 0x00, 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, - 0x00, 0x0a, 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, - 0x11, 0x04, 0x05, 0x01, 0x00, 0x00, 0xad, 0xea, - 0x3c, 0x64, 0x09, 0x00, 0xb5, 0xa5, 0xea, 0x19, - 0xb7, 0x11, 0x65, 0x00, 0x00, 0x0e, 0x0b, 0x38, + 0x00, 0x00, 0x00, 0x28, 0xdf, 0x11, 0x04, 0x0a, + 0x01, 0x00, 0x00, 0x41, 0x5d, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x00, 0x24, 0x01, 0x00, 0x21, 0x01, + 0x00, 0x30, 0x0e, 0xe0, 0x64, 0x04, 0x00, 0x64, + 0x05, 0x00, 0xf0, 0xc9, 0x61, 0x00, 0x00, 0xea, + 0x05, 0x61, 0x00, 0x00, 0x30, 0xb7, 0x11, 0x65, + 0x00, 0x00, 0x0e, 0x0b, 0x38, 0x46, 0x00, 0x00, + 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, + 0x6a, 0x00, 0x00, 0x00, 0x28, 0x60, 0x01, 0x00, + 0x60, 0x00, 0x00, 0xd1, 0xc9, 0xd2, 0x11, 0xf2, + 0xea, 0x08, 0x0e, 0x38, 0x46, 0x00, 0x00, 0x00, + 0xda, 0xca, 0x60, 0x14, 0x00, 0x60, 0x13, 0x00, + 0x60, 0x08, 0x00, 0x60, 0x07, 0x00, 0x60, 0x06, + 0x00, 0x60, 0x05, 0x00, 0x60, 0x04, 0x00, 0x60, + 0x03, 0x00, 0x60, 0x02, 0x00, 0x5d, 0x04, 0x00, + 0xd1, 0x04, 0x0b, 0x01, 0x00, 0x00, 0xf0, 0x0e, + 0xd2, 0x38, 0x46, 0x00, 0x00, 0x00, 0xad, 0xea, + 0x06, 0x0c, 0x07, 0xd6, 0xec, 0x0c, 0x5d, 0x04, + 0x00, 0xd2, 0x04, 0x0c, 0x01, 0x00, 0x00, 0xf0, + 0x0e, 0xd2, 0x40, 0xf8, 0x00, 0x00, 0x00, 0xcb, + 0x61, 0x02, 0x00, 0x38, 0x46, 0x00, 0x00, 0x00, + 0xad, 0xea, 0x0b, 0x04, 0x09, 0x01, 0x00, 0x00, + 0x11, 0x62, 0x02, 0x00, 0x0e, 0x61, 0x02, 0x00, + 0x04, 0x07, 0x01, 0x00, 0x00, 0xad, 0x11, 0xeb, + 0x18, 0x0e, 0x61, 0x02, 0x00, 0x04, 0x06, 0x01, + 0x00, 0x00, 0xad, 0x11, 0xeb, 0x0b, 0x0e, 0x61, + 0x02, 0x00, 0x04, 0x09, 0x01, 0x00, 0x00, 0xad, + 0x95, 0xea, 0x0c, 0xdd, 0x11, 0x04, 0x0d, 0x01, + 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x38, 0x46, + 0x00, 0x00, 0x00, 0xcc, 0x61, 0x02, 0x00, 0x04, + 0x06, 0x01, 0x00, 0x00, 0xad, 0xea, 0x24, 0xd2, + 0x40, 0xf9, 0x00, 0x00, 0x00, 0x11, 0x62, 0x03, + 0x00, 0x0e, 0x61, 0x03, 0x00, 0x38, 0x46, 0x00, + 0x00, 0x00, 0xae, 0xea, 0x0e, 0x5d, 0x04, 0x00, + 0x61, 0x03, 0x00, 0x04, 0x0e, 0x01, 0x00, 0x00, + 0xf0, 0x0e, 0x26, 0x00, 0x00, 0xc2, 0x04, 0xb4, + 0xc2, 0x05, 0x26, 0x00, 0x00, 0xc2, 0x06, 0x26, + 0x00, 0x00, 0xc2, 0x07, 0x26, 0x00, 0x00, 0xc2, + 0x08, 0x60, 0x09, 0x00, 0x5d, 0x05, 0x00, 0xd1, + 0xef, 0x7d, 0xec, 0x1d, 0xc2, 0x09, 0x61, 0x04, + 0x00, 0x61, 0x05, 0x00, 0x90, 0x62, 0x05, 0x00, + 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, + 0x1b, 0x61, 0x09, 0x00, 0x1b, 0x70, 0x1b, 0x48, + 0x80, 0x00, 0xea, 0xe1, 0x0e, 0x83, 0x6b, 0x7d, + 0x01, 0x00, 0x00, 0x60, 0x0a, 0x00, 0xb4, 0xc2, + 0x0a, 0x61, 0x0a, 0x00, 0x61, 0x05, 0x00, 0xa5, + 0x68, 0xf0, 0x00, 0x00, 0x00, 0x60, 0x0c, 0x00, + 0x60, 0x0b, 0x00, 0x0a, 0xc2, 0x0b, 0x61, 0x04, + 0x00, 0x61, 0x0a, 0x00, 0x46, 0xc2, 0x0c, 0x5d, + 0x06, 0x00, 0xd1, 0x61, 0x0c, 0x00, 0xf0, 0xea, + 0x78, 0x60, 0x0d, 0x00, 0xd1, 0x61, 0x0c, 0x00, + 0x46, 0xc2, 0x0d, 0x61, 0x0d, 0x00, 0x38, 0x46, + 0x00, 0x00, 0x00, 0xae, 0xea, 0x63, 0x60, 0x0e, + 0x00, 0x5d, 0x04, 0x00, 0x61, 0x0d, 0x00, 0x04, + 0x0f, 0x01, 0x00, 0x00, 0xf0, 0x0e, 0x61, 0x0d, + 0x00, 0x5d, 0x07, 0x00, 0x46, 0xc2, 0x0e, 0x61, + 0x0e, 0x00, 0xea, 0x0e, 0xdf, 0x61, 0x0d, 0x00, + 0x61, 0x0e, 0x00, 0xf0, 0x11, 0x62, 0x0d, 0x00, + 0x0e, 0x61, 0x06, 0x00, 0x61, 0x0a, 0x00, 0x1b, + 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, + 0x61, 0x0d, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x61, + 0x07, 0x00, 0x61, 0x0a, 0x00, 0x1b, 0x11, 0xaf, + 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x61, 0x0d, + 0x00, 0x40, 0x6b, 0x00, 0x00, 0x00, 0x1b, 0x70, + 0x1b, 0x48, 0x09, 0x11, 0x62, 0x0b, 0x00, 0x0e, + 0x61, 0x0b, 0x00, 0xea, 0x4a, 0x60, 0x0f, 0x00, + 0x61, 0x0a, 0x00, 0xb5, 0x9c, 0xc2, 0x0f, 0x61, + 0x0f, 0x00, 0x61, 0x05, 0x00, 0xa5, 0xea, 0x27, + 0x61, 0x04, 0x00, 0x61, 0x0f, 0x00, 0xb5, 0x9d, + 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, + 0x1b, 0x61, 0x04, 0x00, 0x61, 0x0f, 0x00, 0x46, + 0x1b, 0x70, 0x1b, 0x48, 0x61, 0x0f, 0x00, 0x90, + 0x62, 0x0f, 0x00, 0x0e, 0xec, 0xd2, 0x61, 0x05, + 0x00, 0x8f, 0x62, 0x05, 0x00, 0x0e, 0x61, 0x0a, + 0x00, 0x8f, 0x62, 0x0a, 0x00, 0x0e, 0x61, 0x0a, + 0x00, 0x90, 0x62, 0x0a, 0x00, 0x0e, 0xed, 0x0a, + 0xff, 0x61, 0x02, 0x00, 0x04, 0x06, 0x01, 0x00, + 0x00, 0xad, 0xea, 0x6e, 0x61, 0x03, 0x00, 0xea, + 0x38, 0x60, 0x10, 0x00, 0xb4, 0xc2, 0x10, 0x61, + 0x10, 0x00, 0x61, 0x05, 0x00, 0xa5, 0xea, 0x5a, + 0x61, 0x08, 0x00, 0x61, 0x10, 0x00, 0x1b, 0x11, + 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x61, + 0x03, 0x00, 0x61, 0x04, 0x00, 0x61, 0x10, 0x00, + 0x46, 0x46, 0x1b, 0x70, 0x1b, 0x48, 0x61, 0x10, + 0x00, 0x90, 0x62, 0x10, 0x00, 0x0e, 0xec, 0xd0, + 0x60, 0x11, 0x00, 0xb4, 0xc2, 0x11, 0x61, 0x11, + 0x00, 0x61, 0x05, 0x00, 0xa5, 0xea, 0x23, 0x61, + 0x08, 0x00, 0x61, 0x11, 0x00, 0x1b, 0x11, 0xaf, + 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x38, 0x46, + 0x00, 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x61, + 0x11, 0x00, 0x90, 0x62, 0x11, 0x00, 0x0e, 0xec, + 0xd6, 0x0e, 0xec, 0x15, 0xc2, 0x12, 0x6b, 0x10, + 0x00, 0x00, 0x00, 0xe0, 0x61, 0x06, 0x00, 0x61, + 0x05, 0x00, 0xf0, 0x0e, 0xc1, 0x12, 0x30, 0x30, + 0xb4, 0xc2, 0x13, 0x61, 0x05, 0x00, 0xc2, 0x14, + 0x0b, 0x5d, 0x08, 0x00, 0x4e, 0xbf, 0x00, 0x53, + 0x6b, 0x00, 0x00, 0x00, 0x04, 0xbf, 0x01, 0x53, + 0x06, 0x00, 0x00, 0x00, 0x04, 0x28, 0xbf, 0x00, + 0xc9, 0xbf, 0x01, 0xca, 0xbf, 0x02, 0xcb, 0xbf, + 0x03, 0x28, 0xbf, 0x00, 0xcd, 0x28, +}; + + +/* File generated automatically by the QuickJS-ng compiler. */ + +#include + +const uint32_t qjsc_builtin_iterator_zip_size = 2621; + +const uint8_t qjsc_builtin_iterator_zip[2621] = { + 0x18, 0x05, 0x6b, 0x07, 0x2a, 0x2a, 0x01, 0x1c, + 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, + 0x48, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x01, 0x08, + 0x63, 0x61, 0x6c, 0x6c, 0x01, 0x1e, 0x53, 0x79, + 0x6d, 0x62, 0x6f, 0x6c, 0xb7, 0x69, 0x74, 0x65, + 0x72, 0x61, 0x74, 0x6f, 0x72, 0x01, 0x0a, 0x63, + 0x68, 0x65, 0x63, 0x6b, 0x01, 0x0a, 0x63, 0x6c, + 0x6f, 0x73, 0x65, 0x01, 0x10, 0x63, 0x6c, 0x6f, + 0x73, 0x65, 0x61, 0x6c, 0x6c, 0x01, 0x02, 0x76, + 0x01, 0x02, 0x73, 0x01, 0x08, 0x69, 0x74, 0x65, + 0x72, 0x01, 0x0c, 0x6d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x01, 0x02, 0x65, 0x01, 0x0a, 0x69, 0x74, + 0x65, 0x72, 0x73, 0x01, 0x0a, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x01, 0x04, 0x65, 0x78, 0x01, 0x02, + 0x69, 0x01, 0x12, 0x69, 0x74, 0x65, 0x72, 0x61, + 0x62, 0x6c, 0x65, 0x73, 0x01, 0x0e, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x01, 0x08, 0x6d, + 0x6f, 0x64, 0x65, 0x01, 0x0e, 0x70, 0x61, 0x64, + 0x64, 0x69, 0x6e, 0x67, 0x01, 0x08, 0x70, 0x61, + 0x64, 0x73, 0x01, 0x0a, 0x6e, 0x65, 0x78, 0x74, + 0x73, 0x01, 0x16, 0x70, 0x61, 0x64, 0x64, 0x69, + 0x6e, 0x67, 0x69, 0x74, 0x65, 0x72, 0x01, 0x1a, + 0x69, 0x74, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, + 0x73, 0x69, 0x74, 0x65, 0x72, 0x01, 0x08, 0x69, + 0x74, 0x65, 0x6d, 0x01, 0x02, 0x74, 0x01, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x01, 0x0a, 0x61, + 0x6c, 0x69, 0x76, 0x65, 0x01, 0x0a, 0x64, 0x6f, + 0x6e, 0x65, 0x73, 0x01, 0x0e, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x73, 0x01, 0x0c, 0x72, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x01, 0x1c, 0x72, 0x75, + 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x7a, 0x69, + 0x70, 0x70, 0x65, 0x72, 0x01, 0x06, 0x62, 0x75, + 0x67, 0x01, 0x0e, 0x6c, 0x6f, 0x6e, 0x67, 0x65, + 0x73, 0x74, 0x01, 0x0c, 0x73, 0x74, 0x72, 0x69, + 0x63, 0x74, 0x01, 0x22, 0x6d, 0x69, 0x73, 0x6d, + 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x20, 0x69, + 0x6e, 0x70, 0x75, 0x74, 0x73, 0x01, 0x10, 0x73, + 0x68, 0x6f, 0x72, 0x74, 0x65, 0x73, 0x74, 0x01, + 0x16, 0x62, 0x75, 0x67, 0x3a, 0x20, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x3d, 0x01, 0x1a, 0x62, 0x61, + 0x64, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x62, + 0x6c, 0x65, 0x73, 0x01, 0x16, 0x62, 0x61, 0x64, + 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x01, 0x10, 0x62, 0x61, 0x64, 0x20, 0x6d, 0x6f, + 0x64, 0x65, 0x01, 0x16, 0x62, 0x61, 0x64, 0x20, + 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x01, + 0x18, 0x62, 0x61, 0x64, 0x20, 0x69, 0x74, 0x65, + 0x72, 0x61, 0x74, 0x6f, 0x72, 0x0c, 0x00, 0x02, + 0x00, 0xa2, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x04, 0x01, 0xa4, 0x01, 0x00, 0x00, + 0x00, 0x0c, 0x43, 0x02, 0x00, 0x00, 0x05, 0x03, + 0x05, 0x01, 0x08, 0x00, 0x04, 0x0c, 0x08, 0xca, + 0x03, 0x00, 0x01, 0x40, 0x07, 0xa8, 0x03, 0x00, + 0x01, 0x40, 0x03, 0xa4, 0x03, 0x00, 0x01, 0x40, + 0x00, 0xcc, 0x03, 0x00, 0x01, 0x40, 0x01, 0xce, + 0x03, 0x00, 0x01, 0x40, 0x06, 0xd0, 0x03, 0x00, + 0x00, 0x40, 0x05, 0xd2, 0x03, 0x00, 0x01, 0x40, + 0x02, 0xd4, 0x03, 0x00, 0x02, 0x40, 0x04, 0x0c, + 0x43, 0x02, 0x00, 0xd0, 0x03, 0x02, 0x00, 0x02, + 0x03, 0x00, 0x01, 0x00, 0x17, 0x02, 0xd6, 0x03, + 0x00, 0x01, 0x00, 0xd8, 0x03, 0x00, 0x01, 0x00, + 0xa4, 0x03, 0x02, 0x01, 0xd1, 0x96, 0x04, 0x4a, + 0x00, 0x00, 0x00, 0xad, 0xea, 0x07, 0xd1, 0x07, + 0xae, 0xea, 0x02, 0x29, 0xdd, 0x11, 0xd2, 0x21, + 0x01, 0x00, 0x30, 0x0c, 0x43, 0x02, 0x00, 0xd2, + 0x03, 0x01, 0x02, 0x01, 0x04, 0x00, 0x01, 0x00, + 0x2e, 0x03, 0xda, 0x03, 0x00, 0x01, 0x00, 0xdc, + 0x03, 0x02, 0x00, 0x20, 0xde, 0x03, 0x05, 0x00, + 0x03, 0xcc, 0x03, 0x03, 0x01, 0x6b, 0x23, 0x00, + 0x00, 0x00, 0x60, 0x00, 0x00, 0xd1, 0x95, 0xea, + 0x04, 0x06, 0x6e, 0x28, 0xd1, 0x40, 0x06, 0x00, + 0x00, 0x00, 0xc9, 0x61, 0x00, 0x00, 0xea, 0x08, + 0xdd, 0xd1, 0x61, 0x00, 0x00, 0xf0, 0x0e, 0x0e, + 0x29, 0xca, 0x6b, 0x07, 0x00, 0x00, 0x00, 0xc6, + 0x6e, 0x28, 0x30, 0x0c, 0x43, 0x02, 0x00, 0xd4, + 0x03, 0x02, 0x04, 0x02, 0x03, 0x00, 0x01, 0x00, + 0x55, 0x06, 0xe0, 0x03, 0x00, 0x01, 0x00, 0xe2, + 0x03, 0x00, 0x01, 0x00, 0xe4, 0x03, 0x01, 0x00, + 0x20, 0xe6, 0x03, 0x02, 0x01, 0x20, 0xda, 0x03, + 0x03, 0x02, 0x20, 0xde, 0x03, 0x03, 0x03, 0x20, + 0xd2, 0x03, 0x01, 0x00, 0x60, 0x00, 0x00, 0x38, + 0x46, 0x00, 0x00, 0x00, 0xc9, 0x60, 0x01, 0x00, + 0xd2, 0xca, 0x61, 0x01, 0x00, 0x8f, 0x62, 0x01, + 0x00, 0xb4, 0xa7, 0xea, 0x39, 0x60, 0x03, 0x00, + 0x60, 0x02, 0x00, 0xd1, 0x61, 0x01, 0x00, 0x46, + 0xcb, 0xd1, 0x61, 0x01, 0x00, 0x1b, 0x11, 0xaf, + 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x38, 0x46, + 0x00, 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0xdd, + 0x61, 0x02, 0x00, 0xef, 0xcc, 0x61, 0x00, 0x00, + 0x95, 0xea, 0xc8, 0x61, 0x03, 0x00, 0x11, 0x62, + 0x00, 0x00, 0x0e, 0xec, 0xbe, 0x61, 0x00, 0x00, + 0x28, 0x0c, 0x41, 0x02, 0x00, 0xa8, 0x02, 0x02, + 0x1a, 0x01, 0x05, 0x07, 0x08, 0x02, 0x8a, 0x06, + 0x1c, 0xe8, 0x03, 0x00, 0x01, 0x00, 0xea, 0x03, + 0x00, 0x01, 0x00, 0xe8, 0x03, 0x01, 0xff, 0xff, + 0xff, 0xff, 0x0f, 0x20, 0xea, 0x03, 0x01, 0x01, + 0x20, 0xec, 0x03, 0x02, 0x00, 0x60, 0x03, 0xee, + 0x03, 0x02, 0x03, 0x20, 0xf0, 0x03, 0x02, 0x04, + 0x60, 0x04, 0xe0, 0x03, 0x02, 0x05, 0x60, 0x02, + 0xf2, 0x03, 0x02, 0x06, 0x60, 0x05, 0xe2, 0x03, + 0x02, 0x07, 0x60, 0x01, 0xf4, 0x03, 0x02, 0x08, + 0x20, 0xf6, 0x03, 0x02, 0x09, 0x20, 0xd6, 0x01, + 0x09, 0x1a, 0x20, 0xf8, 0x03, 0x0b, 0x0b, 0x20, + 0xde, 0x03, 0x0d, 0x0f, 0x03, 0xda, 0x03, 0x0b, + 0x0c, 0x20, 0xdc, 0x03, 0x0b, 0x0e, 0x20, 0xd6, + 0x01, 0x13, 0x0b, 0x20, 0xe6, 0x03, 0x13, 0x10, + 0x20, 0xd4, 0x01, 0x13, 0x11, 0x20, 0x82, 0x01, + 0x15, 0x16, 0x20, 0xf8, 0x03, 0x16, 0x13, 0x20, + 0xde, 0x03, 0x17, 0x13, 0x03, 0xfa, 0x03, 0x13, + 0x12, 0x20, 0xe4, 0x03, 0x1c, 0x16, 0x20, 0xde, + 0x03, 0x1f, 0x1a, 0x03, 0xfc, 0x03, 0x02, 0x0a, + 0x60, 0x00, 0xfe, 0x03, 0x02, 0x19, 0x60, 0x06, + 0xa4, 0x03, 0x02, 0x01, 0xa8, 0x03, 0x01, 0x01, + 0xcc, 0x03, 0x03, 0x01, 0xd4, 0x03, 0x02, 0x00, + 0xd0, 0x03, 0x00, 0x00, 0xce, 0x03, 0x04, 0x01, + 0xd2, 0x03, 0x01, 0x00, 0xca, 0x03, 0x00, 0x01, + 0x0c, 0x42, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x05, 0x00, 0x0b, 0x00, 0xec, 0x04, 0x08, 0x80, + 0x04, 0x01, 0x00, 0x20, 0xd8, 0x01, 0x01, 0x01, + 0x20, 0x82, 0x04, 0x01, 0x02, 0x20, 0xe6, 0x03, + 0x03, 0x03, 0x20, 0xda, 0x03, 0x04, 0x04, 0x20, + 0x84, 0x04, 0x04, 0x05, 0x20, 0xde, 0x03, 0x09, + 0x06, 0x03, 0xe4, 0x03, 0x10, 0x06, 0x20, 0xfc, + 0x03, 0x18, 0x10, 0xa4, 0x03, 0x00, 0x02, 0xa8, + 0x03, 0x01, 0x02, 0xe2, 0x03, 0x07, 0x10, 0xe0, + 0x03, 0x05, 0x10, 0xec, 0x03, 0x02, 0x10, 0xf0, + 0x03, 0x04, 0x10, 0xcc, 0x03, 0x02, 0x02, 0xf2, + 0x03, 0x06, 0x10, 0xfe, 0x03, 0x19, 0x10, 0xd4, + 0x03, 0x03, 0x02, 0x60, 0x02, 0x00, 0x60, 0x01, + 0x00, 0x60, 0x00, 0x00, 0x64, 0x00, 0x00, 0x11, + 0xb4, 0xad, 0xeb, 0x06, 0x11, 0xb5, 0xad, 0xea, + 0x09, 0xb6, 0x11, 0x65, 0x00, 0x00, 0x0e, 0xec, + 0x33, 0x11, 0xb6, 0xad, 0xea, 0x0c, 0xde, 0x11, + 0x04, 0x03, 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, + 0x30, 0x11, 0xb7, 0xad, 0xea, 0x13, 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, + 0xdf, 0x11, 0x04, 0x04, 0x01, 0x00, 0x00, 0x21, + 0x01, 0x00, 0x30, 0x0e, 0xb4, 0xc9, 0xb4, 0xca, + 0x26, 0x00, 0x00, 0xcb, 0x60, 0x03, 0x00, 0xb4, + 0xcc, 0x61, 0x03, 0x00, 0x64, 0x03, 0x00, 0xa5, + 0x68, 0xd1, 0x01, 0x00, 0x00, 0x60, 0x05, 0x00, + 0x60, 0x04, 0x00, 0x64, 0x04, 0x00, 0x61, 0x03, + 0x00, 0x46, 0xc2, 0x04, 0x61, 0x04, 0x00, 0x95, + 0xea, 0x34, 0x64, 0x05, 0x00, 0x04, 0x05, 0x01, + 0x00, 0x00, 0xae, 0xea, 0x0c, 0xdf, 0x11, 0x04, + 0x04, 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x61, 0x02, 0x00, 0x61, 0x03, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x64, 0x06, 0x00, 0x61, 0x03, 0x00, 0x46, 0x1b, 0x70, - 0x1b, 0x48, 0xec, 0x27, 0x11, 0x04, 0x06, 0x01, - 0x00, 0x00, 0xad, 0xea, 0x1e, 0x61, 0x01, 0x00, + 0x1b, 0x48, 0xed, 0x7c, 0x01, 0x06, 0xc2, 0x05, + 0x6b, 0x1a, 0x00, 0x00, 0x00, 0x5d, 0x07, 0x00, + 0x61, 0x04, 0x00, 0x64, 0x08, 0x00, 0x61, 0x03, + 0x00, 0x46, 0xf0, 0x11, 0x62, 0x05, 0x00, 0x0e, + 0x0e, 0xec, 0x35, 0xc2, 0x06, 0x6b, 0x30, 0x00, + 0x00, 0x00, 0xb4, 0x11, 0x65, 0x09, 0x00, 0x0e, + 0x64, 0x04, 0x00, 0x61, 0x03, 0x00, 0x1b, 0x11, + 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x38, + 0x46, 0x00, 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, + 0x5d, 0x0a, 0x00, 0x64, 0x04, 0x00, 0x64, 0x03, + 0x00, 0xf0, 0x0e, 0xc1, 0x06, 0x30, 0x30, 0x61, + 0x05, 0x00, 0x40, 0x6a, 0x00, 0x00, 0x00, 0x95, + 0xea, 0x4f, 0x64, 0x05, 0x00, 0x04, 0x06, 0x01, + 0x00, 0x00, 0xad, 0xea, 0x1e, 0x61, 0x00, 0x00, 0xb4, 0xa7, 0xea, 0x17, 0x5d, 0x0a, 0x00, 0x64, 0x04, 0x00, 0x64, 0x03, 0x00, 0xf0, 0x0e, 0xde, 0x11, 0x04, 0x07, 0x01, 0x00, 0x00, 0x21, 0x01, - 0x00, 0x30, 0x0e, 0x61, 0x03, 0x00, 0x90, 0x62, - 0x03, 0x00, 0x0e, 0xed, 0x29, 0xfe, 0x61, 0x01, - 0x00, 0xb4, 0xad, 0xea, 0x19, 0xb7, 0x11, 0x65, - 0x00, 0x00, 0x0e, 0x0b, 0x38, 0x46, 0x00, 0x00, - 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, - 0x6a, 0x00, 0x00, 0x00, 0x28, 0xb5, 0x11, 0x65, - 0x00, 0x00, 0x0e, 0x0b, 0x61, 0x02, 0x00, 0x4b, - 0x41, 0x00, 0x00, 0x00, 0x09, 0x4b, 0x6a, 0x00, - 0x00, 0x00, 0x28, 0x0c, 0x42, 0x03, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x06, 0x00, 0x06, 0x00, 0x88, - 0x01, 0x01, 0xe4, 0x03, 0x01, 0x00, 0x20, 0xfc, - 0x03, 0x18, 0x10, 0xa4, 0x03, 0x00, 0x02, 0xa8, - 0x03, 0x01, 0x02, 0xd4, 0x03, 0x03, 0x02, 0xe0, - 0x03, 0x05, 0x10, 0xe2, 0x03, 0x07, 0x10, 0x60, - 0x00, 0x00, 0x64, 0x00, 0x00, 0x11, 0xb4, 0xad, - 0xea, 0x09, 0xb7, 0x11, 0x65, 0x00, 0x00, 0x0e, - 0xec, 0x4b, 0x11, 0xb5, 0xad, 0xea, 0x09, 0xb6, - 0x11, 0x65, 0x00, 0x00, 0x0e, 0xec, 0x3e, 0x11, - 0xb6, 0xad, 0xea, 0x0c, 0xde, 0x11, 0x04, 0x03, - 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x11, - 0xb7, 0xad, 0xea, 0x13, 0x0b, 0x38, 0x46, 0x00, - 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, - 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, 0xdf, 0x11, - 0x04, 0x09, 0x01, 0x00, 0x00, 0x41, 0x5d, 0x00, - 0x00, 0x00, 0x64, 0x00, 0x00, 0x24, 0x01, 0x00, - 0x21, 0x01, 0x00, 0x30, 0x0e, 0xe0, 0x64, 0x04, - 0x00, 0x64, 0x05, 0x00, 0xf0, 0xc9, 0x61, 0x00, - 0x00, 0xea, 0x05, 0x61, 0x00, 0x00, 0x30, 0xb7, - 0x11, 0x65, 0x00, 0x00, 0x0e, 0x0b, 0x38, 0x46, - 0x00, 0x00, 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, - 0x0a, 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, 0x60, - 0x01, 0x00, 0x60, 0x00, 0x00, 0xd1, 0xc9, 0xd2, - 0x11, 0xf2, 0xea, 0x08, 0x0e, 0x38, 0x46, 0x00, - 0x00, 0x00, 0xda, 0xca, 0x60, 0x19, 0x00, 0x60, - 0x18, 0x00, 0x60, 0x09, 0x00, 0x60, 0x08, 0x00, - 0x60, 0x07, 0x00, 0x60, 0x06, 0x00, 0x60, 0x05, - 0x00, 0x60, 0x04, 0x00, 0x60, 0x03, 0x00, 0x60, - 0x02, 0x00, 0x5d, 0x04, 0x00, 0xd1, 0x04, 0x0a, - 0x01, 0x00, 0x00, 0xf0, 0x0e, 0xd2, 0x38, 0x46, - 0x00, 0x00, 0x00, 0xad, 0xea, 0x06, 0x0c, 0x07, - 0xd6, 0xec, 0x0c, 0x5d, 0x04, 0x00, 0xd2, 0x04, - 0x0b, 0x01, 0x00, 0x00, 0xf0, 0x0e, 0xd2, 0x40, - 0xf6, 0x00, 0x00, 0x00, 0xcb, 0x61, 0x02, 0x00, - 0x38, 0x46, 0x00, 0x00, 0x00, 0xad, 0xea, 0x0b, - 0x04, 0x08, 0x01, 0x00, 0x00, 0x11, 0x62, 0x02, - 0x00, 0x0e, 0x61, 0x02, 0x00, 0x04, 0x06, 0x01, - 0x00, 0x00, 0xad, 0x11, 0xeb, 0x18, 0x0e, 0x61, - 0x02, 0x00, 0x04, 0x05, 0x01, 0x00, 0x00, 0xad, - 0x11, 0xeb, 0x0b, 0x0e, 0x61, 0x02, 0x00, 0x04, - 0x08, 0x01, 0x00, 0x00, 0xad, 0x95, 0xea, 0x0c, - 0xdd, 0x11, 0x04, 0x0c, 0x01, 0x00, 0x00, 0x21, - 0x01, 0x00, 0x30, 0x38, 0x46, 0x00, 0x00, 0x00, - 0xcc, 0x61, 0x02, 0x00, 0x04, 0x05, 0x01, 0x00, - 0x00, 0xad, 0xea, 0x24, 0xd2, 0x40, 0xf7, 0x00, - 0x00, 0x00, 0x11, 0x62, 0x03, 0x00, 0x0e, 0x61, - 0x03, 0x00, 0x38, 0x46, 0x00, 0x00, 0x00, 0xae, - 0xea, 0x0e, 0x5d, 0x04, 0x00, 0x61, 0x03, 0x00, - 0x04, 0x0d, 0x01, 0x00, 0x00, 0xf0, 0x0e, 0x26, - 0x00, 0x00, 0xc2, 0x04, 0x26, 0x00, 0x00, 0xc2, - 0x05, 0x26, 0x00, 0x00, 0xc2, 0x06, 0xb4, 0xc2, - 0x07, 0x38, 0x46, 0x00, 0x00, 0x00, 0xc2, 0x08, - 0xd1, 0x5d, 0x05, 0x00, 0x47, 0x24, 0x00, 0x00, - 0xc2, 0x09, 0x6b, 0xcc, 0x01, 0x00, 0x00, 0x60, - 0x0a, 0x00, 0x61, 0x09, 0x00, 0x40, 0x6b, 0x00, - 0x00, 0x00, 0xc2, 0x0a, 0x60, 0x0e, 0x00, 0x60, - 0x0d, 0x00, 0x60, 0x0b, 0x00, 0x06, 0xc2, 0x0b, - 0x6b, 0x14, 0x00, 0x00, 0x00, 0xdf, 0x61, 0x09, - 0x00, 0x61, 0x0a, 0x00, 0xf0, 0x11, 0x62, 0x0b, - 0x00, 0x0e, 0x0e, 0xec, 0x16, 0xc2, 0x0c, 0x6b, - 0x11, 0x00, 0x00, 0x00, 0x38, 0x46, 0x00, 0x00, - 0x00, 0x11, 0x62, 0x09, 0x00, 0x0e, 0xc1, 0x0c, - 0x30, 0x30, 0x61, 0x0b, 0x00, 0x40, 0x6a, 0x00, - 0x00, 0x00, 0xeb, 0x6f, 0x61, 0x0b, 0x00, 0x40, - 0x41, 0x00, 0x00, 0x00, 0xc2, 0x0d, 0x5d, 0x04, - 0x00, 0x61, 0x0d, 0x00, 0x04, 0x0e, 0x01, 0x00, - 0x00, 0xf0, 0x0e, 0x61, 0x0d, 0x00, 0x5d, 0x05, - 0x00, 0x46, 0xc2, 0x0e, 0x61, 0x0e, 0x00, 0xea, - 0x0e, 0xdf, 0x61, 0x0d, 0x00, 0x61, 0x0e, 0x00, - 0xf0, 0x11, 0x62, 0x0d, 0x00, 0x0e, 0x61, 0x05, - 0x00, 0x61, 0x07, 0x00, 0x1b, 0x11, 0xaf, 0xeb, - 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x61, 0x0d, 0x00, - 0x1b, 0x70, 0x1b, 0x48, 0x61, 0x06, 0x00, 0x61, - 0x07, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, - 0x70, 0x1b, 0x1b, 0x61, 0x0d, 0x00, 0x40, 0x6b, - 0x00, 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x61, - 0x07, 0x00, 0x90, 0x62, 0x07, 0x00, 0x0e, 0xed, - 0x54, 0xff, 0x38, 0x46, 0x00, 0x00, 0x00, 0x11, - 0x62, 0x09, 0x00, 0x0e, 0x61, 0x03, 0x00, 0x68, - 0xfc, 0x00, 0x00, 0x00, 0x60, 0x15, 0x00, 0x60, - 0x11, 0x00, 0x60, 0x10, 0x00, 0x60, 0x0f, 0x00, - 0x61, 0x03, 0x00, 0x5d, 0x05, 0x00, 0x47, 0x24, - 0x00, 0x00, 0x11, 0x62, 0x08, 0x00, 0x0e, 0x61, - 0x08, 0x00, 0x40, 0x6b, 0x00, 0x00, 0x00, 0xc2, - 0x0f, 0xb4, 0xc2, 0x10, 0x09, 0xc2, 0x11, 0x61, - 0x10, 0x00, 0x61, 0x07, 0x00, 0xa5, 0xea, 0x70, - 0x60, 0x12, 0x00, 0x06, 0xc2, 0x12, 0x6b, 0x2e, - 0x00, 0x00, 0x00, 0x60, 0x13, 0x00, 0xdf, 0x61, - 0x08, 0x00, 0x61, 0x0f, 0x00, 0xf0, 0xc2, 0x13, - 0x61, 0x13, 0x00, 0x40, 0x6a, 0x00, 0x00, 0x00, - 0x11, 0x62, 0x11, 0x00, 0x0e, 0x61, 0x13, 0x00, - 0x40, 0x41, 0x00, 0x00, 0x00, 0x11, 0x62, 0x12, - 0x00, 0x0e, 0x0e, 0xec, 0x16, 0xc2, 0x14, 0x6b, - 0x11, 0x00, 0x00, 0x00, 0x38, 0x46, 0x00, 0x00, - 0x00, 0x11, 0x62, 0x08, 0x00, 0x0e, 0xc1, 0x14, - 0x30, 0x30, 0x61, 0x11, 0x00, 0xeb, 0x21, 0x61, - 0x04, 0x00, 0x61, 0x10, 0x00, 0x1b, 0x11, 0xaf, - 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x61, 0x12, - 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x61, 0x10, 0x00, - 0x90, 0x62, 0x10, 0x00, 0x0e, 0xec, 0x89, 0x61, - 0x08, 0x00, 0xc2, 0x15, 0x38, 0x46, 0x00, 0x00, - 0x00, 0x11, 0x62, 0x08, 0x00, 0x0e, 0x61, 0x11, - 0x00, 0x95, 0xea, 0x16, 0x60, 0x16, 0x00, 0x5d, - 0x06, 0x00, 0x61, 0x15, 0x00, 0xef, 0xc2, 0x16, - 0x61, 0x16, 0x00, 0xea, 0x05, 0x61, 0x16, 0x00, - 0x30, 0x61, 0x10, 0x00, 0x61, 0x07, 0x00, 0xa5, - 0xea, 0x23, 0x61, 0x04, 0x00, 0x61, 0x10, 0x00, + 0x00, 0x30, 0x61, 0x02, 0x00, 0x61, 0x03, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, - 0x1b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x1b, 0x70, - 0x1b, 0x48, 0x61, 0x10, 0x00, 0x90, 0x62, 0x10, - 0x00, 0x0e, 0xec, 0xd6, 0x0e, 0xec, 0x25, 0xc2, - 0x17, 0x6b, 0x20, 0x00, 0x00, 0x00, 0xe0, 0x61, - 0x05, 0x00, 0x61, 0x07, 0x00, 0xf0, 0x0e, 0x5d, - 0x06, 0x00, 0x61, 0x09, 0x00, 0xef, 0x0e, 0x5d, - 0x06, 0x00, 0x61, 0x08, 0x00, 0xef, 0x0e, 0xc1, - 0x17, 0x30, 0x30, 0xb4, 0xc2, 0x18, 0x61, 0x07, - 0x00, 0xc2, 0x19, 0x0b, 0x5d, 0x07, 0x00, 0x4e, - 0xbf, 0x00, 0x53, 0x6b, 0x00, 0x00, 0x00, 0x04, - 0xbf, 0x01, 0x53, 0x06, 0x00, 0x00, 0x00, 0x04, - 0x28, 0xbf, 0x00, 0xc9, 0xbf, 0x01, 0xca, 0xbf, - 0x02, 0xcb, 0xbf, 0x03, 0x28, 0xbf, 0x00, 0xcd, - 0x28, + 0x1b, 0x61, 0x05, 0x00, 0x40, 0x41, 0x00, 0x00, + 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x61, 0x01, 0x00, + 0x90, 0x62, 0x01, 0x00, 0x0e, 0xed, 0xd1, 0x00, + 0x64, 0x09, 0x00, 0x8f, 0x65, 0x09, 0x00, 0x0e, + 0x61, 0x00, 0x00, 0x90, 0x62, 0x00, 0x00, 0x0e, + 0x64, 0x04, 0x00, 0x61, 0x03, 0x00, 0x1b, 0x11, + 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x38, + 0x46, 0x00, 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, + 0x64, 0x05, 0x00, 0x60, 0x07, 0x00, 0x11, 0x04, + 0x08, 0x01, 0x00, 0x00, 0xad, 0xea, 0x2e, 0x5d, + 0x0a, 0x00, 0x64, 0x04, 0x00, 0x64, 0x03, 0x00, + 0xf0, 0xc2, 0x07, 0x61, 0x07, 0x00, 0xea, 0x05, + 0x61, 0x07, 0x00, 0x30, 0xb7, 0x11, 0x65, 0x00, + 0x00, 0x0e, 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, + 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, + 0x00, 0x00, 0x00, 0x28, 0x11, 0x04, 0x05, 0x01, + 0x00, 0x00, 0xad, 0xea, 0x3c, 0x64, 0x09, 0x00, + 0xb5, 0xa5, 0xea, 0x19, 0xb7, 0x11, 0x65, 0x00, + 0x00, 0x0e, 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, + 0x4b, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, + 0x00, 0x00, 0x00, 0x28, 0x61, 0x02, 0x00, 0x61, + 0x03, 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, + 0x70, 0x1b, 0x1b, 0x64, 0x06, 0x00, 0x61, 0x03, + 0x00, 0x46, 0x1b, 0x70, 0x1b, 0x48, 0xec, 0x27, + 0x11, 0x04, 0x06, 0x01, 0x00, 0x00, 0xad, 0xea, + 0x1e, 0x61, 0x01, 0x00, 0xb4, 0xa7, 0xea, 0x17, + 0x5d, 0x0a, 0x00, 0x64, 0x04, 0x00, 0x64, 0x03, + 0x00, 0xf0, 0x0e, 0xde, 0x11, 0x04, 0x07, 0x01, + 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x0e, 0x61, + 0x03, 0x00, 0x90, 0x62, 0x03, 0x00, 0x0e, 0xed, + 0x29, 0xfe, 0x61, 0x01, 0x00, 0xb4, 0xad, 0xea, + 0x19, 0xb7, 0x11, 0x65, 0x00, 0x00, 0x0e, 0x0b, + 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, 0x41, 0x00, + 0x00, 0x00, 0x0a, 0x4b, 0x6a, 0x00, 0x00, 0x00, + 0x28, 0xb5, 0x11, 0x65, 0x00, 0x00, 0x0e, 0x0b, + 0x61, 0x02, 0x00, 0x4b, 0x41, 0x00, 0x00, 0x00, + 0x09, 0x4b, 0x6a, 0x00, 0x00, 0x00, 0x28, 0x0c, + 0x42, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, + 0x00, 0x06, 0x00, 0x88, 0x01, 0x01, 0xe4, 0x03, + 0x01, 0x00, 0x20, 0xfc, 0x03, 0x18, 0x10, 0xa4, + 0x03, 0x00, 0x02, 0xa8, 0x03, 0x01, 0x02, 0xd4, + 0x03, 0x03, 0x02, 0xe0, 0x03, 0x05, 0x10, 0xe2, + 0x03, 0x07, 0x10, 0x60, 0x00, 0x00, 0x64, 0x00, + 0x00, 0x11, 0xb4, 0xad, 0xea, 0x09, 0xb7, 0x11, + 0x65, 0x00, 0x00, 0x0e, 0xec, 0x4b, 0x11, 0xb5, + 0xad, 0xea, 0x09, 0xb6, 0x11, 0x65, 0x00, 0x00, + 0x0e, 0xec, 0x3e, 0x11, 0xb6, 0xad, 0xea, 0x0c, + 0xde, 0x11, 0x04, 0x03, 0x01, 0x00, 0x00, 0x21, + 0x01, 0x00, 0x30, 0x11, 0xb7, 0xad, 0xea, 0x13, + 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, 0x41, + 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, 0x00, 0x00, + 0x00, 0x28, 0xdf, 0x11, 0x04, 0x09, 0x01, 0x00, + 0x00, 0x41, 0x5d, 0x00, 0x00, 0x00, 0x64, 0x00, + 0x00, 0x24, 0x01, 0x00, 0x21, 0x01, 0x00, 0x30, + 0x0e, 0xe0, 0x64, 0x04, 0x00, 0x64, 0x05, 0x00, + 0xf0, 0xc9, 0x61, 0x00, 0x00, 0xea, 0x05, 0x61, + 0x00, 0x00, 0x30, 0xb7, 0x11, 0x65, 0x00, 0x00, + 0x0e, 0x0b, 0x38, 0x46, 0x00, 0x00, 0x00, 0x4b, + 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4b, 0x6a, 0x00, + 0x00, 0x00, 0x28, 0x60, 0x01, 0x00, 0x60, 0x00, + 0x00, 0xd1, 0xc9, 0xd2, 0x11, 0xf2, 0xea, 0x08, + 0x0e, 0x38, 0x46, 0x00, 0x00, 0x00, 0xda, 0xca, + 0x60, 0x19, 0x00, 0x60, 0x18, 0x00, 0x60, 0x09, + 0x00, 0x60, 0x08, 0x00, 0x60, 0x07, 0x00, 0x60, + 0x06, 0x00, 0x60, 0x05, 0x00, 0x60, 0x04, 0x00, + 0x60, 0x03, 0x00, 0x60, 0x02, 0x00, 0x5d, 0x04, + 0x00, 0xd1, 0x04, 0x0a, 0x01, 0x00, 0x00, 0xf0, + 0x0e, 0xd2, 0x38, 0x46, 0x00, 0x00, 0x00, 0xad, + 0xea, 0x06, 0x0c, 0x07, 0xd6, 0xec, 0x0c, 0x5d, + 0x04, 0x00, 0xd2, 0x04, 0x0b, 0x01, 0x00, 0x00, + 0xf0, 0x0e, 0xd2, 0x40, 0xf6, 0x00, 0x00, 0x00, + 0xcb, 0x61, 0x02, 0x00, 0x38, 0x46, 0x00, 0x00, + 0x00, 0xad, 0xea, 0x0b, 0x04, 0x08, 0x01, 0x00, + 0x00, 0x11, 0x62, 0x02, 0x00, 0x0e, 0x61, 0x02, + 0x00, 0x04, 0x06, 0x01, 0x00, 0x00, 0xad, 0x11, + 0xeb, 0x18, 0x0e, 0x61, 0x02, 0x00, 0x04, 0x05, + 0x01, 0x00, 0x00, 0xad, 0x11, 0xeb, 0x0b, 0x0e, + 0x61, 0x02, 0x00, 0x04, 0x08, 0x01, 0x00, 0x00, + 0xad, 0x95, 0xea, 0x0c, 0xdd, 0x11, 0x04, 0x0c, + 0x01, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x38, + 0x46, 0x00, 0x00, 0x00, 0xcc, 0x61, 0x02, 0x00, + 0x04, 0x05, 0x01, 0x00, 0x00, 0xad, 0xea, 0x24, + 0xd2, 0x40, 0xf7, 0x00, 0x00, 0x00, 0x11, 0x62, + 0x03, 0x00, 0x0e, 0x61, 0x03, 0x00, 0x38, 0x46, + 0x00, 0x00, 0x00, 0xae, 0xea, 0x0e, 0x5d, 0x04, + 0x00, 0x61, 0x03, 0x00, 0x04, 0x0d, 0x01, 0x00, + 0x00, 0xf0, 0x0e, 0x26, 0x00, 0x00, 0xc2, 0x04, + 0x26, 0x00, 0x00, 0xc2, 0x05, 0x26, 0x00, 0x00, + 0xc2, 0x06, 0xb4, 0xc2, 0x07, 0x38, 0x46, 0x00, + 0x00, 0x00, 0xc2, 0x08, 0xd1, 0x5d, 0x05, 0x00, + 0x47, 0x24, 0x00, 0x00, 0xc2, 0x09, 0x6b, 0xcc, + 0x01, 0x00, 0x00, 0x60, 0x0a, 0x00, 0x61, 0x09, + 0x00, 0x40, 0x6b, 0x00, 0x00, 0x00, 0xc2, 0x0a, + 0x60, 0x0e, 0x00, 0x60, 0x0d, 0x00, 0x60, 0x0b, + 0x00, 0x06, 0xc2, 0x0b, 0x6b, 0x14, 0x00, 0x00, + 0x00, 0xdf, 0x61, 0x09, 0x00, 0x61, 0x0a, 0x00, + 0xf0, 0x11, 0x62, 0x0b, 0x00, 0x0e, 0x0e, 0xec, + 0x16, 0xc2, 0x0c, 0x6b, 0x11, 0x00, 0x00, 0x00, + 0x38, 0x46, 0x00, 0x00, 0x00, 0x11, 0x62, 0x09, + 0x00, 0x0e, 0xc1, 0x0c, 0x30, 0x30, 0x61, 0x0b, + 0x00, 0x40, 0x6a, 0x00, 0x00, 0x00, 0xeb, 0x6f, + 0x61, 0x0b, 0x00, 0x40, 0x41, 0x00, 0x00, 0x00, + 0xc2, 0x0d, 0x5d, 0x04, 0x00, 0x61, 0x0d, 0x00, + 0x04, 0x0e, 0x01, 0x00, 0x00, 0xf0, 0x0e, 0x61, + 0x0d, 0x00, 0x5d, 0x05, 0x00, 0x46, 0xc2, 0x0e, + 0x61, 0x0e, 0x00, 0xea, 0x0e, 0xdf, 0x61, 0x0d, + 0x00, 0x61, 0x0e, 0x00, 0xf0, 0x11, 0x62, 0x0d, + 0x00, 0x0e, 0x61, 0x05, 0x00, 0x61, 0x07, 0x00, + 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, + 0x1b, 0x61, 0x0d, 0x00, 0x1b, 0x70, 0x1b, 0x48, + 0x61, 0x06, 0x00, 0x61, 0x07, 0x00, 0x1b, 0x11, + 0xaf, 0xeb, 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x61, + 0x0d, 0x00, 0x40, 0x6b, 0x00, 0x00, 0x00, 0x1b, + 0x70, 0x1b, 0x48, 0x61, 0x07, 0x00, 0x90, 0x62, + 0x07, 0x00, 0x0e, 0xed, 0x54, 0xff, 0x38, 0x46, + 0x00, 0x00, 0x00, 0x11, 0x62, 0x09, 0x00, 0x0e, + 0x61, 0x03, 0x00, 0x68, 0xfc, 0x00, 0x00, 0x00, + 0x60, 0x15, 0x00, 0x60, 0x11, 0x00, 0x60, 0x10, + 0x00, 0x60, 0x0f, 0x00, 0x61, 0x03, 0x00, 0x5d, + 0x05, 0x00, 0x47, 0x24, 0x00, 0x00, 0x11, 0x62, + 0x08, 0x00, 0x0e, 0x61, 0x08, 0x00, 0x40, 0x6b, + 0x00, 0x00, 0x00, 0xc2, 0x0f, 0xb4, 0xc2, 0x10, + 0x09, 0xc2, 0x11, 0x61, 0x10, 0x00, 0x61, 0x07, + 0x00, 0xa5, 0xea, 0x70, 0x60, 0x12, 0x00, 0x06, + 0xc2, 0x12, 0x6b, 0x2e, 0x00, 0x00, 0x00, 0x60, + 0x13, 0x00, 0xdf, 0x61, 0x08, 0x00, 0x61, 0x0f, + 0x00, 0xf0, 0xc2, 0x13, 0x61, 0x13, 0x00, 0x40, + 0x6a, 0x00, 0x00, 0x00, 0x11, 0x62, 0x11, 0x00, + 0x0e, 0x61, 0x13, 0x00, 0x40, 0x41, 0x00, 0x00, + 0x00, 0x11, 0x62, 0x12, 0x00, 0x0e, 0x0e, 0xec, + 0x16, 0xc2, 0x14, 0x6b, 0x11, 0x00, 0x00, 0x00, + 0x38, 0x46, 0x00, 0x00, 0x00, 0x11, 0x62, 0x08, + 0x00, 0x0e, 0xc1, 0x14, 0x30, 0x30, 0x61, 0x11, + 0x00, 0xeb, 0x21, 0x61, 0x04, 0x00, 0x61, 0x10, + 0x00, 0x1b, 0x11, 0xaf, 0xeb, 0x04, 0x1b, 0x70, + 0x1b, 0x1b, 0x61, 0x12, 0x00, 0x1b, 0x70, 0x1b, + 0x48, 0x61, 0x10, 0x00, 0x90, 0x62, 0x10, 0x00, + 0x0e, 0xec, 0x89, 0x61, 0x08, 0x00, 0xc2, 0x15, + 0x38, 0x46, 0x00, 0x00, 0x00, 0x11, 0x62, 0x08, + 0x00, 0x0e, 0x61, 0x11, 0x00, 0x95, 0xea, 0x16, + 0x60, 0x16, 0x00, 0x5d, 0x06, 0x00, 0x61, 0x15, + 0x00, 0xef, 0xc2, 0x16, 0x61, 0x16, 0x00, 0xea, + 0x05, 0x61, 0x16, 0x00, 0x30, 0x61, 0x10, 0x00, + 0x61, 0x07, 0x00, 0xa5, 0xea, 0x23, 0x61, 0x04, + 0x00, 0x61, 0x10, 0x00, 0x1b, 0x11, 0xaf, 0xeb, + 0x04, 0x1b, 0x70, 0x1b, 0x1b, 0x38, 0x46, 0x00, + 0x00, 0x00, 0x1b, 0x70, 0x1b, 0x48, 0x61, 0x10, + 0x00, 0x90, 0x62, 0x10, 0x00, 0x0e, 0xec, 0xd6, + 0x0e, 0xec, 0x25, 0xc2, 0x17, 0x6b, 0x20, 0x00, + 0x00, 0x00, 0xe0, 0x61, 0x05, 0x00, 0x61, 0x07, + 0x00, 0xf0, 0x0e, 0x5d, 0x06, 0x00, 0x61, 0x09, + 0x00, 0xef, 0x0e, 0x5d, 0x06, 0x00, 0x61, 0x08, + 0x00, 0xef, 0x0e, 0xc1, 0x17, 0x30, 0x30, 0xb4, + 0xc2, 0x18, 0x61, 0x07, 0x00, 0xc2, 0x19, 0x0b, + 0x5d, 0x07, 0x00, 0x4e, 0xbf, 0x00, 0x53, 0x6b, + 0x00, 0x00, 0x00, 0x04, 0xbf, 0x01, 0x53, 0x06, + 0x00, 0x00, 0x00, 0x04, 0x28, 0xbf, 0x00, 0xc9, + 0xbf, 0x01, 0xca, 0xbf, 0x02, 0xcb, 0xbf, 0x03, + 0x28, 0xbf, 0x00, 0xcd, 0x28, }; @@ -19975,7 +20092,7 @@ static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx, exotic_count = 0; tab_exotic = NULL; sh = p->shape; - for(i = 0, prs = get_shape_prop(sh); i < sh->prop_count; i++, prs++) { + for(i = 0, prs = sh->prop; i < sh->prop_count; i++, prs++) { atom = prs->atom; if (atom != JS_ATOM_NULL) { is_enumerable = ((prs->flags & JS_PROP_ENUMERABLE) != 0); @@ -20064,7 +20181,7 @@ static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx, num_sorted = true; sh = p->shape; - for(i = 0, prs = get_shape_prop(sh); i < sh->prop_count; i++, prs++) { + for(i = 0, prs = sh->prop; i < sh->prop_count; i++, prs++) { atom = prs->atom; if (atom != JS_ATOM_NULL) { is_enumerable = ((prs->flags & JS_PROP_ENUMERABLE) != 0); @@ -20656,7 +20773,7 @@ static int delete_property(JSContext *ctx, JSObject *p, JSAtom atom) sh = p->shape; h1 = atom & sh->prop_hash_mask; h = prop_hash_end(sh)[-h1 - 1]; - prop = get_shape_prop(sh); + prop = sh->prop; lpr = NULL; lpr_idx = 0; /* prevent warning */ while (h != 0) { @@ -20667,13 +20784,13 @@ static int delete_property(JSContext *ctx, JSObject *p, JSAtom atom) return false; /* realloc the shape if needed */ if (lpr) - lpr_idx = lpr - get_shape_prop(sh); + lpr_idx = lpr - sh->prop; if (js_shape_prepare_update(ctx, p, &pr)) return -1; sh = p->shape; /* remove property */ if (lpr) { - lpr = get_shape_prop(sh) + lpr_idx; + lpr = &sh->prop[lpr_idx]; lpr->hash_next = pr->hash_next; } else { prop_hash_end(sh)[-h1 - 1] = pr->hash_next; @@ -20815,7 +20932,7 @@ static int set_array_length(JSContext *ctx, JSObject *p, JSValue val, passes in case one of the property is not configurable */ cur_len = len; - for(i = 0, pr = get_shape_prop(sh); i < sh->prop_count; + for(i = 0, pr = sh->prop; i < sh->prop_count; i++, pr++) { if (pr->atom != JS_ATOM_NULL && JS_AtomIsArrayIndex(ctx, &idx, pr->atom)) { @@ -20826,7 +20943,7 @@ static int set_array_length(JSContext *ctx, JSObject *p, JSValue val, } } - for(i = 0, pr = get_shape_prop(sh); i < sh->prop_count; + for(i = 0, pr = sh->prop; i < sh->prop_count; i++, pr++) { if (pr->atom != JS_ATOM_NULL && JS_AtomIsArrayIndex(ctx, &idx, pr->atom)) { @@ -20835,7 +20952,7 @@ static int set_array_length(JSContext *ctx, JSObject *p, JSValue val, delete_property(ctx, p, pr->atom); /* WARNING: the shape may have been modified */ sh = p->shape; - pr = get_shape_prop(sh) + i; + pr = &sh->prop[i]; } } } @@ -20882,7 +20999,7 @@ static int add_fast_array_element(JSContext *ctx, JSObject *p, if (likely(JS_VALUE_GET_TAG(p->prop[0].u.value) == JS_TAG_INT)) { array_len = JS_VALUE_GET_INT(p->prop[0].u.value); if (new_len > array_len) { - if (unlikely(!(get_shape_prop(p->shape)->flags & JS_PROP_WRITABLE))) { + if (unlikely(!(p->shape->prop->flags & JS_PROP_WRITABLE))) { JS_FreeValue(ctx, val); return JS_ThrowTypeErrorReadOnly(ctx, flags, JS_ATOM_length); } @@ -21425,7 +21542,7 @@ static int JS_CreateProperty(JSContext *ctx, JSObject *p, plen = &p->prop[0]; JS_ToUint32(ctx, &len, plen->u.value); if ((idx + 1) > len) { - pslen = get_shape_prop(p->shape); + pslen = p->shape->prop; if (unlikely(!(pslen->flags & JS_PROP_WRITABLE))) return JS_ThrowTypeErrorReadOnly(ctx, flags, JS_ATOM_length); /* XXX: should update the length after defining @@ -21535,7 +21652,7 @@ static int js_shape_prepare_update(JSContext *ctx, JSObject *p, if (sh->is_hashed) { if (sh->header.ref_count != 1) { if (pprs) - idx = *pprs - get_shape_prop(sh); + idx = *pprs - sh->prop; /* clone the shape (the resulting one is no longer hashed) */ sh = js_clone_shape(ctx, sh); if (!sh) @@ -21543,7 +21660,7 @@ static int js_shape_prepare_update(JSContext *ctx, JSObject *p, js_free_shape(ctx->rt, p->shape); p->shape = sh; if (pprs) - *pprs = get_shape_prop(sh) + idx; + *pprs = &sh->prop[idx]; } else { js_shape_hash_unlink(ctx->rt, sh); sh->is_hashed = false; @@ -21733,7 +21850,7 @@ int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj, property is read-only. */ if ((flags & (JS_PROP_HAS_WRITABLE | JS_PROP_WRITABLE)) == JS_PROP_HAS_WRITABLE) { - prs = get_shape_prop(p->shape); + prs = p->shape->prop; if (js_update_property_flags(ctx, p, &prs, prs->flags & ~JS_PROP_WRITABLE)) return -1; @@ -25150,7 +25267,7 @@ static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p) if (sh) { printf("{ "); - for(i = 0, prs = get_shape_prop(sh); i < sh->prop_count; i++, prs++) { + for(i = 0, prs = sh->prop; i < sh->prop_count; i++, prs++) { if (prs->atom != JS_ATOM_NULL) { pr = &p->prop[i]; if (!is_first) @@ -27001,7 +27118,7 @@ static void js_mapped_arguments_mark(JSRuntime *rt, JSValueConst val, int i; if (var_refs) { for(i = 0; i < p->u.array.count; i++) { - if (var_refs[i]) + if (var_refs[i] && var_refs[i]->is_detached) mark_func(rt, &var_refs[i]->header); } } @@ -27129,7 +27246,7 @@ static JSValue build_for_in_iterator(JSContext *ctx, JSValue obj) JSShapeProperty *prs; /* check that there are no enumerable normal fields */ sh = p->shape; - for(i = 0, prs = get_shape_prop(sh); i < sh->prop_count; i++, prs++) { + for(i = 0, prs = sh->prop; i < sh->prop_count; i++, prs++) { if (prs->flags & JS_PROP_ENUMERABLE) goto normal_case; } @@ -27221,7 +27338,7 @@ static __exception int js_for_in_next(JSContext *ctx, JSValue *sp) JSShapeProperty *prs; if (it->idx >= sh->prop_count) goto done; - prs = get_shape_prop(sh) + it->idx; + prs = &sh->prop[it->idx]; prop = prs->atom; it->idx++; if (prop == JS_ATOM_NULL || !(prs->flags & JS_PROP_ENUMERABLE)) @@ -28956,7 +29073,7 @@ DEF( typeof_is_function, 1, 1, 1, none) pc += 2; i = min_int(first, argc); n = argc - i; - *sp++ = js_create_array(ctx, n, &argv[i]); + *sp++ = js_create_array(ctx, n, n ? &argv[i] : NULL); if (unlikely(JS_IsException(sp[-1]))) goto exception; } @@ -29373,6 +29490,8 @@ DEF( typeof_is_function, 1, 1, 1, none) sp[-2] = js_regexp_constructor_internal(ctx, JS_UNDEFINED, sp[-2], sp[-1]); sp--; + if (JS_IsException(sp[-1])) + goto exception; } BREAK; @@ -32334,9 +32453,8 @@ static JSValue js_async_generator_resolve_function(JSContext *ctx, } else { js_async_generator_resolve(ctx, s, arg, true); } - } else { + } else if (s->state == JS_ASYNC_GENERATOR_STATE_EXECUTING) { /* restart function execution after await() */ - assert(s->state == JS_ASYNC_GENERATOR_STATE_EXECUTING); s->func_state.throw_flag = is_reject; if (is_reject) { JS_Throw(ctx, js_dup(arg)); @@ -34859,23 +34977,6 @@ static __exception int emit_push_const(JSParseState *s, JSValue val, return 0; } -// perl hash; variation of k&r hash with a different magic multiplier -// and a final shuffle to improve distribution of the low-order bits -static uint32_t hash_bytes(uint32_t h, const void *b, size_t n) -{ - const char *p; - - for (p = b; p < (char *)b + n; p++) - h = 33*h + *p; - h += h >> 5; - return h; -} - -static uint32_t hash_atom(JSAtom atom) -{ - return hash_bytes(0, &atom, sizeof(atom)); -} - // caveat emptor: the table size must be a power of two in order for // masking to work, and the load factor constant must be an odd number (5) // @@ -34905,7 +35006,7 @@ static int update_var_htab(JSContext *ctx, JSFunctionDef *fd) insert: m = UINT32_MAX >> clz32(m); do { - i = hash_atom(fd->vars[k].var_name); + i = hash32(fd->vars[k].var_name); j = 1; for (;;) { p = &fd->vars_htab[i & m]; @@ -34923,7 +35024,7 @@ static int find_var_htab(JSFunctionDef *fd, JSAtom var_name) { uint32_t i, j, m, *p; - i = hash_atom(var_name); + i = hash32(var_name); j = 1; m = fd->var_count + fd->var_count/5; m = UINT32_MAX >> clz32(m); @@ -35749,6 +35850,7 @@ static bool is_regexp_allowed(int tok) case TOK_FALSE: case TOK_TRUE: case TOK_THIS: + case TOK_PRIVATE_NAME: case ')': case ']': case '}': /* XXX: regexp may occur after */ @@ -39682,8 +39784,6 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, if (token_is_pseudo_keyword(s, JS_ATOM_of)) { is_for_of = true; - break_entry.has_iterator = true; - break_entry.drop_count += 2; if (has_initializer) goto initializer_error; } else if (s->token.val == TOK_IN) { @@ -39711,6 +39811,11 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, the TDZ values are in the closures */ close_scopes(s, s->cur_func->scope_level, block_scope_level); if (is_for_of) { + /* set has_iterator after the iterable expression is parsed so + that a yield in the expression does not try to close a + not-yet-created iterator */ + break_entry.has_iterator = true; + break_entry.drop_count += 2; if (is_async) emit_op(s, OP_for_await_of_start); else @@ -39731,7 +39836,8 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, int chunk_size = pos_expr - pos_next; int offset = bc->size - pos_next; int i; - dbuf_claim(bc, chunk_size); + if (dbuf_claim(bc, chunk_size)) + return -1; dbuf_put(bc, bc->buf + pos_next, chunk_size); memset(bc->buf + pos_next, OP_nop, chunk_size); /* `next` part ends with a goto */ @@ -40130,7 +40236,8 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, int chunk_size = pos_body - pos_cont; int offset = bc->size - pos_cont; int i; - dbuf_claim(bc, chunk_size); + if (dbuf_claim(bc, chunk_size)) + return -1; dbuf_put(bc, bc->buf + pos_cont, chunk_size); memset(bc->buf + pos_cont, OP_nop, chunk_size); /* increment part ends with a goto */ @@ -40803,7 +40910,8 @@ void JS_SetModuleLoaderFunc(JSRuntime *rt, JSModuleNormalizeFunc *module_normalize, JSModuleLoaderFunc *module_loader, void *opaque) { - rt->module_normalize_func = module_normalize; + rt->module_normalize_has_attr = false; + rt->normalize_u.module_normalize_func = module_normalize; rt->module_loader_has_attr = false; rt->u.module_loader_func = module_loader; rt->module_check_attrs = NULL; @@ -40816,13 +40924,21 @@ void JS_SetModuleLoaderFunc2(JSRuntime *rt, JSModuleCheckSupportedImportAttributes *module_check_attrs, void *opaque) { - rt->module_normalize_func = module_normalize; + rt->module_normalize_has_attr = false; + rt->normalize_u.module_normalize_func = module_normalize; rt->module_loader_has_attr = true; rt->u.module_loader_func2 = module_loader; rt->module_check_attrs = module_check_attrs; rt->module_loader_opaque = opaque; } +void JS_SetModuleNormalizeFunc2(JSRuntime *rt, + JSModuleNormalizeFunc2 *module_normalize) +{ + rt->module_normalize_has_attr = true; + rt->normalize_u.module_normalize_func2 = module_normalize; +} + int JS_SetModulePrivateValue(JSContext *ctx, JSModuleDef *m, JSValue val) { set_value(ctx, &m->private_value, val); @@ -40920,11 +41036,15 @@ static JSModuleDef *js_host_resolve_imported_module(JSContext *ctx, char *cname; JSAtom module_name; - if (!rt->module_normalize_func) { + if (!rt->normalize_u.module_normalize_func && !rt->normalize_u.module_normalize_func2) { cname = js_default_module_normalize_name(ctx, base_cname, cname1); + } else if (rt->module_normalize_has_attr) { + cname = rt->normalize_u.module_normalize_func2(ctx, base_cname, cname1, + attributes, + rt->module_loader_opaque); } else { - cname = rt->module_normalize_func(ctx, base_cname, cname1, - rt->module_loader_opaque); + cname = rt->normalize_u.module_normalize_func(ctx, base_cname, cname1, + rt->module_loader_opaque); } if (!cname) return NULL; @@ -48420,7 +48540,7 @@ typedef enum BCTagEnum { BC_TAG_SYMBOL, } BCTagEnum; -#define BC_VERSION 23 +#define BC_VERSION 24 typedef struct BCWriterState { JSContext *ctx; @@ -48486,22 +48606,16 @@ static void bc_put_u8(BCWriterState *s, uint8_t v) static void bc_put_u16(BCWriterState *s, uint16_t v) { - if (is_be()) - v = bswap16(v); dbuf_put_u16(&s->dbuf, v); } static __maybe_unused void bc_put_u32(BCWriterState *s, uint32_t v) { - if (is_be()) - v = bswap32(v); dbuf_put_u32(&s->dbuf, v); } static void bc_put_u64(BCWriterState *s, uint64_t v) { - if (is_be()) - v = bswap64(v); dbuf_put(&s->dbuf, (uint8_t *)&v, sizeof(v)); } @@ -48576,64 +48690,30 @@ static int bc_put_atom(BCWriterState *s, JSAtom atom) return 0; } -static void bc_byte_swap(uint8_t *bc_buf, int bc_len) +static uint32_t bc_csum(const uint8_t *p, size_t n) { - int pos, len, op, fmt; + uint32_t a, b, c, h; + size_t i; - pos = 0; - while (pos < bc_len) { - op = bc_buf[pos]; - len = short_opcode_info(op).size; - fmt = short_opcode_info(op).fmt; - switch(fmt) { - case OP_FMT_u16: - case OP_FMT_i16: - case OP_FMT_label16: - case OP_FMT_npop: - case OP_FMT_loc: - case OP_FMT_arg: - case OP_FMT_var_ref: - put_u16(bc_buf + pos + 1, - bswap16(get_u16(bc_buf + pos + 1))); - break; - case OP_FMT_i32: - case OP_FMT_u32: - case OP_FMT_const: - case OP_FMT_label: - case OP_FMT_atom: - case OP_FMT_atom_u8: - put_u32(bc_buf + pos + 1, - bswap32(get_u32(bc_buf + pos + 1))); - break; - case OP_FMT_atom_u16: - case OP_FMT_label_u16: - put_u32(bc_buf + pos + 1, - bswap32(get_u32(bc_buf + pos + 1))); - put_u16(bc_buf + pos + 1 + 4, - bswap16(get_u16(bc_buf + pos + 1 + 4))); - break; - case OP_FMT_atom_label_u8: - case OP_FMT_atom_label_u16: - put_u32(bc_buf + pos + 1, - bswap32(get_u32(bc_buf + pos + 1))); - put_u32(bc_buf + pos + 1 + 4, - bswap32(get_u32(bc_buf + pos + 1 + 4))); - if (fmt == OP_FMT_atom_label_u16) { - put_u16(bc_buf + pos + 1 + 4 + 4, - bswap16(get_u16(bc_buf + pos + 1 + 4 + 4))); - } - break; - case OP_FMT_npop_u16: - put_u16(bc_buf + pos + 1, - bswap16(get_u16(bc_buf + pos + 1))); - put_u16(bc_buf + pos + 1 + 2, - bswap16(get_u16(bc_buf + pos + 1 + 2))); - break; - default: - break; - } - pos += len; + h = 0; + for (i = 0; i+4 < n; i += 4) { + h += get_u32_le(p+i); + h *= 0x9e370001; } + a = b = c = 0; + switch (n-i) { + case 3: + c = (uint32_t)p[i+2]; + case 2: + b = (uint32_t)p[i+1]; + case 1: + a = (uint32_t)p[i+0]; + case 0: + break; + } + h += a | b<<8 | c<<16; + h *= 0x9e370001; + return h; } static int JS_WriteFunctionBytecode(BCWriterState *s, @@ -48671,9 +48751,6 @@ static int JS_WriteFunctionBytecode(BCWriterState *s, pos += len; } - if (is_be()) - bc_byte_swap(bc_buf, bc_len); - dbuf_put(&s->dbuf, bc_buf, bc_len); js_free(s->ctx, bc_buf); @@ -48945,7 +49022,7 @@ static int JS_WriteObjectTag(BCWriterState *s, JSValueConst obj) for(pass = 0; pass < 2; pass++) { if (pass == 1) bc_put_leb128(s, prop_count); - for(i = 0, pr = get_shape_prop(sh); i < sh->prop_count; i++, pr++) { + for(i = 0, pr = sh->prop; i < sh->prop_count; i++, pr++) { atom = pr->atom; if (atom != JS_ATOM_NULL && (pr->flags & JS_PROP_ENUMERABLE)) { if (pr->flags & JS_PROP_TMASK) { @@ -49017,17 +49094,8 @@ static int JS_WriteRegExp(BCWriterState *s, JSRegExp regexp) { JSString *bc = regexp.bytecode; assert(!bc->is_wide_char); - JS_WriteString(s, regexp.pattern); - - if (is_be()) - lre_byte_swap(str8(bc), bc->len, /*is_byte_swapped*/false); - JS_WriteString(s, bc); - - if (is_be()) - lre_byte_swap(str8(bc), bc->len, /*is_byte_swapped*/true); - return 0; } @@ -49076,11 +49144,14 @@ static int JS_WriteObjectRec(BCWriterState *s, JSValueConst obj) case JS_TAG_STRING_ROPE: { JSValue str; + int ret; str = JS_ToString(s->ctx, obj); if (JS_IsException(str)) goto fail; - JS_WriteObjectRec(s, str); + ret = JS_WriteObjectRec(s, str); JS_FreeValue(s->ctx, str); + if (ret) + goto fail; } break; case JS_TAG_FUNCTION_BYTECODE: @@ -49207,6 +49278,7 @@ static int JS_WriteObjectAtoms(BCWriterState *s) dbuf1 = s->dbuf; js_dbuf_init(s->ctx, &s->dbuf); bc_put_u8(s, BC_VERSION); + bc_put_u32(s, 0); // checksum, filled in after serialization bc_put_leb128(s, s->idx_to_atom_count); for(i = 0; i < s->idx_to_atom_count; i++) { @@ -49247,6 +49319,8 @@ uint8_t *JS_WriteObject2(JSContext *ctx, size_t *psize, JSValueConst obj, int flags, JSSABTab *psab_tab) { BCWriterState ss, *s = &ss; + uint32_t h; + DynBuf *d; memset(s, 0, sizeof(*s)); s->ctx = ctx; @@ -49277,7 +49351,11 @@ uint8_t *JS_WriteObject2(JSContext *ctx, size_t *psize, JSValueConst obj, } else { js_free(ctx, s->sab_tab); } - return s->dbuf.buf; + // don't include version and checksum fields in checksum + d = &s->dbuf; + h = bc_csum(&d->buf[5], d->size - 5); + put_u32_le(&d->buf[1], h); + return d->buf; fail: js_object_list_end(ctx, &s->object_list); js_free(ctx, s->atom_to_idx); @@ -49384,8 +49462,6 @@ static int bc_get_u16(BCReaderState *s, uint16_t *pval) return bc_read_error_end(s); } v = get_u16(s->ptr); - if (is_be()) - v = bswap16(v); *pval = v; s->ptr += 2; return 0; @@ -49399,8 +49475,6 @@ static __maybe_unused int bc_get_u32(BCReaderState *s, uint32_t *pval) return bc_read_error_end(s); } v = get_u32(s->ptr); - if (is_be()) - v = bswap32(v); *pval = v; s->ptr += 4; return 0; @@ -49414,8 +49488,6 @@ static int bc_get_u64(BCReaderState *s, uint64_t *pval) return bc_read_error_end(s); } v = get_u64(s->ptr); - if (is_be()) - v = bswap64(v); *pval = v; s->ptr += 8; return 0; @@ -49532,15 +49604,8 @@ static JSString *JS_ReadString(BCReaderState *s) } memcpy(str8(p), s->ptr, size); s->ptr += size; - if (is_wide_char) { - if (is_be()) { - uint32_t i; - for (i = 0; i < len; i++) - str16(p)[i] = bswap16(str16(p)[i]); - } - } else { + if (!is_wide_char) str8(p)[size] = '\0'; /* add the trailing zero for 8 bit strings */ - } #ifdef ENABLE_DUMPS // JS_DUMP_READ_OBJECT if (check_dump_flag(s->ctx->rt, JS_DUMP_READ_OBJECT)) { bc_read_trace(s, "%s", ""); // hex dump and indentation @@ -49573,9 +49638,6 @@ static int JS_ReadFunctionBytecode(BCReaderState *s, JSFunctionBytecode *b, return -1; b->byte_code_buf = bc_buf; - if (is_be()) - bc_byte_swap(bc_buf, bc_len); - pos = 0; while (pos < bc_len) { op = bc_buf[pos]; @@ -50279,9 +50341,6 @@ static JSValue JS_ReadRegExp(BCReaderState *s) return JS_ThrowInternalError(ctx, "bad regexp bytecode"); } - if (is_be()) - lre_byte_swap(str8(bc), bc->len, /*is_byte_swapped*/true); - return js_regexp_constructor_internal(ctx, JS_UNDEFINED, JS_MKPTR(JS_TAG_STRING, pattern), JS_MKPTR(JS_TAG_STRING, bc)); @@ -50478,6 +50537,7 @@ static int JS_ReadObjectAtoms(BCReaderState *s) { uint8_t v8, type; JSString *p; + uint32_t h; int i; JSAtom atom; @@ -50488,6 +50548,14 @@ static int JS_ReadObjectAtoms(BCReaderState *s) v8, BC_VERSION); return -1; } + if (bc_get_u32(s, &h)) + return -1; + // allow UINT32_MAX as an escape hatch, otherwise updating + // the test corpus in tests/test_bjson.js gets too tedious + if (h != UINT32_MAX && h != bc_csum(s->ptr, s->buf_end - s->ptr)) { + JS_ThrowSyntaxError(s->ctx, "checksum error"); + return -1; + } if (bc_get_leb128(s, &s->idx_to_atom_count)) return -1; if (s->idx_to_atom_count > 1000*1000) { @@ -50639,7 +50707,7 @@ static JSValue JS_InstantiateFunctionListItem2(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque) { const JSCFunctionListEntry *e = opaque; - JSValue val; + JSValue val, proto; switch(e->def_type) { case JS_DEF_CFUNC: @@ -50650,8 +50718,13 @@ static JSValue JS_InstantiateFunctionListItem2(JSContext *ctx, JSObject *p, val = JS_NewAtomString(ctx, e->u.str); break; case JS_DEF_OBJECT: - val = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, val, e->u.prop_list.tab, e->u.prop_list.len); + /* XXX: could add a flag */ + if (atom == JS_ATOM_Symbol_unscopables) + proto = JS_NULL; + else + proto = ctx->class_proto[JS_CLASS_OBJECT]; + val = JS_NewObjectProtoList(ctx, proto, + e->u.prop_list.tab, e->u.prop_list.len); break; default: abort(); @@ -50740,6 +50813,12 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj, case JS_DEF_PROP_UNDEFINED: val = JS_UNDEFINED; break; + case JS_DEF_PROP_SYMBOL: + val = JS_AtomToValue(ctx, e->u.i32); + break; + case JS_DEF_PROP_BOOL: + val = JS_NewBool(ctx, e->u.i32); + break; case JS_DEF_PROP_STRING: case JS_DEF_OBJECT: JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP, @@ -50808,8 +50887,8 @@ int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m, val = js_float64(e->u.f64); break; case JS_DEF_OBJECT: - val = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, val, e->u.prop_list.tab, e->u.prop_list.len); + val = JS_NewObjectProtoList(ctx, ctx->class_proto[JS_CLASS_OBJECT], + e->u.prop_list.tab, e->u.prop_list.len); break; default: abort(); @@ -50821,22 +50900,26 @@ int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m, } /* Note: 'func_obj' is not necessarily a constructor */ -static void JS_SetConstructor2(JSContext *ctx, - JSValueConst func_obj, - JSValueConst proto, - int proto_flags, int ctor_flags) +static int JS_SetConstructor2(JSContext *ctx, + JSValueConst func_obj, + JSValueConst proto, + int proto_flags, int ctor_flags) { - JS_DefinePropertyValue(ctx, func_obj, JS_ATOM_prototype, - js_dup(proto), proto_flags); - JS_DefinePropertyValue(ctx, proto, JS_ATOM_constructor, - js_dup(func_obj), ctor_flags); + if (JS_DefinePropertyValue(ctx, func_obj, JS_ATOM_prototype, + js_dup(proto), proto_flags) < 0) + return -1; + if (JS_DefinePropertyValue(ctx, proto, JS_ATOM_constructor, + js_dup(func_obj), ctor_flags) < 0) + return -1; + return 0; } -void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj, - JSValueConst proto) +/* return 0 if OK, -1 if exception */ +int JS_SetConstructor(JSContext *ctx, JSValueConst func_obj, + JSValueConst proto) { - JS_SetConstructor2(ctx, func_obj, proto, - 0, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); + return JS_SetConstructor2(ctx, func_obj, proto, + 0, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); } static void JS_NewGlobalCConstructor2(JSContext *ctx, @@ -50861,14 +50944,97 @@ static JSValue JS_NewGlobalCConstructor(JSContext *ctx, const char *name, return func_obj; } -static JSValue JS_NewGlobalCConstructorOnly(JSContext *ctx, const char *name, - JSCFunction *func, int length, - JSValue proto) +static JSValue JS_NewObjectProtoList(JSContext *ctx, JSValueConst proto, + const JSCFunctionListEntry *fields, int n_fields) { - JSValue func_obj; - func_obj = JS_NewCFunction2(ctx, func, name, length, JS_CFUNC_constructor, 0); - JS_NewGlobalCConstructor2(ctx, func_obj, name, proto); - return func_obj; + JSValue obj; + obj = JS_NewObjectProtoClassAlloc(ctx, proto, JS_CLASS_OBJECT, n_fields); + if (JS_IsException(obj)) + return obj; + if (JS_SetPropertyFunctionList(ctx, obj, fields, n_fields)) { + JS_FreeValue(ctx, obj); + return JS_EXCEPTION; + } + return obj; +} + +#define JS_NEW_CTOR_NO_GLOBAL (1 << 0) /* don't create a global binding */ +#define JS_NEW_CTOR_PROTO_CLASS (1 << 1) /* the prototype class is 'class_id' instead of JS_CLASS_OBJECT */ +#define JS_NEW_CTOR_PROTO_EXIST (1 << 2) /* the prototype is already defined */ +#define JS_NEW_CTOR_READONLY (1 << 3) /* read-only constructor field */ + +/* Return the constructor. Define it as a global variable unless + JS_NEW_CTOR_NO_GLOBAL is set. The new class inherits from + parent_ctor if it is not JS_UNDEFINED. If class_id is >= 0, + class_proto[class_id] is set. */ +static JSValue JS_NewCConstructor(JSContext *ctx, int class_id, const char *name, + JSCFunction *func, int length, JSCFunctionEnum cproto, int magic, + JSValueConst parent_ctor, + const JSCFunctionListEntry *ctor_fields, int n_ctor_fields, + const JSCFunctionListEntry *proto_fields, int n_proto_fields, + int flags) +{ + JSValue ctor = JS_UNDEFINED, proto, parent_proto; + int proto_class_id, proto_flags, ctor_flags; + + proto_flags = 0; + if (flags & JS_NEW_CTOR_READONLY) { + ctor_flags = JS_PROP_CONFIGURABLE; + } else { + ctor_flags = JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE; + } + + if (JS_IsUndefined(parent_ctor)) { + parent_proto = js_dup(ctx->class_proto[JS_CLASS_OBJECT]); + parent_ctor = ctx->function_proto; + } else { + parent_proto = JS_GetProperty(ctx, parent_ctor, JS_ATOM_prototype); + if (JS_IsException(parent_proto)) + return JS_EXCEPTION; + } + + if (flags & JS_NEW_CTOR_PROTO_EXIST) { + proto = js_dup(ctx->class_proto[class_id]); + } else { + if (flags & JS_NEW_CTOR_PROTO_CLASS) + proto_class_id = class_id; + else + proto_class_id = JS_CLASS_OBJECT; + /* one additional field: constructor */ + proto = JS_NewObjectProtoClassAlloc(ctx, parent_proto, proto_class_id, + n_proto_fields + 1); + if (JS_IsException(proto)) + goto fail; + if (class_id >= 0) + ctx->class_proto[class_id] = js_dup(proto); + } + if (JS_SetPropertyFunctionList(ctx, proto, proto_fields, n_proto_fields)) + goto fail; + + /* additional fields: name, length, prototype */ + ctor = JS_NewCFunction3(ctx, func, name, length, cproto, magic, parent_ctor, + n_ctor_fields + 3); + if (JS_IsException(ctor)) + goto fail; + if (JS_SetPropertyFunctionList(ctx, ctor, ctor_fields, n_ctor_fields)) + goto fail; + if (!(flags & JS_NEW_CTOR_NO_GLOBAL)) { + if (JS_DefinePropertyValueStr(ctx, ctx->global_obj, name, + js_dup(ctor), + JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE) < 0) + goto fail; + } + if (JS_SetConstructor2(ctx, ctor, proto, proto_flags, ctor_flags)) + goto fail; + + JS_FreeValue(ctx, proto); + JS_FreeValue(ctx, parent_proto); + return ctor; + fail: + JS_FreeValue(ctx, proto); + JS_FreeValue(ctx, parent_proto); + JS_FreeValue(ctx, ctor); + return JS_EXCEPTION; } static JSValue js_global_eval(JSContext *ctx, JSValueConst this_val, @@ -53972,7 +54138,7 @@ static JSValue js_array_push(JSContext *ctx, JSValueConst this_val, ctx->std_array_prototype)) { uint32_t array_len, new_len; if (likely(JS_VALUE_GET_TAG(p->prop[0].u.value) == JS_TAG_INT && - (get_shape_prop(p->shape)->flags & JS_PROP_WRITABLE))) { + (p->shape->prop->flags & JS_PROP_WRITABLE))) { array_len = JS_VALUE_GET_INT(p->prop[0].u.value); new_len = array_len + argc; if (likely(new_len >= array_len)) { /* no overflow */ @@ -55071,7 +55237,7 @@ static JSValue js_iterator_concat_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { JSIteratorConcatData *it; - JSValue ret; + JSValue ret, *pval; it = JS_GetOpaque2(ctx, this_val, JS_CLASS_ITERATOR_CONCAT); if (!it) @@ -55087,8 +55253,11 @@ static JSValue js_iterator_concat_return(JSContext *ctx, JSValueConst this_val, ret = JS_CallFree(ctx, ret, it->iter, 0, NULL); it->running = false; } - while (it->index < it->count) - JS_FreeValue(ctx, it->values[it->index++]); + while (it->index < it->count) { + pval = &it->values[it->index++]; + JS_FreeValue(ctx, *pval); + *pval = JS_UNDEFINED; + } JS_FreeValue(ctx, it->iter); JS_FreeValue(ctx, it->next); it->iter = JS_UNDEFINED; @@ -55822,6 +55991,7 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValueConst this_val, args[1] = index_val; ret = JS_Call(ctx, it->func, JS_UNDEFINED, countof(args), args); JS_FreeValue(ctx, index_val); + JS_FreeValue(ctx, item); if (JS_IsException(ret)) goto fail; goto done; @@ -55897,6 +56067,25 @@ static const JSCFunctionListEntry js_iterator_helper_proto_funcs[] = { JS_PROP_STRING_DEF("[Symbol.toStringTag]", "Iterator Helper", JS_PROP_CONFIGURABLE ), }; +static const JSCFunctionListEntry js_array_unscopables_funcs[] = { + JS_PROP_BOOL_DEF("at", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("copyWithin", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("entries", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("fill", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("find", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("findIndex", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("findLast", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("findLastIndex", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("flat", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("flatMap", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("includes", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("keys", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("toReversed", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("toSorted", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("toSpliced", 1, JS_PROP_C_W_E), + JS_PROP_BOOL_DEF("values", 1, JS_PROP_C_W_E), +}; + static const JSCFunctionListEntry js_array_proto_funcs[] = { JS_CFUNC_DEF("at", 1, js_array_at ), JS_CFUNC_DEF("with", 2, js_array_with ), @@ -55937,6 +56126,7 @@ static const JSCFunctionListEntry js_array_proto_funcs[] = { JS_ALIAS_DEF("[Symbol.iterator]", "values" ), JS_CFUNC_MAGIC_DEF("keys", 0, js_create_array_iterator, JS_ITERATOR_KIND_KEY ), JS_CFUNC_MAGIC_DEF("entries", 0, js_create_array_iterator, JS_ITERATOR_KIND_KEY_AND_VALUE ), + JS_OBJECT_DEF("[Symbol.unscopables]", js_array_unscopables_funcs, countof(js_array_unscopables_funcs), JS_PROP_CONFIGURABLE ), }; static const JSCFunctionListEntry js_array_iterator_proto_funcs[] = { @@ -56673,12 +56863,48 @@ static JSValue js_string_codePointAt(JSContext *ctx, JSValueConst this_val, static JSValue js_string_concat(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + int i, is_wide_char; + JSString *p, *q; + int64_t len; + uint32_t n; JSValue r; - int i; + char *d; - /* XXX: Use more efficient method */ - /* XXX: This method is OK if r has a single refcount */ - /* XXX: should use string_buffer? */ + if (JS_TAG_STRING != JS_VALUE_GET_TAG(this_val)) + goto slow_path; + p = JS_VALUE_GET_STRING(this_val); + len = p->len; + is_wide_char = p->is_wide_char; + for (i = 0; i < argc; i++) { + if (JS_TAG_STRING != JS_VALUE_GET_TAG(argv[i])) + goto slow_path; + p = JS_VALUE_GET_STRING(argv[i]); + if (p->is_wide_char ^ is_wide_char) + goto slow_path; + len += p->len; + } + if (len > INT_MAX>>is_wide_char) + return JS_ThrowOutOfMemory(ctx); + p = JS_VALUE_GET_STRING(this_val); + if (p->len == len) + return js_dup(this_val); + q = js_alloc_string(ctx, len, is_wide_char); + if (!q) + return JS_EXCEPTION; + d = strv(q); + n = p->len << is_wide_char; + memcpy(d, strv(p), n); + d += n; + for (i = 0; i < argc; i++) { + p = JS_VALUE_GET_STRING(argv[i]); + n = p->len << is_wide_char; + memcpy(d, strv(p), n); + d += n; + } + if (!is_wide_char) + *d = '\0'; + return JS_MKPTR(JS_TAG_STRING, q); +slow_path: r = JS_ToStringCheckObject(ctx, this_val); for (i = 0; i < argc; i++) { if (JS_IsException(r)) @@ -58720,27 +58946,36 @@ static JSValue js_regexp_constructor_internal(JSContext *ctx, JSValueConst ctor, JSValue obj; JSObject *p; JSRegExp *re; + JSProperty prop; /* sanity check */ if (JS_VALUE_GET_TAG(bc) != JS_TAG_STRING || JS_VALUE_GET_TAG(pattern) != JS_TAG_STRING) { JS_ThrowTypeError(ctx, "string expected"); - fail: - JS_FreeValue(ctx, bc); - JS_FreeValue(ctx, pattern); - return JS_EXCEPTION; - } - - obj = js_create_from_ctor(ctx, ctor, JS_CLASS_REGEXP); - if (JS_IsException(obj)) goto fail; + } + prop.u.value = js_int32(0); // lastIndex + if (ctx->regexp_shape && JS_IsUndefined(ctor)) { + obj = JS_NewObjectFromShape(ctx, js_dup_shape(ctx->regexp_shape), + JS_CLASS_REGEXP, &prop); + if (JS_IsException(obj)) + goto fail; + } else { + obj = js_create_from_ctor(ctx, ctor, JS_CLASS_REGEXP); + if (JS_IsException(obj)) + goto fail; + JS_DefinePropertyValue(ctx, obj, JS_ATOM_lastIndex, prop.u.value, + JS_PROP_WRITABLE); + } p = JS_VALUE_GET_OBJ(obj); re = &p->u.regexp; re->pattern = JS_VALUE_GET_STRING(pattern); re->bytecode = JS_VALUE_GET_STRING(bc); - JS_DefinePropertyValue(ctx, obj, JS_ATOM_lastIndex, js_int32(0), - JS_PROP_WRITABLE); return obj; +fail: + JS_FreeValue(ctx, bc); + JS_FreeValue(ctx, pattern); + return JS_EXCEPTION; } static JSRegExp *js_get_regexp(JSContext *ctx, JSValueConst obj, @@ -59132,15 +59367,16 @@ static JSValue js_regexp_escape(JSContext *ctx, JSValueConst this_val, static JSValue js_regexp_exec(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + int rc, capture_count, shift, index, i, re_flags, prop_flags; JSRegExp *re = js_get_regexp(ctx, this_val, true); JSString *str; JSValue t, ret, str_val, obj, val, groups; JSValue indices, indices_groups; uint8_t *re_bytecode; uint8_t **capture, *str_buf; - int rc, capture_count, shift, i, re_flags; int64_t last_index; const char *group_name_ptr; + JSProperty props[4]; // length, index, input, groups, in that order if (!re) return JS_EXCEPTION; @@ -59189,24 +59425,27 @@ static JSValue js_regexp_exec(JSContext *ctx, JSValueConst this_val, goto fail; } } else { - if (rc == LRE_RET_TIMEOUT) { + switch(rc) { + case LRE_RET_TIMEOUT: JS_ThrowInterrupted(ctx); - } else { + break; + case LRE_RET_MEMORY_ERROR: JS_ThrowInternalError(ctx, "out of memory in regexp execution"); + break; + case LRE_RET_BYTECODE_ERROR: + JS_ThrowInternalError(ctx, "corrupted bytecode in regexp execution"); + break; + default: + abort(); } goto fail; } } else { - int prop_flags; if (re_flags & (LRE_FLAG_GLOBAL | LRE_FLAG_STICKY)) { if (JS_SetProperty(ctx, this_val, JS_ATOM_lastIndex, js_int32((capture[1] - str_buf) >> shift)) < 0) goto fail; } - obj = JS_NewArray(ctx); - if (JS_IsException(obj)) - goto fail; - prop_flags = JS_PROP_C_W_E | JS_PROP_THROW; group_name_ptr = lre_get_groupnames(re_bytecode); if (group_name_ptr) { groups = JS_NewObjectProto(ctx, JS_NULL); @@ -59223,7 +59462,17 @@ static JSValue js_regexp_exec(JSContext *ctx, JSValueConst this_val, goto fail; } } - + index = (capture[0] - str_buf) >> shift; + props[0].u.value = js_int32(capture_count); // length + props[1].u.value = js_int32(index); // index + props[2].u.value = str_val; // input + props[3].u.value = js_dup(groups); // groups + str_val = JS_UNDEFINED; + obj = JS_NewObjectFromShape(ctx, js_dup_shape(ctx->regexp_result_shape), + JS_CLASS_ARRAY, props); + if (JS_IsException(obj)) + goto fail; + prop_flags = JS_PROP_C_W_E | JS_PROP_THROW; for(i = 0; i < capture_count; i++) { const char *name = NULL; uint8_t **match = &capture[2 * i]; @@ -59293,20 +59542,6 @@ static JSValue js_regexp_exec(JSContext *ctx, JSValueConst this_val, goto fail; } - t = groups, groups = JS_UNDEFINED; - if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_groups, - t, prop_flags) < 0) { - goto fail; - } - - t = js_int32((capture[0] - str_buf) >> shift); - if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_index, t, prop_flags) < 0) - goto fail; - - t = str_val, str_val = JS_UNDEFINED; - if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_input, t, prop_flags) < 0) - goto fail; - if (!JS_IsUndefined(indices)) { t = indices_groups, indices_groups = JS_UNDEFINED; if (JS_DefinePropertyValue(ctx, indices, JS_ATOM_groups, @@ -59388,10 +59623,18 @@ static JSValue JS_RegExpDelete(JSContext *ctx, JSValueConst this_val, JSValue ar goto fail; } } else { - if (ret == LRE_RET_TIMEOUT) { + switch(ret) { + case LRE_RET_TIMEOUT: JS_ThrowInterrupted(ctx); - } else { + break; + case LRE_RET_MEMORY_ERROR: JS_ThrowInternalError(ctx, "out of memory in regexp execution"); + break; + case LRE_RET_BYTECODE_ERROR: + JS_ThrowInternalError(ctx, "corrupted bytecode in regexp execution"); + break; + default: + abort(); } goto fail; } @@ -60202,25 +60445,55 @@ void JS_AddIntrinsicRegExpCompiler(JSContext *ctx) ctx->compile_regexp = js_compile_regexp; } -void JS_AddIntrinsicRegExp(JSContext *ctx) +int JS_AddIntrinsicRegExp(JSContext *ctx) { - JSValue obj; + JSValue proto, obj; - JS_AddIntrinsicRegExpCompiler(ctx); - - ctx->class_proto[JS_CLASS_REGEXP] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_REGEXP], js_regexp_proto_funcs, - countof(js_regexp_proto_funcs)); + proto = ctx->class_proto[JS_CLASS_REGEXP] = JS_NewObject(ctx); + if (JS_IsException(proto)) + return -1; + if (JS_SetPropertyFunctionList(ctx, proto, js_regexp_proto_funcs, + countof(js_regexp_proto_funcs))) { + return -1; + } obj = JS_NewGlobalCConstructor(ctx, "RegExp", js_regexp_constructor, 2, - ctx->class_proto[JS_CLASS_REGEXP]); + proto); + if (JS_IsException(obj)) + return -1; ctx->regexp_ctor = js_dup(obj); - JS_SetPropertyFunctionList(ctx, obj, js_regexp_funcs, countof(js_regexp_funcs)); - - ctx->class_proto[JS_CLASS_REGEXP_STRING_ITERATOR] = + if (JS_SetPropertyFunctionList(ctx, obj, js_regexp_funcs, + countof(js_regexp_funcs))) { + return -1; + } + static const JSShapeProperty regexp_props[] = { + {.atom=JS_ATOM_lastIndex, .flags=JS_PROP_WRITABLE}, + }; + static const JSShapeProperty regexp_result_props[] = { + {.atom=JS_ATOM_length, .flags=JS_PROP_WRITABLE|JS_PROP_LENGTH}, + {.atom=JS_ATOM_index, .flags=JS_PROP_C_W_E}, + {.atom=JS_ATOM_input, .flags=JS_PROP_C_W_E}, + {.atom=JS_ATOM_groups, .flags=JS_PROP_C_W_E}, + }; + if (js_new_shape_with(ctx, &ctx->regexp_shape, proto, + countof(regexp_props), regexp_props)) { + return -1; + } + if (js_new_shape_with(ctx, &ctx->regexp_result_shape, + ctx->class_proto[JS_CLASS_ARRAY], + countof(regexp_result_props), regexp_result_props)) { + return -1; + } + proto = ctx->class_proto[JS_CLASS_REGEXP_STRING_ITERATOR] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_REGEXP_STRING_ITERATOR], - js_regexp_string_iterator_proto_funcs, - countof(js_regexp_string_iterator_proto_funcs)); + if (JS_IsException(proto)) + return -1; + if (JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_REGEXP_STRING_ITERATOR], + js_regexp_string_iterator_proto_funcs, + countof(js_regexp_string_iterator_proto_funcs))) { + return -1; + } + JS_AddIntrinsicRegExpCompiler(ctx); + return 0; } /* JSON */ @@ -60893,10 +61166,10 @@ static const JSCFunctionListEntry js_json_obj[] = { JS_OBJECT_DEF("JSON", js_json_funcs, countof(js_json_funcs), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ), }; -void JS_AddIntrinsicJSON(JSContext *ctx) +int JS_AddIntrinsicJSON(JSContext *ctx) { /* add JSON as autoinit object */ - JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_json_obj, countof(js_json_obj)); + return JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_json_obj, countof(js_json_obj)); } /* Reflect */ @@ -62009,25 +62282,36 @@ static const JSClassShortDef js_proxy_class_def[] = { { JS_ATOM_Object, js_proxy_finalizer, js_proxy_mark }, /* JS_CLASS_PROXY */ }; -void JS_AddIntrinsicProxy(JSContext *ctx) +int JS_AddIntrinsicProxy(JSContext *ctx) { JSRuntime *rt = ctx->rt; JSValue obj1; if (!JS_IsRegisteredClass(rt, JS_CLASS_PROXY)) { - init_class_range(rt, js_proxy_class_def, JS_CLASS_PROXY, - countof(js_proxy_class_def)); + if (init_class_range(rt, js_proxy_class_def, JS_CLASS_PROXY, + countof(js_proxy_class_def))) + return -1; rt->class_array[JS_CLASS_PROXY].exotic = &js_proxy_exotic_methods; rt->class_array[JS_CLASS_PROXY].call = js_proxy_call; } - obj1 = JS_NewCFunction2(ctx, js_proxy_constructor, "Proxy", 2, - JS_CFUNC_constructor, 0); + /* additional fields: name, length */ + obj1 = JS_NewCFunction3(ctx, js_proxy_constructor, "Proxy", 2, + JS_CFUNC_constructor, 0, + ctx->function_proto, countof(js_proxy_funcs) + 2); + if (JS_IsException(obj1)) + return -1; JS_SetConstructorBit(ctx, obj1, true); - JS_SetPropertyFunctionList(ctx, obj1, js_proxy_funcs, - countof(js_proxy_funcs)); - JS_DefinePropertyValueStr(ctx, ctx->global_obj, "Proxy", - obj1, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); + if (JS_SetPropertyFunctionList(ctx, obj1, js_proxy_funcs, + countof(js_proxy_funcs))) + goto fail; + if (JS_DefinePropertyValueStr(ctx, ctx->global_obj, "Proxy", + obj1, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE) < 0) + goto fail; + return 0; + fail: + JS_FreeValue(ctx, obj1); + return -1; } bool JS_IsProxy(JSValueConst val) @@ -62173,6 +62457,19 @@ static JSValue js_symbol_keyFor(JSContext *ctx, JSValueConst this_val, static const JSCFunctionListEntry js_symbol_funcs[] = { JS_CFUNC_DEF("for", 1, js_symbol_for ), JS_CFUNC_DEF("keyFor", 1, js_symbol_keyFor ), + JS_PROP_SYMBOL_DEF("toPrimitive", JS_ATOM_Symbol_toPrimitive, 0), + JS_PROP_SYMBOL_DEF("iterator", JS_ATOM_Symbol_iterator, 0), + JS_PROP_SYMBOL_DEF("match", JS_ATOM_Symbol_match, 0), + JS_PROP_SYMBOL_DEF("matchAll", JS_ATOM_Symbol_matchAll, 0), + JS_PROP_SYMBOL_DEF("replace", JS_ATOM_Symbol_replace, 0), + JS_PROP_SYMBOL_DEF("search", JS_ATOM_Symbol_search, 0), + JS_PROP_SYMBOL_DEF("split", JS_ATOM_Symbol_split, 0), + JS_PROP_SYMBOL_DEF("toStringTag", JS_ATOM_Symbol_toStringTag, 0), + JS_PROP_SYMBOL_DEF("isConcatSpreadable", JS_ATOM_Symbol_isConcatSpreadable, 0), + JS_PROP_SYMBOL_DEF("hasInstance", JS_ATOM_Symbol_hasInstance, 0), + JS_PROP_SYMBOL_DEF("species", JS_ATOM_Symbol_species, 0), + JS_PROP_SYMBOL_DEF("unscopables", JS_ATOM_Symbol_unscopables, 0), + JS_PROP_SYMBOL_DEF("asyncIterator", JS_ATOM_Symbol_asyncIterator, 0), }; /* Set/Map/WeakSet/WeakMap */ @@ -63707,37 +64004,50 @@ static const uint8_t js_map_proto_funcs_count[6] = { countof(js_set_iterator_proto_funcs), }; -void JS_AddIntrinsicMapSet(JSContext *ctx) +int JS_AddIntrinsicMapSet(JSContext *ctx) { int i; JSValue obj1; char buf[ATOM_GET_STR_BUF_SIZE]; + /* Used to squelch a -Wcast-function-type warning. */ + JSCFunctionType ft = { .constructor_magic = js_map_constructor }; for(i = 0; i < 4; i++) { const char *name = JS_AtomGetStr(ctx, buf, sizeof(buf), JS_ATOM_Map + i); int class_id = JS_CLASS_MAP + i; - ctx->class_proto[class_id] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[class_id], - js_map_proto_funcs_ptr[i], - js_map_proto_funcs_count[i]); - obj1 = JS_NewCFunctionMagic(ctx, js_map_constructor, name, 0, - JS_CFUNC_constructor_magic, i); - if (class_id == JS_CLASS_MAP) - JS_SetPropertyFunctionList(ctx, obj1, js_map_funcs, countof(js_map_funcs)); - else if (class_id == JS_CLASS_SET) - JS_SetPropertyFunctionList(ctx, obj1, js_set_funcs, countof(js_set_funcs)); - - JS_NewGlobalCConstructor2(ctx, obj1, name, ctx->class_proto[class_id]); + const JSCFunctionListEntry *ctor_funcs; + int n_ctor_funcs; + if (class_id == JS_CLASS_MAP) { + ctor_funcs = js_map_funcs; + n_ctor_funcs = countof(js_map_funcs); + } else if (class_id == JS_CLASS_SET) { + ctor_funcs = js_set_funcs; + n_ctor_funcs = countof(js_set_funcs); + } else { + ctor_funcs = NULL; + n_ctor_funcs = 0; + } + obj1 = JS_NewCConstructor(ctx, class_id, name, + ft.generic, 0, JS_CFUNC_constructor_magic, i, + JS_UNDEFINED, + ctor_funcs, n_ctor_funcs, + js_map_proto_funcs_ptr[i], js_map_proto_funcs_count[i], + 0); + if (JS_IsException(obj1)) + return -1; + JS_FreeValue(ctx, obj1); } for(i = 0; i < 2; i++) { ctx->class_proto[JS_CLASS_MAP_ITERATOR + i] = - JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_MAP_ITERATOR + i], - js_map_proto_funcs_ptr[i + 4], - js_map_proto_funcs_count[i + 4]); + JS_NewObjectProtoList(ctx, ctx->class_proto[JS_CLASS_ITERATOR], + js_map_proto_funcs_ptr[i + 4], + js_map_proto_funcs_count[i + 4]); + if (JS_IsException(ctx->class_proto[JS_CLASS_MAP_ITERATOR + i])) + return -1; } + return 0; } /* Generator */ @@ -63801,6 +64111,11 @@ bool JS_IsPromise(JSValueConst val) return JS_VALUE_GET_OBJ(val)->class_id == JS_CLASS_PROMISE; } +JSValue JS_NewSettledPromise(JSContext *ctx, bool is_reject, JSValueConst value) +{ + return js_promise_resolve(ctx, ctx->promise_ctor, 1, &value, is_reject); +} + static int js_create_resolving_functions(JSContext *ctx, JSValue *args, JSValueConst promise); @@ -64131,33 +64446,33 @@ static void js_promise_mark(JSRuntime *rt, JSValueConst val, JS_MarkValue(rt, s->promise_result, mark_func); } -static JSValue js_promise_constructor(JSContext *ctx, JSValueConst new_target, - int argc, JSValueConst *argv) +/* Create a new promise object with resolving functions. Returns the promise + and sets resolving_funcs[0] (resolve) and resolving_funcs[1] (reject). */ +static JSValue js_promise_new(JSContext *ctx, JSValueConst new_target, + JSValue *resolving_funcs) { - JSValueConst executor; JSValue obj; JSPromiseData *s; JSRuntime *rt; - JSValue args[2], ret; - int i; - executor = argv[0]; - if (check_function(ctx, executor)) - return JS_EXCEPTION; obj = js_create_from_ctor(ctx, new_target, JS_CLASS_PROMISE); if (JS_IsException(obj)) return JS_EXCEPTION; s = js_mallocz(ctx, sizeof(*s)); - if (!s) - goto fail; + if (!s) { + JS_FreeValue(ctx, obj); + return JS_EXCEPTION; + } s->promise_state = JS_PROMISE_PENDING; s->is_handled = false; - for(i = 0; i < 2; i++) - init_list_head(&s->promise_reactions[i]); + init_list_head(&s->promise_reactions[0]); + init_list_head(&s->promise_reactions[1]); s->promise_result = JS_UNDEFINED; JS_SetOpaqueInternal(obj, s); - if (js_create_resolving_functions(ctx, args, obj)) - goto fail; + if (js_create_resolving_functions(ctx, resolving_funcs, obj)) { + JS_FreeValue(ctx, obj); + return JS_EXCEPTION; + } rt = ctx->rt; if (rt->promise_hook) { JSValueConst parent_promise = JS_UNDEFINED; @@ -64166,6 +64481,22 @@ static JSValue js_promise_constructor(JSContext *ctx, JSValueConst new_target, rt->promise_hook(ctx, JS_PROMISE_HOOK_INIT, obj, parent_promise, rt->promise_hook_opaque); } + return obj; +} + +static JSValue js_promise_constructor(JSContext *ctx, JSValueConst new_target, + int argc, JSValueConst *argv) +{ + JSValueConst executor; + JSValue obj; + JSValue args[2], ret; + + executor = argv[0]; + if (check_function(ctx, executor)) + return JS_EXCEPTION; + obj = js_promise_new(ctx, new_target, args); + if (JS_IsException(obj)) + return JS_EXCEPTION; ret = JS_Call(ctx, executor, JS_UNDEFINED, 2, vc(args)); if (JS_IsException(ret)) { JSValue ret2, error; @@ -64173,17 +64504,16 @@ static JSValue js_promise_constructor(JSContext *ctx, JSValueConst new_target, ret2 = JS_Call(ctx, args[1], JS_UNDEFINED, 1, vc(&error)); JS_FreeValue(ctx, error); if (JS_IsException(ret2)) - goto fail1; + goto fail; JS_FreeValue(ctx, ret2); } JS_FreeValue(ctx, ret); JS_FreeValue(ctx, args[0]); JS_FreeValue(ctx, args[1]); return obj; - fail1: + fail: JS_FreeValue(ctx, args[0]); JS_FreeValue(ctx, args[1]); - fail: JS_FreeValue(ctx, obj); return JS_EXCEPTION; } @@ -64221,14 +64551,12 @@ static JSValue js_new_promise_capability(JSContext *ctx, JSCFunctionDataRecord *s; int i; + if (JS_IsUndefined(ctor) || js_same_value(ctx, ctor, ctx->promise_ctor)) + return js_promise_new(ctx, JS_UNDEFINED, resolving_funcs); executor = js_promise_executor_new(ctx); if (JS_IsException(executor)) return JS_EXCEPTION; - if (JS_IsUndefined(ctor)) { - result_promise = js_promise_constructor(ctx, ctor, 1, vc(&executor)); - } else { - result_promise = JS_CallConstructor(ctx, ctor, 1, vc(&executor)); - } + result_promise = JS_CallConstructor(ctx, ctor, 1, vc(&executor)); if (JS_IsException(result_promise)) goto fail; s = JS_GetOpaque(executor, JS_CLASS_C_FUNCTION_DATA); @@ -65082,14 +65410,16 @@ static JSClassShortDef const js_async_class_def[] = { { JS_ATOM_AsyncGenerator, js_async_generator_finalizer, js_async_generator_mark }, /* JS_CLASS_ASYNC_GENERATOR */ }; -void JS_AddIntrinsicPromise(JSContext *ctx) +int JS_AddIntrinsicPromise(JSContext *ctx) { JSRuntime *rt = ctx->rt; JSValue obj1; + JSCFunctionType ft; if (!JS_IsRegisteredClass(rt, JS_CLASS_PROMISE)) { - init_class_range(rt, js_async_class_def, JS_CLASS_PROMISE, - countof(js_async_class_def)); + if (init_class_range(rt, js_async_class_def, JS_CLASS_PROMISE, + countof(js_async_class_def))) + return -1; rt->class_array[JS_CLASS_PROMISE_RESOLVE_FUNCTION].call = js_promise_resolve_function_call; rt->class_array[JS_CLASS_PROMISE_REJECT_FUNCTION].call = js_promise_resolve_function_call; rt->class_array[JS_CLASS_ASYNC_FUNCTION].call = js_async_function_call; @@ -65099,77 +65429,67 @@ void JS_AddIntrinsicPromise(JSContext *ctx) } /* Promise */ - ctx->class_proto[JS_CLASS_PROMISE] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_PROMISE], - js_promise_proto_funcs, - countof(js_promise_proto_funcs)); - obj1 = JS_NewCFunction2(ctx, js_promise_constructor, "Promise", 1, - JS_CFUNC_constructor, 0); - ctx->promise_ctor = js_dup(obj1); - JS_SetPropertyFunctionList(ctx, obj1, - js_promise_funcs, - countof(js_promise_funcs)); - JS_NewGlobalCConstructor2(ctx, obj1, "Promise", - ctx->class_proto[JS_CLASS_PROMISE]); - - /* Used to squelch a -Wcast-function-type warning. */ - JSCFunctionType ft; + obj1 = JS_NewCConstructor(ctx, JS_CLASS_PROMISE, "Promise", + js_promise_constructor, 1, JS_CFUNC_constructor, 0, + JS_UNDEFINED, + js_promise_funcs, countof(js_promise_funcs), + js_promise_proto_funcs, countof(js_promise_proto_funcs), + 0); + if (JS_IsException(obj1)) + return -1; + ctx->promise_ctor = obj1; /* AsyncFunction */ - ctx->class_proto[JS_CLASS_ASYNC_FUNCTION] = JS_NewObjectProto(ctx, ctx->function_proto); ft.generic_magic = js_function_constructor; - obj1 = JS_NewCFunction3(ctx, ft.generic, - "AsyncFunction", 1, - JS_CFUNC_constructor_or_func_magic, JS_FUNC_ASYNC, - ctx->function_ctor); - JS_SetPropertyFunctionList(ctx, - ctx->class_proto[JS_CLASS_ASYNC_FUNCTION], - js_async_function_proto_funcs, - countof(js_async_function_proto_funcs)); - JS_SetConstructor2(ctx, obj1, ctx->class_proto[JS_CLASS_ASYNC_FUNCTION], - 0, JS_PROP_CONFIGURABLE); + obj1 = JS_NewCConstructor(ctx, JS_CLASS_ASYNC_FUNCTION, "AsyncFunction", + ft.generic, 1, JS_CFUNC_constructor_or_func_magic, JS_FUNC_ASYNC, + ctx->function_ctor, + NULL, 0, + js_async_function_proto_funcs, countof(js_async_function_proto_funcs), + JS_NEW_CTOR_NO_GLOBAL | JS_NEW_CTOR_READONLY); + if (JS_IsException(obj1)) + return -1; JS_FreeValue(ctx, obj1); /* AsyncIteratorPrototype */ - ctx->async_iterator_proto = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->async_iterator_proto, - js_async_iterator_proto_funcs, - countof(js_async_iterator_proto_funcs)); + ctx->async_iterator_proto = + JS_NewObjectProtoList(ctx, ctx->class_proto[JS_CLASS_OBJECT], + js_async_iterator_proto_funcs, + countof(js_async_iterator_proto_funcs)); + if (JS_IsException(ctx->async_iterator_proto)) + return -1; /* AsyncFromSyncIteratorPrototype */ ctx->class_proto[JS_CLASS_ASYNC_FROM_SYNC_ITERATOR] = - JS_NewObjectProto(ctx, ctx->async_iterator_proto); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ASYNC_FROM_SYNC_ITERATOR], - js_async_from_sync_iterator_proto_funcs, - countof(js_async_from_sync_iterator_proto_funcs)); + JS_NewObjectProtoList(ctx, ctx->async_iterator_proto, + js_async_from_sync_iterator_proto_funcs, + countof(js_async_from_sync_iterator_proto_funcs)); + if (JS_IsException(ctx->class_proto[JS_CLASS_ASYNC_FROM_SYNC_ITERATOR])) + return -1; /* AsyncGeneratorPrototype */ ctx->class_proto[JS_CLASS_ASYNC_GENERATOR] = - JS_NewObjectProto(ctx, ctx->async_iterator_proto); - JS_SetPropertyFunctionList(ctx, - ctx->class_proto[JS_CLASS_ASYNC_GENERATOR], - js_async_generator_proto_funcs, - countof(js_async_generator_proto_funcs)); + JS_NewObjectProtoList(ctx, ctx->async_iterator_proto, + js_async_generator_proto_funcs, + countof(js_async_generator_proto_funcs)); + if (JS_IsException(ctx->class_proto[JS_CLASS_ASYNC_GENERATOR])) + return -1; /* AsyncGeneratorFunction */ - ctx->class_proto[JS_CLASS_ASYNC_GENERATOR_FUNCTION] = - JS_NewObjectProto(ctx, ctx->function_proto); ft.generic_magic = js_function_constructor; - obj1 = JS_NewCFunction3(ctx, ft.generic, - "AsyncGeneratorFunction", 1, - JS_CFUNC_constructor_or_func_magic, - JS_FUNC_ASYNC_GENERATOR, - ctx->function_ctor); - JS_SetPropertyFunctionList(ctx, - ctx->class_proto[JS_CLASS_ASYNC_GENERATOR_FUNCTION], - js_async_generator_function_proto_funcs, - countof(js_async_generator_function_proto_funcs)); - JS_SetConstructor2(ctx, ctx->class_proto[JS_CLASS_ASYNC_GENERATOR_FUNCTION], - ctx->class_proto[JS_CLASS_ASYNC_GENERATOR], - JS_PROP_CONFIGURABLE, JS_PROP_CONFIGURABLE); - JS_SetConstructor2(ctx, obj1, ctx->class_proto[JS_CLASS_ASYNC_GENERATOR_FUNCTION], - 0, JS_PROP_CONFIGURABLE); + obj1 = JS_NewCConstructor(ctx, JS_CLASS_ASYNC_GENERATOR_FUNCTION, "AsyncGeneratorFunction", + ft.generic, 1, JS_CFUNC_constructor_or_func_magic, JS_FUNC_ASYNC_GENERATOR, + ctx->function_ctor, + NULL, 0, + js_async_generator_function_proto_funcs, countof(js_async_generator_function_proto_funcs), + JS_NEW_CTOR_NO_GLOBAL | JS_NEW_CTOR_READONLY); + if (JS_IsException(obj1)) + return -1; JS_FreeValue(ctx, obj1); + + return JS_SetConstructor2(ctx, ctx->class_proto[JS_CLASS_ASYNC_GENERATOR_FUNCTION], + ctx->class_proto[JS_CLASS_ASYNC_GENERATOR], + JS_PROP_CONFIGURABLE, JS_PROP_CONFIGURABLE); } /* URI handling */ @@ -65465,6 +65785,7 @@ static const JSCFunctionListEntry js_global_funcs[] = { JS_PROP_U2D_DEF("NaN", 0x7FF8ull<<48, 0 ), // workaround for msvc JS_PROP_UNDEFINED_DEF("undefined", 0 ), JS_PROP_STRING_DEF("[Symbol.toStringTag]", "global", JS_PROP_CONFIGURABLE ), + JS_CFUNC_DEF("eval", 1, js_global_eval ), }; /* Date */ @@ -66613,26 +66934,30 @@ bool JS_IsDate(JSValueConst v) return JS_VALUE_GET_OBJ(v)->class_id == JS_CLASS_DATE; } -void JS_AddIntrinsicDate(JSContext *ctx) +int JS_AddIntrinsicDate(JSContext *ctx) { JSValue obj; - /* Date */ - ctx->class_proto[JS_CLASS_DATE] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_DATE], js_date_proto_funcs, - countof(js_date_proto_funcs)); - obj = JS_NewGlobalCConstructor(ctx, "Date", js_date_constructor, 7, - ctx->class_proto[JS_CLASS_DATE]); - JS_SetPropertyFunctionList(ctx, obj, js_date_funcs, countof(js_date_funcs)); + obj = JS_NewCConstructor(ctx, JS_CLASS_DATE, "Date", + js_date_constructor, 7, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + js_date_funcs, countof(js_date_funcs), + js_date_proto_funcs, countof(js_date_proto_funcs), + 0); + if (JS_IsException(obj)) + return -1; + JS_FreeValue(ctx, obj); + return 0; } /* eval */ -void JS_AddIntrinsicEval(JSContext *ctx) +int JS_AddIntrinsicEval(JSContext *ctx) { #ifndef QJS_DISABLE_PARSER ctx->eval_internal = __JS_EvalInternal; #endif // QJS_DISABLE_PARSER + return 0; } /* BigInt */ @@ -66816,18 +67141,20 @@ static const JSCFunctionListEntry js_bigint_proto_funcs[] = { JS_PROP_STRING_DEF("[Symbol.toStringTag]", "BigInt", JS_PROP_CONFIGURABLE ), }; -void JS_AddIntrinsicBigInt(JSContext *ctx) +int JS_AddIntrinsicBigInt(JSContext *ctx) { JSValue obj1; - ctx->class_proto[JS_CLASS_BIG_INT] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_BIG_INT], - js_bigint_proto_funcs, - countof(js_bigint_proto_funcs)); - obj1 = JS_NewGlobalCConstructor(ctx, "BigInt", js_bigint_constructor, 1, - ctx->class_proto[JS_CLASS_BIG_INT]); - JS_SetPropertyFunctionList(ctx, obj1, js_bigint_funcs, - countof(js_bigint_funcs)); + obj1 = JS_NewCConstructor(ctx, JS_CLASS_BIG_INT, "BigInt", + js_bigint_constructor, 1, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + js_bigint_funcs, countof(js_bigint_funcs), + js_bigint_proto_funcs, countof(js_bigint_proto_funcs), + 0); + if (JS_IsException(obj1)) + return -1; + JS_FreeValue(ctx, obj1); + return 0; } static const char * const native_error_name[JS_NATIVE_ERROR_COUNT] = { @@ -66838,18 +67165,38 @@ static const char * const native_error_name[JS_NATIVE_ERROR_COUNT] = { /* Minimum amount of objects to be able to compile code and display error messages. No JSAtom should be allocated by this function. */ -static void JS_AddIntrinsicBasicObjects(JSContext *ctx) +/* Minimum amount of objects to be able to compile code and display + error messages. */ +static int JS_AddIntrinsicBasicObjects(JSContext *ctx) { JSValue proto; int i; - ctx->class_proto[JS_CLASS_OBJECT] = JS_NewObjectProto(ctx, JS_NULL); - ctx->global_obj = JS_NewObject(ctx); - ctx->global_var_obj = JS_NewObjectProto(ctx, JS_NULL); + /* warning: ordering is tricky */ + ctx->class_proto[JS_CLASS_OBJECT] = + JS_NewObjectProtoClassAlloc(ctx, JS_NULL, JS_CLASS_OBJECT, + countof(js_object_proto_funcs) + 1); + if (JS_IsException(ctx->class_proto[JS_CLASS_OBJECT])) + return -1; + + /* 2 more properties: caller and arguments */ ctx->function_proto = JS_NewCFunction3(ctx, js_function_proto, "", 0, JS_CFUNC_generic, 0, - ctx->class_proto[JS_CLASS_OBJECT]); + ctx->class_proto[JS_CLASS_OBJECT], + countof(js_function_proto_funcs) + 3 + 2); + if (JS_IsException(ctx->function_proto)) + return -1; ctx->class_proto[JS_CLASS_BYTECODE_FUNCTION] = js_dup(ctx->function_proto); + + ctx->global_obj = JS_NewObjectProtoClassAlloc(ctx, ctx->class_proto[JS_CLASS_OBJECT], + JS_CLASS_OBJECT, 64); + if (JS_IsException(ctx->global_obj)) + return -1; + ctx->global_var_obj = JS_NewObjectProtoClassAlloc(ctx, JS_NULL, + JS_CLASS_OBJECT, 16); + if (JS_IsException(ctx->global_var_obj)) + return -1; + ctx->class_proto[JS_CLASS_ERROR] = JS_NewObject(ctx); JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ERROR], js_error_proto_funcs, @@ -66870,302 +67217,310 @@ static void JS_AddIntrinsicBasicObjects(JSContext *ctx) ctx->class_proto[JS_CLASS_ARRAY] = JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_OBJECT], JS_CLASS_ARRAY); - - ctx->array_shape = js_new_shape2(ctx, get_proto_obj(ctx->class_proto[JS_CLASS_ARRAY]), - JS_PROP_INITIAL_HASH_SIZE, 1); - add_shape_property(ctx, &ctx->array_shape, NULL, - JS_ATOM_length, JS_PROP_WRITABLE | JS_PROP_LENGTH); - ctx->std_array_prototype = true; - ctx->arguments_shape = js_new_shape2(ctx, get_proto_obj(ctx->class_proto[JS_CLASS_OBJECT]), - JS_PROP_INITIAL_HASH_SIZE, 3); - if (!ctx->arguments_shape) - return; - if (add_shape_property(ctx, &ctx->arguments_shape, NULL, - JS_ATOM_length, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE)) - return; - if (add_shape_property(ctx, &ctx->arguments_shape, NULL, - JS_ATOM_Symbol_iterator, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE)) - return; - if (add_shape_property(ctx, &ctx->arguments_shape, NULL, - JS_ATOM_callee, JS_PROP_GETSET)) - return; + static const JSShapeProperty array_props[] = { + {.atom=JS_ATOM_length, .flags=JS_PROP_WRITABLE|JS_PROP_LENGTH}, + }; + static const JSShapeProperty arguments_props[] = { + {.atom=JS_ATOM_length, .flags=JS_PROP_WRITABLE|JS_PROP_CONFIGURABLE}, + {.atom=JS_ATOM_Symbol_iterator, .flags=JS_PROP_WRITABLE|JS_PROP_CONFIGURABLE}, + {.atom=JS_ATOM_callee, .flags=JS_PROP_GETSET}, + }; + static const JSShapeProperty mapped_arguments_props[] = { + {.atom=JS_ATOM_length, .flags=JS_PROP_WRITABLE|JS_PROP_CONFIGURABLE}, + {.atom=JS_ATOM_Symbol_iterator, .flags=JS_PROP_WRITABLE|JS_PROP_CONFIGURABLE}, + {.atom=JS_ATOM_callee, .flags=JS_PROP_WRITABLE|JS_PROP_CONFIGURABLE}, + }; + if (js_new_shape_with(ctx, &ctx->array_shape, + ctx->class_proto[JS_CLASS_ARRAY], + countof(array_props), array_props)) { + return -1; + } + if (js_new_shape_with(ctx, &ctx->arguments_shape, + ctx->class_proto[JS_CLASS_OBJECT], + countof(arguments_props), arguments_props)) { + return -1; + } + if (js_new_shape_with(ctx, &ctx->mapped_arguments_shape, + ctx->class_proto[JS_CLASS_OBJECT], + countof(mapped_arguments_props), mapped_arguments_props)) { + return -1; + } - ctx->mapped_arguments_shape = js_new_shape2(ctx, get_proto_obj(ctx->class_proto[JS_CLASS_OBJECT]), - JS_PROP_INITIAL_HASH_SIZE, 3); - if (!ctx->mapped_arguments_shape) - return; - if (add_shape_property(ctx, &ctx->mapped_arguments_shape, NULL, - JS_ATOM_length, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE)) - return; - if (add_shape_property(ctx, &ctx->mapped_arguments_shape, NULL, - JS_ATOM_Symbol_iterator, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE)) - return; - if (add_shape_property(ctx, &ctx->mapped_arguments_shape, NULL, - JS_ATOM_callee, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE)) - return; - - /* XXX: could test it on first context creation to ensure that no - new atoms are created in JS_AddIntrinsicBasicObjects(). It is - necessary to avoid useless renumbering of atoms after - JS_EvalBinary() if it is done just after - JS_AddIntrinsicBasicObjects(). */ - // assert(ctx->rt->atom_count == JS_ATOM_END); + return 0; } -void JS_AddIntrinsicBaseObjects(JSContext *ctx) +int JS_AddIntrinsicBaseObjects(JSContext *ctx) { - int i; - JSValue obj, number_obj; - JSValue obj1; + JSValue obj1, obj2; + JSCFunctionType ft; ctx->throw_type_error = JS_NewCFunction(ctx, js_throw_type_error, NULL, 0); - + if (JS_IsException(ctx->throw_type_error)) + return -1; /* add caller and arguments properties to throw a TypeError */ - JS_DefineProperty(ctx, ctx->function_proto, JS_ATOM_caller, JS_UNDEFINED, - ctx->throw_type_error, ctx->throw_type_error, - JS_PROP_HAS_GET | JS_PROP_HAS_SET | - JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE); - JS_DefineProperty(ctx, ctx->function_proto, JS_ATOM_arguments, JS_UNDEFINED, - ctx->throw_type_error, ctx->throw_type_error, - JS_PROP_HAS_GET | JS_PROP_HAS_SET | - JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE); + if (JS_DefineProperty(ctx, ctx->function_proto, JS_ATOM_caller, JS_UNDEFINED, + ctx->throw_type_error, ctx->throw_type_error, + JS_PROP_HAS_GET | JS_PROP_HAS_SET | + JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE) < 0) + return -1; + if (JS_DefineProperty(ctx, ctx->function_proto, JS_ATOM_arguments, JS_UNDEFINED, + ctx->throw_type_error, ctx->throw_type_error, + JS_PROP_HAS_GET | JS_PROP_HAS_SET | + JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE) < 0) + return -1; JS_FreeValue(ctx, js_object_seal(ctx, JS_UNDEFINED, 1, vc(&ctx->throw_type_error), 1)); /* Object */ - obj = JS_NewGlobalCConstructor(ctx, "Object", js_object_constructor, 1, - ctx->class_proto[JS_CLASS_OBJECT]); - JS_SetPropertyFunctionList(ctx, obj, js_object_funcs, countof(js_object_funcs)); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_OBJECT], - js_object_proto_funcs, countof(js_object_proto_funcs)); + obj1 = JS_NewCConstructor(ctx, JS_CLASS_OBJECT, "Object", + js_object_constructor, 1, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + js_object_funcs, countof(js_object_funcs), + js_object_proto_funcs, countof(js_object_proto_funcs), + JS_NEW_CTOR_PROTO_EXIST); + if (JS_IsException(obj1)) + return -1; + JS_FreeValue(ctx, obj1); /* Function */ - JS_SetPropertyFunctionList(ctx, ctx->function_proto, js_function_proto_funcs, countof(js_function_proto_funcs)); - ctx->function_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, - "Function", 1, JS_CFUNC_constructor_or_func_magic, - JS_FUNC_NORMAL); - JS_NewGlobalCConstructor2(ctx, js_dup(ctx->function_ctor), "Function", - ctx->function_proto); + ft.generic_magic = js_function_constructor; + obj1 = JS_NewCConstructor(ctx, JS_CLASS_BYTECODE_FUNCTION, "Function", + ft.generic, 1, JS_CFUNC_constructor_or_func_magic, JS_FUNC_NORMAL, + JS_UNDEFINED, + NULL, 0, + js_function_proto_funcs, countof(js_function_proto_funcs), + JS_NEW_CTOR_PROTO_EXIST); + if (JS_IsException(obj1)) + return -1; + ctx->function_ctor = obj1; /* Error */ + ft.generic_magic = js_error_constructor; ctx->error_ctor = JS_NewCFunctionMagic(ctx, js_error_constructor, "Error", 1, JS_CFUNC_constructor_or_func_magic, -1); + if (JS_IsException(ctx->error_ctor)) + return -1; JS_NewGlobalCConstructor2(ctx, js_dup(ctx->error_ctor), "Error", ctx->class_proto[JS_CLASS_ERROR]); - JS_SetPropertyFunctionList(ctx, ctx->error_ctor, js_error_funcs, countof(js_error_funcs)); + if (JS_SetPropertyFunctionList(ctx, ctx->error_ctor, js_error_funcs, countof(js_error_funcs))) + return -1; - /* Used to squelch a -Wcast-function-type warning. */ - JSCFunctionType ft = { .generic_magic = js_error_constructor }; - for(i = 0; i < JS_NATIVE_ERROR_COUNT; i++) { + for(int i = 0; i < JS_NATIVE_ERROR_COUNT; i++) { JSValue func_obj; int n_args; n_args = 1 + (i == JS_AGGREGATE_ERROR); func_obj = JS_NewCFunction3(ctx, ft.generic, native_error_name[i], n_args, JS_CFUNC_constructor_or_func_magic, i, - ctx->error_ctor); + ctx->error_ctor, 0); + if (JS_IsException(func_obj)) + return -1; JS_NewGlobalCConstructor2(ctx, func_obj, native_error_name[i], ctx->native_error_proto[i]); } /* CallSite */ - _JS_AddIntrinsicCallSite(ctx); + if (_JS_AddIntrinsicCallSite(ctx)) + return -1; /* Iterator */ - ctx->class_proto[JS_CLASS_ITERATOR] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ITERATOR], - js_iterator_proto_funcs, - countof(js_iterator_proto_funcs)); - obj = JS_NewGlobalCConstructor(ctx, "Iterator", js_iterator_constructor, 0, - ctx->class_proto[JS_CLASS_ITERATOR]); + obj2 = JS_NewCConstructor(ctx, JS_CLASS_ITERATOR, "Iterator", + js_iterator_constructor, 0, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + js_iterator_funcs, countof(js_iterator_funcs), + js_iterator_proto_funcs, countof(js_iterator_proto_funcs), + 0); + if (JS_IsException(obj2)) + return -1; // quirk: Iterator.prototype.constructor is an accessor property - // TODO(bnoordhuis) mildly inefficient because JS_NewGlobalCConstructor + // TODO(bnoordhuis) mildly inefficient because JS_NewCConstructor // first creates a .constructor value property that we then replace with // an accessor - ctx->iterator_ctor_getset = JS_NewCFunctionData(ctx, js_iterator_constructor_getset, - 0, 0, 1, vc(&obj)); - JS_DefineProperty(ctx, ctx->class_proto[JS_CLASS_ITERATOR], - JS_ATOM_constructor, JS_UNDEFINED, - ctx->iterator_ctor_getset, ctx->iterator_ctor_getset, - JS_PROP_HAS_GET|JS_PROP_HAS_SET|JS_PROP_WRITABLE|JS_PROP_CONFIGURABLE); - ctx->iterator_ctor = js_dup(obj); - JS_SetPropertyFunctionList(ctx, obj, - js_iterator_funcs, - countof(js_iterator_funcs)); - JS_DefineAutoInitProperty(ctx, obj, JS_ATOM_zip, JS_AUTOINIT_ID_BYTECODE, + obj1 = JS_NewCFunctionData(ctx, js_iterator_constructor_getset, + 0, 0, 1, vc(&obj2)); + if (JS_IsException(obj1)) { + JS_FreeValue(ctx, obj2); + return -1; + } + ctx->iterator_ctor_getset = js_dup(obj1); + if (JS_DefineProperty(ctx, ctx->class_proto[JS_CLASS_ITERATOR], + JS_ATOM_constructor, JS_UNDEFINED, + obj1, obj1, + JS_PROP_HAS_GET | JS_PROP_HAS_SET | JS_PROP_CONFIGURABLE) < 0) { + JS_FreeValue(ctx, obj2); + JS_FreeValue(ctx, obj1); + return -1; + } + JS_FreeValue(ctx, obj1); + ctx->iterator_ctor = obj2; + JS_DefineAutoInitProperty(ctx, obj2, JS_ATOM_zip, JS_AUTOINIT_ID_BYTECODE, (void *)(uintptr_t)JS_BUILTIN_ITERATOR_ZIP, JS_PROP_WRITABLE|JS_PROP_CONFIGURABLE); - JS_DefineAutoInitProperty(ctx, obj, JS_ATOM_zipKeyed, JS_AUTOINIT_ID_BYTECODE, + JS_DefineAutoInitProperty(ctx, obj2, JS_ATOM_zipKeyed, JS_AUTOINIT_ID_BYTECODE, (void *)(uintptr_t)JS_BUILTIN_ITERATOR_ZIP_KEYED, JS_PROP_WRITABLE|JS_PROP_CONFIGURABLE); - ctx->class_proto[JS_CLASS_ITERATOR_CONCAT] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ITERATOR_CONCAT], - js_iterator_concat_proto_funcs, - countof(js_iterator_concat_proto_funcs)); + ctx->class_proto[JS_CLASS_ITERATOR_CONCAT] = + JS_NewObjectProtoList(ctx, ctx->class_proto[JS_CLASS_ITERATOR], + js_iterator_concat_proto_funcs, + countof(js_iterator_concat_proto_funcs)); + if (JS_IsException(ctx->class_proto[JS_CLASS_ITERATOR_CONCAT])) + return -1; - ctx->class_proto[JS_CLASS_ITERATOR_HELPER] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ITERATOR_HELPER], - js_iterator_helper_proto_funcs, - countof(js_iterator_helper_proto_funcs)); + ctx->class_proto[JS_CLASS_ITERATOR_HELPER] = + JS_NewObjectProtoList(ctx, ctx->class_proto[JS_CLASS_ITERATOR], + js_iterator_helper_proto_funcs, + countof(js_iterator_helper_proto_funcs)); + if (JS_IsException(ctx->class_proto[JS_CLASS_ITERATOR_HELPER])) + return -1; - ctx->class_proto[JS_CLASS_ITERATOR_WRAP] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ITERATOR_WRAP], - js_iterator_wrap_proto_funcs, - countof(js_iterator_wrap_proto_funcs)); + ctx->class_proto[JS_CLASS_ITERATOR_WRAP] = + JS_NewObjectProtoList(ctx, ctx->class_proto[JS_CLASS_ITERATOR], + js_iterator_wrap_proto_funcs, + countof(js_iterator_wrap_proto_funcs)); + if (JS_IsException(ctx->class_proto[JS_CLASS_ITERATOR_WRAP])) + return -1; /* Array */ - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ARRAY], - js_array_proto_funcs, - countof(js_array_proto_funcs)); - - obj = JS_NewGlobalCConstructor(ctx, "Array", js_array_constructor, 1, - ctx->class_proto[JS_CLASS_ARRAY]); - ctx->array_ctor = js_dup(obj); - JS_SetPropertyFunctionList(ctx, obj, js_array_funcs, - countof(js_array_funcs)); - JS_DefineAutoInitProperty(ctx, obj, JS_ATOM_fromAsync, + obj1 = JS_NewCConstructor(ctx, JS_CLASS_ARRAY, "Array", + js_array_constructor, 1, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + js_array_funcs, countof(js_array_funcs), + js_array_proto_funcs, countof(js_array_proto_funcs), + JS_NEW_CTOR_PROTO_EXIST); + if (JS_IsException(obj1)) + return -1; + ctx->array_ctor = obj1; + JS_DefineAutoInitProperty(ctx, obj1, JS_ATOM_fromAsync, JS_AUTOINIT_ID_BYTECODE, (void *)(uintptr_t)JS_BUILTIN_ARRAY_FROMASYNC, JS_PROP_WRITABLE|JS_PROP_CONFIGURABLE); - /* XXX: create auto_initializer */ - { - /* initialize Array.prototype[Symbol.unscopables] */ - static const char unscopables[] = - "copyWithin" "\0" - "entries" "\0" - "fill" "\0" - "find" "\0" - "findIndex" "\0" - "findLast" "\0" - "findLastIndex" "\0" - "flat" "\0" - "flatMap" "\0" - "includes" "\0" - "keys" "\0" - "toReversed" "\0" - "toSorted" "\0" - "toSpliced" "\0" - "values" "\0"; - const char *p = unscopables; - obj1 = JS_NewObjectProto(ctx, JS_NULL); - for(p = unscopables; *p; p += strlen(p) + 1) { - JS_DefinePropertyValueStr(ctx, obj1, p, JS_TRUE, JS_PROP_C_W_E); - } - JS_DefinePropertyValue(ctx, ctx->class_proto[JS_CLASS_ARRAY], - JS_ATOM_Symbol_unscopables, obj1, - JS_PROP_CONFIGURABLE); - } - /* needed to initialize arguments[Symbol.iterator] */ ctx->array_proto_values = JS_GetProperty(ctx, ctx->class_proto[JS_CLASS_ARRAY], JS_ATOM_values); + if (JS_IsException(ctx->array_proto_values)) + return -1; - ctx->class_proto[JS_CLASS_ARRAY_ITERATOR] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ARRAY_ITERATOR], - js_array_iterator_proto_funcs, - countof(js_array_iterator_proto_funcs)); + ctx->class_proto[JS_CLASS_ARRAY_ITERATOR] = + JS_NewObjectProtoList(ctx, ctx->class_proto[JS_CLASS_ITERATOR], + js_array_iterator_proto_funcs, + countof(js_array_iterator_proto_funcs)); + if (JS_IsException(ctx->class_proto[JS_CLASS_ARRAY_ITERATOR])) + return -1; /* parseFloat and parseInteger must be defined before Number because of the Number.parseFloat and Number.parseInteger aliases */ - JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_global_funcs, - countof(js_global_funcs)); + if (JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_global_funcs, + countof(js_global_funcs))) + return -1; /* Number */ - ctx->class_proto[JS_CLASS_NUMBER] = JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_OBJECT], - JS_CLASS_NUMBER); - JS_SetObjectData(ctx, ctx->class_proto[JS_CLASS_NUMBER], js_int32(0)); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_NUMBER], - js_number_proto_funcs, - countof(js_number_proto_funcs)); - number_obj = JS_NewGlobalCConstructor(ctx, "Number", js_number_constructor, 1, - ctx->class_proto[JS_CLASS_NUMBER]); - JS_SetPropertyFunctionList(ctx, number_obj, js_number_funcs, countof(js_number_funcs)); + obj1 = JS_NewCConstructor(ctx, JS_CLASS_NUMBER, "Number", + js_number_constructor, 1, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + js_number_funcs, countof(js_number_funcs), + js_number_proto_funcs, countof(js_number_proto_funcs), + JS_NEW_CTOR_PROTO_CLASS); + if (JS_IsException(obj1)) + return -1; + JS_FreeValue(ctx, obj1); + if (JS_SetObjectData(ctx, ctx->class_proto[JS_CLASS_NUMBER], js_int32(0))) + return -1; /* Boolean */ - ctx->class_proto[JS_CLASS_BOOLEAN] = JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_OBJECT], - JS_CLASS_BOOLEAN); - JS_SetObjectData(ctx, ctx->class_proto[JS_CLASS_BOOLEAN], JS_FALSE); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_BOOLEAN], js_boolean_proto_funcs, - countof(js_boolean_proto_funcs)); - JS_NewGlobalCConstructor(ctx, "Boolean", js_boolean_constructor, 1, - ctx->class_proto[JS_CLASS_BOOLEAN]); + obj1 = JS_NewCConstructor(ctx, JS_CLASS_BOOLEAN, "Boolean", + js_boolean_constructor, 1, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + NULL, 0, + js_boolean_proto_funcs, countof(js_boolean_proto_funcs), + JS_NEW_CTOR_PROTO_CLASS); + if (JS_IsException(obj1)) + return -1; + JS_FreeValue(ctx, obj1); + if (JS_SetObjectData(ctx, ctx->class_proto[JS_CLASS_BOOLEAN], JS_FALSE)) + return -1; /* String */ - ctx->class_proto[JS_CLASS_STRING] = JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_OBJECT], - JS_CLASS_STRING); - JS_SetObjectData(ctx, ctx->class_proto[JS_CLASS_STRING], js_empty_string(ctx->rt)); - obj = JS_NewGlobalCConstructor(ctx, "String", js_string_constructor, 1, - ctx->class_proto[JS_CLASS_STRING]); - JS_SetPropertyFunctionList(ctx, obj, js_string_funcs, - countof(js_string_funcs)); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_STRING], js_string_proto_funcs, - countof(js_string_proto_funcs)); + obj1 = JS_NewCConstructor(ctx, JS_CLASS_STRING, "String", + js_string_constructor, 1, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + js_string_funcs, countof(js_string_funcs), + js_string_proto_funcs, countof(js_string_proto_funcs), + JS_NEW_CTOR_PROTO_CLASS); + if (JS_IsException(obj1)) + return -1; + JS_FreeValue(ctx, obj1); + if (JS_SetObjectData(ctx, ctx->class_proto[JS_CLASS_STRING], js_empty_string(ctx->rt))) + return -1; - ctx->class_proto[JS_CLASS_STRING_ITERATOR] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_STRING_ITERATOR], - js_string_iterator_proto_funcs, - countof(js_string_iterator_proto_funcs)); + ctx->class_proto[JS_CLASS_STRING_ITERATOR] = + JS_NewObjectProtoList(ctx, ctx->class_proto[JS_CLASS_ITERATOR], + js_string_iterator_proto_funcs, + countof(js_string_iterator_proto_funcs)); + if (JS_IsException(ctx->class_proto[JS_CLASS_STRING_ITERATOR])) + return -1; /* Math: create as autoinit object */ js_random_init(ctx); - JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_math_obj, countof(js_math_obj)); + if (JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_math_obj, countof(js_math_obj))) + return -1; /* ES6 Reflect: create as autoinit object */ - JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_reflect_obj, countof(js_reflect_obj)); + if (JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_reflect_obj, countof(js_reflect_obj))) + return -1; /* ES6 Symbol */ - ctx->class_proto[JS_CLASS_SYMBOL] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_SYMBOL], js_symbol_proto_funcs, - countof(js_symbol_proto_funcs)); - obj = JS_NewGlobalCConstructor(ctx, "Symbol", js_symbol_constructor, 0, - ctx->class_proto[JS_CLASS_SYMBOL]); - JS_SetPropertyFunctionList(ctx, obj, js_symbol_funcs, - countof(js_symbol_funcs)); - for(i = JS_ATOM_Symbol_toPrimitive; i < JS_ATOM_END; i++) { - char buf[ATOM_GET_STR_BUF_SIZE]; - const char *str, *p; - str = JS_AtomGetStr(ctx, buf, sizeof(buf), i); - /* skip "Symbol." */ - p = strchr(str, '.'); - if (p) - str = p + 1; - JS_DefinePropertyValueStr(ctx, obj, str, JS_AtomToValue(ctx, i), 0); - } - - /* ES6 Generator */ - ctx->class_proto[JS_CLASS_GENERATOR] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_GENERATOR], - js_generator_proto_funcs, - countof(js_generator_proto_funcs)); - - ctx->class_proto[JS_CLASS_GENERATOR_FUNCTION] = JS_NewObjectProto(ctx, ctx->function_proto); - obj1 = JS_NewCFunctionMagic(ctx, js_function_constructor, - "GeneratorFunction", 1, - JS_CFUNC_constructor_or_func_magic, JS_FUNC_GENERATOR); - JS_SetPropertyFunctionList(ctx, - ctx->class_proto[JS_CLASS_GENERATOR_FUNCTION], - js_generator_function_proto_funcs, - countof(js_generator_function_proto_funcs)); - JS_SetConstructor2(ctx, ctx->class_proto[JS_CLASS_GENERATOR_FUNCTION], - ctx->class_proto[JS_CLASS_GENERATOR], - JS_PROP_CONFIGURABLE, JS_PROP_CONFIGURABLE); - JS_SetConstructor2(ctx, obj1, ctx->class_proto[JS_CLASS_GENERATOR_FUNCTION], - 0, JS_PROP_CONFIGURABLE); + obj1 = JS_NewCConstructor(ctx, JS_CLASS_SYMBOL, "Symbol", + js_symbol_constructor, 0, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + js_symbol_funcs, countof(js_symbol_funcs), + js_symbol_proto_funcs, countof(js_symbol_proto_funcs), + 0); + if (JS_IsException(obj1)) + return -1; JS_FreeValue(ctx, obj1); - /* global properties */ - ctx->eval_obj = JS_NewCFunction(ctx, js_global_eval, "eval", 1); - JS_DefinePropertyValue(ctx, ctx->global_obj, JS_ATOM_eval, - js_dup(ctx->eval_obj), - JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); + /* ES6 Generator */ + ctx->class_proto[JS_CLASS_GENERATOR] = + JS_NewObjectProtoList(ctx, ctx->class_proto[JS_CLASS_ITERATOR], + js_generator_proto_funcs, + countof(js_generator_proto_funcs)); + if (JS_IsException(ctx->class_proto[JS_CLASS_GENERATOR])) + return -1; - JS_DefinePropertyValue(ctx, ctx->global_obj, JS_ATOM_globalThis, - js_dup(ctx->global_obj), - JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE); + ft.generic_magic = js_function_constructor; + obj1 = JS_NewCConstructor(ctx, JS_CLASS_GENERATOR_FUNCTION, "GeneratorFunction", + ft.generic, 1, JS_CFUNC_constructor_or_func_magic, JS_FUNC_GENERATOR, + ctx->function_ctor, + NULL, 0, + js_generator_function_proto_funcs, + countof(js_generator_function_proto_funcs), + JS_NEW_CTOR_NO_GLOBAL | JS_NEW_CTOR_READONLY); + if (JS_IsException(obj1)) + return -1; + JS_FreeValue(ctx, obj1); + if (JS_SetConstructor2(ctx, ctx->class_proto[JS_CLASS_GENERATOR_FUNCTION], + ctx->class_proto[JS_CLASS_GENERATOR], + JS_PROP_CONFIGURABLE, JS_PROP_CONFIGURABLE)) + return -1; + + /* global properties */ + ctx->eval_obj = JS_GetProperty(ctx, ctx->global_obj, JS_ATOM_eval); + if (JS_IsException(ctx->eval_obj)) + return -1; + + if (JS_DefinePropertyValue(ctx, ctx->global_obj, JS_ATOM_globalThis, + js_dup(ctx->global_obj), + JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE) < 0) + return -1; + + /* BigInt */ + if (JS_AddIntrinsicBigInt(ctx)) + return -1; + return 0; } /* Typed Arrays */ @@ -67500,6 +67855,23 @@ void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj) } } +int JS_IsImmutableArrayBuffer(JSValueConst obj) +{ + JSArrayBuffer *abuf = JS_GetOpaque(obj, JS_CLASS_ARRAY_BUFFER); + if (!abuf) + return -1; + return abuf->immutable; +} + +int JS_SetImmutableArrayBuffer(JSValueConst obj, bool immutable) +{ + JSArrayBuffer *abuf = JS_GetOpaque(obj, JS_CLASS_ARRAY_BUFFER); + if (!abuf) + return -1; + abuf->immutable = immutable; + return 0; +} + /* get an ArrayBuffer or SharedArrayBuffer */ static JSArrayBuffer *js_get_array_buffer(JSContext *ctx, JSValueConst obj) { @@ -68160,39 +68532,79 @@ static JSValue js_typed_array_at(JSContext *ctx, JSValueConst this_val, static JSValue js_typed_array_with(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - JSValue arr, val; + JSValue arr, val, buffer; JSObject *p; + JSTypedArray *ta; + JSArrayBuffer *src_abuf, *abuf; int64_t idx; - uint32_t len, oldlen, newlen; + uint32_t len, newlen, copy_len; + int size_log2; p = get_typed_array(ctx, this_val); if (!p) return JS_EXCEPTION; - oldlen = p->u.array.count; + len = p->u.array.count; if (JS_ToInt64Sat(ctx, &idx, argv[0])) return JS_EXCEPTION; + /* resolve negative index using original length (spec step 5-6) */ + if (idx < 0) + idx = len + idx; val = JS_ToPrimitive(ctx, argv[1], HINT_NUMBER); if (JS_IsException(val)) return JS_EXCEPTION; + /* re-validate after user code (spec step 9: IsValidIntegerIndex) */ + if (typed_array_is_oob(p)) { + JS_FreeValue(ctx, val); + return JS_ThrowTypeErrorArrayBufferOOB(ctx); + } newlen = p->u.array.count; - if (idx < 0) - idx = newlen + idx; if (idx < 0 || idx >= newlen) { JS_FreeValue(ctx, val); - return JS_ThrowRangeError(ctx, "invalid array index"); + return JS_ThrowRangeError(ctx, "invalid typed array index"); } - len = min_uint32(oldlen, newlen); - arr = js_typed_array_constructor_ta(ctx, JS_UNDEFINED, this_val, - p->class_id, len); + copy_len = min_uint32(len, newlen); + size_log2 = typed_array_size_log2(p->class_id); + + /* create new typed array with original length (zero-initialized) */ + arr = js_create_from_ctor(ctx, JS_UNDEFINED, p->class_id); if (JS_IsException(arr)) { JS_FreeValue(ctx, val); return JS_EXCEPTION; } - if (idx < len && JS_SetPropertyInt64(ctx, arr, idx, val) < 0) { + buffer = js_array_buffer_constructor1(ctx, JS_UNDEFINED, + (uint64_t)len << size_log2, + NULL); + if (JS_IsException(buffer)) { + JS_FreeValue(ctx, val); + JS_FreeValue(ctx, arr); + return JS_EXCEPTION; + } + if (typed_array_is_oob(p)) { + JS_FreeValue(ctx, val); + JS_FreeValue(ctx, buffer); + JS_FreeValue(ctx, arr); + return JS_ThrowTypeErrorArrayBufferOOB(ctx); + } + abuf = JS_GetOpaque(buffer, JS_CLASS_ARRAY_BUFFER); + if (typed_array_init(ctx, arr, buffer, 0, len, /*track_rab*/false)) { + JS_FreeValue(ctx, val); + JS_FreeValue(ctx, arr); + return JS_EXCEPTION; + } + + /* copy min(len, newlen) elements from source; rest stays zero */ + if (copy_len > 0) { + ta = p->u.typed_array; + src_abuf = ta->buffer->u.array_buffer; + memcpy(abuf->data, src_abuf->data + ta->offset, + (size_t)copy_len << size_log2); + } + + if (JS_SetPropertyInt64(ctx, arr, idx, val) < 0) { JS_FreeValue(ctx, arr); return JS_EXCEPTION; } @@ -69549,6 +69961,13 @@ static const JSCFunctionListEntry js_typed_array_base_proto_funcs[] = { //JS_ALIAS_BASE_DEF("toString", "toString", 2 /* Array.prototype. */), @@@ }; +static const JSCFunctionListEntry js_typed_array_funcs[] = { + JS_PROP_INT32_DEF("BYTES_PER_ELEMENT", 1, 0), + JS_PROP_INT32_DEF("BYTES_PER_ELEMENT", 2, 0), + JS_PROP_INT32_DEF("BYTES_PER_ELEMENT", 4, 0), + JS_PROP_INT32_DEF("BYTES_PER_ELEMENT", 8, 0), +}; + static JSValue js_typed_array_base_constructor(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) @@ -70780,103 +71199,107 @@ static void js__atomics_init(void) { } /* TODO(saghul) make this public and not dependent on typed arrays? */ -void JS_AddIntrinsicAtomics(JSContext *ctx) +static int JS_AddIntrinsicAtomics(JSContext *ctx) { js_once(&js_atomics_once, js__atomics_init); /* add Atomics as autoinit object */ - JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_atomics_obj, countof(js_atomics_obj)); + return JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_atomics_obj, countof(js_atomics_obj)); } #endif /* CONFIG_ATOMICS */ -void JS_AddIntrinsicTypedArrays(JSContext *ctx) +int JS_AddIntrinsicTypedArrays(JSContext *ctx) { - JSValue typed_array_base_proto, typed_array_base_func; - JSValue array_buffer_func, shared_array_buffer_func; - int i; + JSValue typed_array_base_func, typed_array_base_proto, obj; + int i, ret; - ctx->class_proto[JS_CLASS_ARRAY_BUFFER] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ARRAY_BUFFER], - js_array_buffer_proto_funcs, - countof(js_array_buffer_proto_funcs)); + obj = JS_NewCConstructor(ctx, JS_CLASS_ARRAY_BUFFER, "ArrayBuffer", + js_array_buffer_constructor, 1, JS_CFUNC_constructor, 0, + JS_UNDEFINED, + js_array_buffer_funcs, countof(js_array_buffer_funcs), + js_array_buffer_proto_funcs, countof(js_array_buffer_proto_funcs), + 0); + if (JS_IsException(obj)) + return -1; + JS_FreeValue(ctx, obj); - array_buffer_func = JS_NewGlobalCConstructorOnly(ctx, "ArrayBuffer", - js_array_buffer_constructor, 1, - ctx->class_proto[JS_CLASS_ARRAY_BUFFER]); - JS_SetPropertyFunctionList(ctx, array_buffer_func, - js_array_buffer_funcs, - countof(js_array_buffer_funcs)); + obj = JS_NewCConstructor(ctx, JS_CLASS_SHARED_ARRAY_BUFFER, "SharedArrayBuffer", + js_shared_array_buffer_constructor, 1, JS_CFUNC_constructor, 0, + JS_UNDEFINED, + js_shared_array_buffer_funcs, countof(js_shared_array_buffer_funcs), + js_shared_array_buffer_proto_funcs, countof(js_shared_array_buffer_proto_funcs), + 0); + if (JS_IsException(obj)) + return -1; + JS_FreeValue(ctx, obj); - ctx->class_proto[JS_CLASS_SHARED_ARRAY_BUFFER] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_SHARED_ARRAY_BUFFER], - js_shared_array_buffer_proto_funcs, - countof(js_shared_array_buffer_proto_funcs)); - - shared_array_buffer_func = JS_NewGlobalCConstructorOnly(ctx, "SharedArrayBuffer", - js_shared_array_buffer_constructor, 1, - ctx->class_proto[JS_CLASS_SHARED_ARRAY_BUFFER]); - JS_SetPropertyFunctionList(ctx, shared_array_buffer_func, - js_shared_array_buffer_funcs, - countof(js_shared_array_buffer_funcs)); - - typed_array_base_proto = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, typed_array_base_proto, - js_typed_array_base_proto_funcs, - countof(js_typed_array_base_proto_funcs)); + typed_array_base_func = + JS_NewCConstructor(ctx, -1, "TypedArray", + js_typed_array_base_constructor, 0, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + js_typed_array_base_funcs, countof(js_typed_array_base_funcs), + js_typed_array_base_proto_funcs, countof(js_typed_array_base_proto_funcs), + JS_NEW_CTOR_NO_GLOBAL); + if (JS_IsException(typed_array_base_func)) + return -1; /* TypedArray.prototype.toString must be the same object as Array.prototype.toString */ - JSValue obj = JS_GetProperty(ctx, ctx->class_proto[JS_CLASS_ARRAY], JS_ATOM_toString); + obj = JS_GetProperty(ctx, ctx->class_proto[JS_CLASS_ARRAY], JS_ATOM_toString); + if (JS_IsException(obj)) + goto fail; /* XXX: should use alias method in JSCFunctionListEntry */ //@@@ - JS_DefinePropertyValue(ctx, typed_array_base_proto, JS_ATOM_toString, obj, - JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); - - typed_array_base_func = JS_NewCFunction(ctx, js_typed_array_base_constructor, - "TypedArray", 0); - JS_SetPropertyFunctionList(ctx, typed_array_base_func, - js_typed_array_base_funcs, - countof(js_typed_array_base_funcs)); - JS_SetConstructor(ctx, typed_array_base_func, typed_array_base_proto); - JS_SetConstructorBit(ctx, typed_array_base_func, true); + typed_array_base_proto = JS_GetProperty(ctx, typed_array_base_func, JS_ATOM_prototype); + if (JS_IsException(typed_array_base_proto)) + goto fail; + ret = JS_DefinePropertyValue(ctx, typed_array_base_proto, JS_ATOM_toString, obj, + JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); + JS_FreeValue(ctx, typed_array_base_proto); + if (ret < 0) + goto fail; /* Used to squelch a -Wcast-function-type warning. */ JSCFunctionType ft = { .generic_magic = js_typed_array_constructor }; for(i = JS_CLASS_UINT8C_ARRAY; i < JS_CLASS_UINT8C_ARRAY + JS_TYPED_ARRAY_COUNT; i++) { - JSValue func_obj; char buf[ATOM_GET_STR_BUF_SIZE]; const char *name; + const JSCFunctionListEntry *bpe; - ctx->class_proto[i] = JS_NewObjectProto(ctx, typed_array_base_proto); - JS_DefinePropertyValueStr(ctx, ctx->class_proto[i], - "BYTES_PER_ELEMENT", - js_int32(1 << typed_array_size_log2(i)), - 0); name = JS_AtomGetStr(ctx, buf, sizeof(buf), JS_ATOM_Uint8ClampedArray + i - JS_CLASS_UINT8C_ARRAY); - func_obj = JS_NewCFunction3(ctx, ft.generic, - name, 3, JS_CFUNC_constructor_magic, i, - typed_array_base_func); - JS_NewGlobalCConstructor2(ctx, func_obj, name, ctx->class_proto[i]); - JS_DefinePropertyValueStr(ctx, func_obj, - "BYTES_PER_ELEMENT", - js_int32(1 << typed_array_size_log2(i)), - 0); + bpe = js_typed_array_funcs + typed_array_size_log2(i); + obj = JS_NewCConstructor(ctx, i, name, + ft.generic, 3, JS_CFUNC_constructor_magic, i, + typed_array_base_func, + bpe, 1, + bpe, 1, + 0); + if (JS_IsException(obj)) { + fail: + JS_FreeValue(ctx, typed_array_base_func); + return -1; + } + JS_FreeValue(ctx, obj); } - JS_FreeValue(ctx, typed_array_base_proto); JS_FreeValue(ctx, typed_array_base_func); /* DataView */ - ctx->class_proto[JS_CLASS_DATAVIEW] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_DATAVIEW], - js_dataview_proto_funcs, - countof(js_dataview_proto_funcs)); - JS_NewGlobalCConstructorOnly(ctx, "DataView", - js_dataview_constructor, 1, - ctx->class_proto[JS_CLASS_DATAVIEW]); + obj = JS_NewCConstructor(ctx, JS_CLASS_DATAVIEW, "DataView", + js_dataview_constructor, 1, JS_CFUNC_constructor, 0, + JS_UNDEFINED, + NULL, 0, + js_dataview_proto_funcs, countof(js_dataview_proto_funcs), + 0); + if (JS_IsException(obj)) + return -1; + JS_FreeValue(ctx, obj); + /* Atomics */ #ifdef CONFIG_ATOMICS - JS_AddIntrinsicAtomics(ctx); + if (JS_AddIntrinsicAtomics(ctx)) + return -1; #endif + return 0; } /* Performance */ @@ -70895,7 +71318,7 @@ static const JSCFunctionListEntry js_perf_proto_funcs[] = { JS_CFUNC_DEF2("now", 0, js_perf_now, JS_PROP_ENUMERABLE), }; -void JS_AddPerformance(JSContext *ctx) +int JS_AddPerformance(JSContext *ctx) { ctx->time_origin = js__now_ms(); @@ -70908,6 +71331,7 @@ void JS_AddPerformance(JSContext *ctx) js_dup(performance), JS_PROP_WRITABLE | JS_PROP_ENUMERABLE | JS_PROP_CONFIGURABLE); JS_FreeValue(ctx, performance); + return 0; } /* Equality comparisons and sameness */ @@ -71019,10 +71443,11 @@ static const JSClassShortDef js_weakref_class_def[] = { typedef struct JSFinRecEntry { struct list_head link; - JSValueConst obj; JSValueConst target; JSValue held_val; JSValue token; + JSValue cb; + JSContext *ctx; } JSFinRecEntry; typedef struct JSFinalizationRegistryData { @@ -71047,6 +71472,15 @@ static void delete_finrec_weakref(JSRuntime *rt, JSFinRecEntry *fre) js_free_rt(rt, wr); } +static void js_finrec_free(JSRuntime *rt, JSFinRecEntry *fre) +{ + JS_FreeValueRT(rt, fre->held_val); + JS_FreeValueRT(rt, fre->token); + JS_FreeValueRT(rt, fre->cb); + JS_FreeContext(fre->ctx); + js_free_rt(rt, fre); +} + static void js_finrec_finalizer(JSRuntime *rt, JSValueConst val) { JSFinalizationRegistryData *frd = JS_GetOpaque(val, JS_CLASS_FINALIZATION_REGISTRY); @@ -71062,9 +71496,7 @@ static void js_finrec_finalizer(JSRuntime *rt, JSValueConst val) list_for_each_safe(el, el1, &frd->entries) { JSFinRecEntry *fre = list_entry(el, JSFinRecEntry, link); list_del(&fre->link); - JS_FreeValueRT(rt, fre->held_val); - JS_FreeValueRT(rt, fre->token); - js_free_rt(rt, fre); + js_finrec_free(rt, fre); } JS_FreeValueRT(rt, frd->cb); js_free_rt(rt, frd); @@ -71082,6 +71514,8 @@ static void js_finrec_mark(JSRuntime *rt, JSValueConst val, JSFinRecEntry *fre = list_entry(el, JSFinRecEntry, link); JS_MarkValue(rt, fre->held_val, mark_func); JS_MarkValue(rt, fre->token, mark_func); + JS_MarkValue(rt, fre->cb, mark_func); + mark_func(rt, &fre->ctx->header); } } } @@ -71138,7 +71572,8 @@ static JSValue js_finrec_register(JSContext *ctx, JSValueConst this_val, js_free(ctx, fre); return JS_EXCEPTION; } - fre->obj = this_val; + fre->cb = js_dup(frd->cb); + fre->ctx = JS_DupContext(frd->ctx); fre->target = target; fre->held_val = js_dup(held_val); fre->token = js_dup(token); @@ -71167,9 +71602,7 @@ static JSValue js_finrec_unregister(JSContext *ctx, JSValueConst this_val, int a if (js_same_value(ctx, fre->token, token)) { list_del(&fre->link); delete_finrec_weakref(ctx->rt, fre); - JS_FreeValue(ctx, fre->held_val); - JS_FreeValue(ctx, fre->token); - js_free(ctx, fre); + js_finrec_free(ctx->rt, fre); removed = true; } } @@ -71192,31 +71625,43 @@ static JSValue js_finrec_job(JSContext *ctx, int argc, JSValueConst *argv) return JS_Call(ctx, argv[0], JS_UNDEFINED, 1, &argv[1]); } -void JS_AddIntrinsicWeakRef(JSContext *ctx) +int JS_AddIntrinsicWeakRef(JSContext *ctx) { JSRuntime *rt = ctx->rt; + JSValue obj; /* WeakRef */ if (!JS_IsRegisteredClass(rt, JS_CLASS_WEAK_REF)) { - init_class_range(rt, js_weakref_class_def, JS_CLASS_WEAK_REF, - countof(js_weakref_class_def)); + if (init_class_range(rt, js_weakref_class_def, JS_CLASS_WEAK_REF, + countof(js_weakref_class_def))) + return -1; } - ctx->class_proto[JS_CLASS_WEAK_REF] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_WEAK_REF], - js_weakref_proto_funcs, - countof(js_weakref_proto_funcs)); - JS_NewGlobalCConstructor(ctx, "WeakRef", js_weakref_constructor, 1, ctx->class_proto[JS_CLASS_WEAK_REF]); + obj = JS_NewCConstructor(ctx, JS_CLASS_WEAK_REF, "WeakRef", + js_weakref_constructor, 1, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + NULL, 0, + js_weakref_proto_funcs, countof(js_weakref_proto_funcs), + 0); + if (JS_IsException(obj)) + return -1; + JS_FreeValue(ctx, obj); /* FinalizationRegistry */ if (!JS_IsRegisteredClass(rt, JS_CLASS_FINALIZATION_REGISTRY)) { - init_class_range(rt, js_finrec_class_def, JS_CLASS_FINALIZATION_REGISTRY, - countof(js_finrec_class_def)); + if (init_class_range(rt, js_finrec_class_def, JS_CLASS_FINALIZATION_REGISTRY, + countof(js_finrec_class_def))) + return -1; } - ctx->class_proto[JS_CLASS_FINALIZATION_REGISTRY] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_FINALIZATION_REGISTRY], - js_finrec_proto_funcs, - countof(js_finrec_proto_funcs)); - JS_NewGlobalCConstructor(ctx, "FinalizationRegistry", js_finrec_constructor, 1, ctx->class_proto[JS_CLASS_FINALIZATION_REGISTRY]); + obj = JS_NewCConstructor(ctx, JS_CLASS_FINALIZATION_REGISTRY, "FinalizationRegistry", + js_finrec_constructor, 1, JS_CFUNC_constructor_or_func, 0, + JS_UNDEFINED, + NULL, 0, + js_finrec_proto_funcs, countof(js_finrec_proto_funcs), + 0); + if (JS_IsException(obj)) + return -1; + JS_FreeValue(ctx, obj); + return 0; } static void reset_weak_ref(JSRuntime *rt, JSWeakRefRecord **first_weak_ref) @@ -71270,20 +71715,31 @@ static void reset_weak_ref(JSRuntime *rt, JSWeakRefRecord **first_weak_ref) break; case JS_WEAK_REF_KIND_FINALIZATION_REGISTRY_ENTRY: { fre = wr->u.fin_rec_entry; - JSFinalizationRegistryData *frd = JS_GetOpaque(fre->obj, JS_CLASS_FINALIZATION_REGISTRY); - assert(frd != NULL); /** - * During the GC sweep phase the held object might be collected first. + * During the GC sweep phase the held object might be + * collected first (free_mark set). Also skip if the + * callback or held value are part of a cycle being + * collected (header.mark is set for objects on + * tmp_obj_list during gc_free_cycles). */ - if (!rt->in_free && (!JS_IsObject(fre->held_val) || JS_IsLiveObject(rt, fre->held_val))) { - JSValueConst args[2]; - args[0] = frd->cb; - args[1] = fre->held_val; - JS_EnqueueJob(frd->ctx, js_finrec_job, 2, args); + bool enqueue = !rt->in_free; + if (enqueue && JS_IsObject(fre->held_val)) { + JSObject *p = JS_VALUE_GET_OBJ(fre->held_val); + if (p->free_mark || p->header.mark) + enqueue = false; } - JS_FreeValueRT(rt, fre->held_val); - JS_FreeValueRT(rt, fre->token); - js_free_rt(rt, fre); + if (enqueue && JS_IsObject(fre->cb)) { + JSObject *p = JS_VALUE_GET_OBJ(fre->cb); + if (p->free_mark || p->header.mark) + enqueue = false; + } + if (enqueue) { + JSValueConst args[2]; + args[0] = fre->cb; + args[1] = fre->held_val; + JS_EnqueueJob(fre->ctx, js_finrec_job, 2, args); + } + js_finrec_free(rt, fre); break; } default: @@ -71459,18 +71915,19 @@ static const JSClassShortDef js_callsite_class_def[] = { { JS_ATOM_CallSite, js_callsite_finalizer, js_callsite_mark }, /* JS_CLASS_CALL_SITE */ }; -static void _JS_AddIntrinsicCallSite(JSContext *ctx) +static int _JS_AddIntrinsicCallSite(JSContext *ctx) { JSRuntime *rt = ctx->rt; if (!JS_IsRegisteredClass(rt, JS_CLASS_CALL_SITE)) { - init_class_range(rt, js_callsite_class_def, JS_CLASS_CALL_SITE, - countof(js_callsite_class_def)); + if (init_class_range(rt, js_callsite_class_def, JS_CLASS_CALL_SITE, + countof(js_callsite_class_def))) + return -1; } ctx->class_proto[JS_CLASS_CALL_SITE] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_CALL_SITE], - js_callsite_proto_funcs, - countof(js_callsite_proto_funcs)); + return JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_CALL_SITE], + js_callsite_proto_funcs, + countof(js_callsite_proto_funcs)); } /* DOMException */ @@ -71664,7 +72121,7 @@ JSValue JS_PRINTF_FORMAT_ATTR(3, 4) JS_ThrowDOMException(JSContext *ctx, const c return JS_Throw(ctx, obj); } -void JS_AddIntrinsicDOMException(JSContext *ctx) +int JS_AddIntrinsicDOMException(JSContext *ctx) { JSRuntime *rt = ctx->rt; int i; @@ -71672,8 +72129,9 @@ void JS_AddIntrinsicDOMException(JSContext *ctx) JSValue ctor, proto; if (!JS_IsRegisteredClass(rt, JS_CLASS_DOM_EXCEPTION)) { - init_class_range(rt, js_domexception_class_def, JS_CLASS_DOM_EXCEPTION, - countof(js_domexception_class_def)); + if (init_class_range(rt, js_domexception_class_def, JS_CLASS_DOM_EXCEPTION, + countof(js_domexception_class_def))) + return -1; } proto = JS_NewObjectClass(ctx, JS_CLASS_ERROR); JS_SetPropertyFunctionList(ctx, proto, @@ -71693,6 +72151,7 @@ void JS_AddIntrinsicDOMException(JSContext *ctx) JS_DefinePropertyValue(ctx, ctx->global_obj, JS_ATOM_DOMException, ctor, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); ctx->class_proto[JS_CLASS_DOM_EXCEPTION] = proto; + return 0; } bool JS_DetectModule(const char *input, size_t input_len) @@ -74351,7 +74810,9 @@ static int re_parse_char_class(REParseState *s, const uint8_t **pp) const char *s = verboten; int n = 1; do { - if (!memcmp(s, p, n)) + // not memcmp because some implementations compare word instead + // of byte at a time and will happily read past end of input + if (!strncmp(s, (const char *)p, n)) if (p[n] == ']') goto invalid_class_range; s += n; @@ -75758,7 +76219,8 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture, case REOP_save_start: case REOP_save_end: val = *pc++; - assert(val < s->capture_count); + if (val >= s->capture_count) + return LRE_RET_BYTECODE_ERROR; capture[2 * val + opcode - REOP_save_start] = (uint8_t *)cptr; break; case REOP_save_reset: @@ -75767,7 +76229,8 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture, val = pc[0]; val2 = pc[1]; pc += 2; - assert(val2 < s->capture_count); + if (val2 >= s->capture_count) + return LRE_RET_BYTECODE_ERROR; while (val <= val2) { capture[2 * val] = NULL; capture[2 * val + 1] = NULL; @@ -76060,80 +76523,6 @@ const char *lre_get_groupnames(const uint8_t *bc_buf) return (const char *)(bc_buf + RE_HEADER_LEN + re_bytecode_len); } -void lre_byte_swap(uint8_t *buf, size_t len, bool is_byte_swapped) -{ - uint8_t *p, *pe; - uint32_t n, r, nw; - - p = buf; - if (len < RE_HEADER_LEN) - abort(); - - // format is: - //
- // - // - // - // etc. - inplace_bswap16(&p[RE_HEADER_FLAGS]); - - n = get_u32(&p[RE_HEADER_BYTECODE_LEN]); - inplace_bswap32(&p[RE_HEADER_BYTECODE_LEN]); - if (is_byte_swapped) - n = bswap32(n); - if (n > len - RE_HEADER_LEN) - abort(); - - p = &buf[RE_HEADER_LEN]; - pe = &p[n]; - - while (p < pe) { - n = reopcode_info[*p].size; - switch (n) { - case 1: - case 2: - break; - case 3: - switch (*p) { - case REOP_save_reset: // has two 8 bit arguments - break; - case REOP_range32: // variable length - nw = get_u16(&p[1]); // number of pairs of uint32_t - if (is_byte_swapped) - n = bswap16(n); - for (r = 3 + 8 * nw; n < r; n += 4) - inplace_bswap32(&p[n]); - goto doswap16; - case REOP_range: // variable length - nw = get_u16(&p[1]); // number of pairs of uint16_t - if (is_byte_swapped) - n = bswap16(n); - for (r = 3 + 4 * nw; n < r; n += 2) - inplace_bswap16(&p[n]); - goto doswap16; - default: - doswap16: - inplace_bswap16(&p[1]); - break; - } - break; - case 5: - inplace_bswap32(&p[1]); - break; - case 17: - assert(*p == REOP_simple_greedy_quant); - inplace_bswap32(&p[1]); - inplace_bswap32(&p[5]); - inplace_bswap32(&p[9]); - inplace_bswap32(&p[13]); - break; - default: - abort(); - } - p = &p[n]; - } -} - #ifdef TEST bool lre_check_stack_overflow(void *opaque, size_t alloca_size) @@ -77962,6 +78351,7 @@ int unicode_prop(CharRange *cr, const char *prop_name) #define QUICKJS_LIBC_H #include +#include #include #include @@ -77971,6 +78361,9 @@ int unicode_prop(CharRange *cr, const char *prop_name) extern "C" { #endif +typedef uint8_t *JSLoadFileFunc(JSContext *ctx, size_t *pbuf_len, + const char *filename); + JS_LIBC_EXTERN JSModuleDef *js_init_module_std(JSContext *ctx, const char *module_name); JS_LIBC_EXTERN JSModuleDef *js_init_module_os(JSContext *ctx, @@ -77992,9 +78385,13 @@ JS_LIBC_EXTERN int js_module_set_import_meta(JSContext *ctx, JSValueConst func_v JS_LIBC_EXTERN JSModuleDef *js_module_loader(JSContext *ctx, const char *module_name, void *opaque, JSValueConst attributes); +// like js_module_loader but does not load .so objects and the file reader +// is pluggable; js_module_loader is implemented in terms of js_module_load +JS_LIBC_EXTERN JSModuleDef *js_module_load(JSContext *ctx, const char *module_name, + void *opaque, JSValueConst attributes, + JSLoadFileFunc *load_file); JS_LIBC_EXTERN int js_module_check_attributes(JSContext *ctx, void *opaque, JSValueConst attributes); -JS_LIBC_EXTERN int js_module_test_json(JSContext *ctx, JSValueConst attributes); JS_LIBC_EXTERN void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len, int flags); JS_LIBC_EXTERN void js_std_promise_rejection_tracker(JSContext *ctx, @@ -78804,7 +79201,7 @@ int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val, return 0; } -static int json_module_init(JSContext *ctx, JSModuleDef *m) +static int default_module_init(JSContext *ctx, JSModuleDef *m) { JSValue val; val = JS_GetModulePrivateValue(ctx, m); @@ -78812,20 +79209,6 @@ static int json_module_init(JSContext *ctx, JSModuleDef *m) return 0; } -static JSModuleDef *create_json_module(JSContext *ctx, const char *module_name, JSValue val) -{ - JSModuleDef *m; - m = JS_NewCModule(ctx, module_name, json_module_init); - if (!m) { - JS_FreeValue(ctx, val); - return NULL; - } - /* only export the "default" symbol which will contain the JSON object */ - JS_AddModuleExport(ctx, m, "default"); - JS_SetModulePrivateValue(ctx, m, val); - return m; -} - /* in order to conform with the specification, only the keys should be tested and not the associated values. */ int js_module_check_attributes(JSContext *ctx, void *opaque, @@ -78858,8 +79241,14 @@ int js_module_check_attributes(JSContext *ctx, void *opaque, return ret; } +enum { + JS_IMPORT_TYPE_JS, + JS_IMPORT_TYPE_JSON, + JS_IMPORT_TYPE_TEXT, +}; + /* return > 0 if the attributes indicate a JSON module, 0 otherwise, -1 on error */ -int js_module_test_json(JSContext *ctx, JSValueConst attributes) +static int js_module_import_type(JSContext *ctx, JSValueConst attributes) { JSValue str; const char *cstr; @@ -78867,82 +79256,100 @@ int js_module_test_json(JSContext *ctx, JSValueConst attributes) int res; if (JS_IsUndefined(attributes)) - return 0; + return JS_IMPORT_TYPE_JS; str = JS_GetPropertyStr(ctx, attributes, "type"); if (JS_IsException(str)) return -1; if (!JS_IsString(str)) { JS_FreeValue(ctx, str); - return 0; + return JS_IMPORT_TYPE_JS; } cstr = JS_ToCStringLen(ctx, &len, str); JS_FreeValue(ctx, str); if (!cstr) return -1; if (len == 4 && !memcmp(cstr, "json", len)) { - res = 1; + res = JS_IMPORT_TYPE_JSON; + } else if (len == 4 && !memcmp(cstr, "text", len)) { + res = JS_IMPORT_TYPE_TEXT; } else { /* unknown type - throw error */ JS_ThrowTypeError(ctx, "unsupported module type: '%s'", cstr); - JS_FreeCString(ctx, cstr); - return -1; + res = -1; } JS_FreeCString(ctx, cstr); return res; } -JSModuleDef *js_module_loader(JSContext *ctx, - const char *module_name, void *opaque, - JSValueConst attributes) +JSModuleDef *js_module_load(JSContext *ctx, const char *module_name, + void *opaque, JSValueConst attributes, + JSLoadFileFunc *load_file) { JSModuleDef *m; + JSValue val; + size_t buf_len; + char *buf; + int type; - if (js__has_suffix(module_name, QJS_NATIVE_MODULE_SUFFIX)) { - m = js_module_loader_so(ctx, module_name); + type = js_module_import_type(ctx, attributes); + if (type < 0) + return NULL; + if (js__has_suffix(module_name, ".json")) + type = JS_IMPORT_TYPE_JSON; + buf = (char *)load_file(ctx, &buf_len, module_name); + if (!buf) { + JS_ThrowReferenceError(ctx, "could not load module filename '%s'", + module_name); + return NULL; + } + switch (type) { + case JS_IMPORT_TYPE_JS: + val = JS_Eval(ctx, buf, buf_len, module_name, + JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY); + break; + case JS_IMPORT_TYPE_JSON: + val = JS_ParseJSON(ctx, buf, buf_len, module_name); + break; + case JS_IMPORT_TYPE_TEXT: + val = JS_NewStringLen(ctx, buf, buf_len); + break; + default: + val = JS_ThrowInternalError(ctx, "unhandled import type"); + break; + } + js_free(ctx, buf); + if (JS_IsException(val)) + return NULL; + if (type == JS_IMPORT_TYPE_JS) { + if (js_module_set_import_meta(ctx, val, true, false) < 0) { + JS_FreeValue(ctx, val); + return NULL; + } + // the module is already referenced, so we must free it + m = JS_VALUE_GET_PTR(val); + JS_FreeValue(ctx, val); } else { - int res; - size_t buf_len; - uint8_t *buf; - - res = js_module_test_json(ctx, attributes); - if (res < 0) - return NULL; - buf = js_load_file(ctx, &buf_len, module_name); - if (!buf) { - JS_ThrowReferenceError(ctx, "could not load module filename '%s'", - module_name); + m = JS_NewCModule(ctx, module_name, default_module_init); + if (!m) { + JS_FreeValue(ctx, val); return NULL; } - if (js__has_suffix(module_name, ".json") || res > 0) { - /* compile as JSON */ - JSValue val; - val = JS_ParseJSON(ctx, (char *)buf, buf_len, module_name); - js_free(ctx, buf); - if (JS_IsException(val)) - return NULL; - m = create_json_module(ctx, module_name, val); - if (!m) - return NULL; - } else { - JSValue func_val; - /* compile the module */ - func_val = JS_Eval(ctx, (char *)buf, buf_len, module_name, - JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY); - js_free(ctx, buf); - if (JS_IsException(func_val)) - return NULL; - if (js_module_set_import_meta(ctx, func_val, true, false) < 0) { - JS_FreeValue(ctx, func_val); - return NULL; - } - /* the module is already referenced, so we must free it */ - m = JS_VALUE_GET_PTR(func_val); - JS_FreeValue(ctx, func_val); - } + // only export the "default" symbol which will contain the string + // or JSON object + JS_AddModuleExport(ctx, m, "default"); + JS_SetModulePrivateValue(ctx, m, val); } return m; } +JSModuleDef *js_module_loader(JSContext *ctx, const char *module_name, + void *opaque, JSValueConst attributes) +{ + if (js__has_suffix(module_name, QJS_NATIVE_MODULE_SUFFIX)) + return js_module_loader_so(ctx, module_name); + return js_module_load(ctx, module_name, opaque, attributes, js_load_file); +} + static JSValue js_std_exit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { @@ -79169,19 +79576,27 @@ static bool is_stdio(FILE *f) return f == stdin || f == stdout || f == stderr; } +static void safe_close(FILE *f, bool is_popen) +{ + if (!f) + return; + if (is_stdio(f)) + return; + if (is_popen) { +#if !defined(__wasi__) + pclose(f); +#endif + } else { + fclose(f); + } +} + static void js_std_file_finalizer(JSRuntime *rt, JSValueConst val) { JSThreadState *ts = js_get_thread_state(rt); JSSTDFile *s = JS_GetOpaque(val, ts->std_file_class_id); if (s) { - if (s->f && !is_stdio(s->f)) { -#if !defined(__wasi__) - if (s->is_popen) - pclose(s->f); - else -#endif - fclose(s->f); - } + safe_close(s->f, s->is_popen); js_free_rt(rt, s); } } @@ -79210,16 +79625,18 @@ static JSValue js_new_std_file(JSContext *ctx, FILE *f, bool is_popen) JSValue obj; obj = JS_NewObjectClass(ctx, ts->std_file_class_id); if (JS_IsException(obj)) - return obj; + goto exception; s = js_mallocz(ctx, sizeof(*s)); - if (!s) { - JS_FreeValue(ctx, obj); - return JS_EXCEPTION; - } + if (!s) + goto exception; s->is_popen = is_popen; s->f = f; JS_SetOpaque(obj, s); return obj; +exception: + safe_close(f, is_popen); + JS_FreeValue(ctx, obj); + return JS_EXCEPTION; } static void js_set_error_object(JSContext *ctx, JSValueConst obj, int err) @@ -79525,25 +79942,41 @@ static JSValue js_std_file_read_write(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic) { FILE *f = js_std_file_get(ctx, this_val); + bool is_write = (magic != 0); uint64_t pos, len; size_t size, ret; + const char *str; uint8_t *buf; if (!f) return JS_EXCEPTION; - if (JS_ToIndex(ctx, &pos, argv[1])) + pos = 0; + if (argc > 1 && JS_ToIndex(ctx, &pos, argv[1])) return JS_EXCEPTION; - if (JS_ToIndex(ctx, &len, argv[2])) + len = 0; + if (argc > 2 && JS_ToIndex(ctx, &len, argv[2])) return JS_EXCEPTION; - buf = JS_GetArrayBuffer(ctx, &size, argv[0]); + if (is_write && JS_IsString(argv[0])) { + str = JS_ToCStringLen(ctx, &size, argv[0]); + buf = (void *)str; + } else { + str = NULL; + buf = JS_GetArrayBuffer(ctx, &size, argv[0]); + } if (!buf) return JS_EXCEPTION; + if (pos > size) + pos = size; + if (argc < 3) + len = size - pos; if (pos + len > size) - return JS_ThrowRangeError(ctx, "read/write array buffer overflow"); - if (magic) + len = size - pos; + if (is_write) { ret = fwrite(buf + pos, 1, len, f); - else + } else { ret = fread(buf + pos, 1, len, f); + } + JS_FreeCString(ctx, str); return JS_NewInt64(ctx, ret); } @@ -79915,8 +80348,8 @@ static const JSCFunctionListEntry js_std_file_proto_funcs[] = { JS_CFUNC_DEF("fileno", 0, js_std_file_fileno ), JS_CFUNC_DEF("error", 0, js_std_file_error ), JS_CFUNC_DEF("clearerr", 0, js_std_file_clearerr ), - JS_CFUNC_MAGIC_DEF("read", 3, js_std_file_read_write, 0 ), - JS_CFUNC_MAGIC_DEF("write", 3, js_std_file_read_write, 1 ), + JS_CFUNC_MAGIC_DEF("read", 1, js_std_file_read_write, 0 ), + JS_CFUNC_MAGIC_DEF("write", 1, js_std_file_read_write, 1 ), JS_CFUNC_DEF("getline", 0, js_std_file_getline ), JS_CFUNC_MAGIC_DEF("readAsArrayBuffer", 0, js_std_file_readAs, 0 ), JS_CFUNC_MAGIC_DEF("readAsString", 0, js_std_file_readAs, 1 ), @@ -80947,17 +81380,13 @@ static JSValue make_obj_error(JSContext *ctx, JSValue obj, int err) { - JSValue arr; + JSValue vals[2]; + if (JS_IsException(obj)) return obj; - arr = JS_NewArray(ctx); - if (JS_IsException(arr)) - return JS_EXCEPTION; - JS_DefinePropertyValueUint32(ctx, arr, 0, obj, - JS_PROP_C_W_E); - JS_DefinePropertyValueUint32(ctx, arr, 1, JS_NewInt32(ctx, err), - JS_PROP_C_W_E); - return arr; + vals[0] = obj; + vals[1] = JS_NewInt32(ctx, err); + return JS_NewArrayFrom(ctx, countof(vals), vals); } static JSValue make_string_error(JSContext *ctx, @@ -81103,6 +81532,53 @@ done: #endif } +#if !defined(_WIN32) && !defined(__wasi__) +#define PAT "XXXXXX" +#define PSZ (sizeof(PAT)-1) +static JSValue js_os_mkdstemp(JSContext *ctx, JSValueConst this_val, + int argc, JSValueConst *argv, int magic) +{ + char pat_s[32] = "tmp"PAT, *pat = pat_s; + const char *s; + size_t k, n; + JSValue val; + int err; + + if (argc > 0) { + s = JS_ToCStringLen(ctx, &n, argv[0]); + if (!s) + return JS_EXCEPTION; + k = n; + if (n < PSZ || memcmp(&s[n-PSZ], PAT, PSZ)) + k += PSZ; + if (k >= sizeof(pat_s)) + pat = js_malloc(ctx, k+1); + if (pat) { + memcpy(pat, s, n); + if (n < k) + memcpy(&pat[n], PAT, PSZ); + pat[k] = '\0'; + } + JS_FreeCString(ctx, s); + if (!pat) + return JS_EXCEPTION; + } + if (magic == 'd') { + err = 0; + if (!mkdtemp(pat)) + err = -errno; + } else { + err = js_get_errno(mkstemp(pat)); + } + val = JS_NewString(ctx, pat); + if (pat != pat_s) + js_free(ctx, pat); + return make_obj_error(ctx, val, err); +} +#undef PSZ +#undef PAT +#endif // !defined(_WIN32) && !defined(__wasi__) + #if !defined(_WIN32) static int64_t timespec_to_ms(const struct timespec *tv) { @@ -82366,6 +82842,10 @@ static const JSCFunctionListEntry js_os_funcs[] = { JS_CFUNC_DEF("chdir", 0, js_os_chdir ), JS_CFUNC_DEF("mkdir", 1, js_os_mkdir ), JS_CFUNC_DEF("readdir", 1, js_os_readdir ), +#if !defined(_WIN32) && !defined(__wasi__) + JS_CFUNC_MAGIC_DEF("mkdtemp", 0, js_os_mkdstemp, 'd' ), + JS_CFUNC_MAGIC_DEF("mkstemp", 0, js_os_mkdstemp, 's' ), +#endif /* st_mode constants */ OS_FLAG(S_IFMT), OS_FLAG(S_IFIFO), @@ -82869,6 +83349,7 @@ static JSValue js_bjson_read(JSContext *ctx, JSValueConst this_val, return JS_EXCEPTION; if (JS_ToInt32(ctx, &flags, argv[3])) return JS_EXCEPTION; + flags &= ~JS_READ_OBJ_SAB; buf = JS_GetArrayBuffer(ctx, &size, argv[0]); if (!buf) return JS_EXCEPTION; @@ -82888,6 +83369,7 @@ static JSValue js_bjson_write(JSContext *ctx, JSValueConst this_val, if (JS_ToInt32(ctx, &flags, argv[1])) return JS_EXCEPTION; + flags &= ~JS_WRITE_OBJ_SAB; buf = JS_WriteObject(ctx, &len, argv[0], flags); if (!buf) return JS_EXCEPTION; @@ -82903,10 +83385,8 @@ static const JSCFunctionListEntry js_bjson_funcs[] = { #define DEF(x) JS_PROP_INT32_DEF(#x, JS_##x, JS_PROP_CONFIGURABLE) DEF(READ_OBJ_BYTECODE), DEF(READ_OBJ_REFERENCE), - DEF(READ_OBJ_SAB), DEF(WRITE_OBJ_BYTECODE), DEF(WRITE_OBJ_REFERENCE), - DEF(WRITE_OBJ_SAB), DEF(WRITE_OBJ_STRIP_DEBUG), DEF(WRITE_OBJ_STRIP_SOURCE), #undef DEF diff --git a/src/thirdparty/quickjs-ng/quickjs.h b/src/thirdparty/quickjs-ng/quickjs.h index 1117ea0269..9dac9837f0 100644 --- a/src/thirdparty/quickjs-ng/quickjs.h +++ b/src/thirdparty/quickjs-ng/quickjs.h @@ -1,10 +1,10 @@ /* * QuickJS Javascript Engine * - * Copyright (c) 2017-2024 Fabrice Bellard + * Copyright (c) 2017-2026 Fabrice Bellard * Copyright (c) 2017-2024 Charlie Gordon - * Copyright (c) 2023-2025 Ben Noordhuis - * Copyright (c) 2023-2025 Saúl Ibarra Corretgé + * Copyright (c) 2023-2026 Ben Noordhuis + * Copyright (c) 2023-2026 Saúl Ibarra Corretgé * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -545,20 +545,20 @@ JS_EXTERN JSValue JS_GetFunctionProto(JSContext *ctx); /* the following functions are used to select the intrinsic object to save memory */ JS_EXTERN JSContext *JS_NewContextRaw(JSRuntime *rt); -JS_EXTERN void JS_AddIntrinsicBaseObjects(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicDate(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicEval(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicBaseObjects(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicDate(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicEval(JSContext *ctx); JS_EXTERN void JS_AddIntrinsicRegExpCompiler(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicRegExp(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicJSON(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicProxy(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicMapSet(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicTypedArrays(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicPromise(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicBigInt(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicWeakRef(JSContext *ctx); -JS_EXTERN void JS_AddPerformance(JSContext *ctx); -JS_EXTERN void JS_AddIntrinsicDOMException(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicRegExp(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicJSON(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicProxy(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicMapSet(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicTypedArrays(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicPromise(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicBigInt(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicWeakRef(JSContext *ctx); +JS_EXTERN int JS_AddPerformance(JSContext *ctx); +JS_EXTERN int JS_AddIntrinsicDOMException(JSContext *ctx); /* for equality comparisons and sameness */ JS_EXTERN int JS_IsEqual(JSContext *ctx, JSValueConst op1, JSValueConst op2); @@ -1061,6 +1061,10 @@ JS_EXTERN JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size JS_EXTERN void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj); JS_EXTERN uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj); JS_EXTERN bool JS_IsArrayBuffer(JSValueConst obj); +// returns true or false if obj is an ArrayBuffer, -1 otherwise +JS_EXTERN int JS_IsImmutableArrayBuffer(JSValueConst obj); +// returns 0 if obj is an ArrayBuffer, -1 otherwise +JS_EXTERN int JS_SetImmutableArrayBuffer(JSValueConst obj, bool immutable); JS_EXTERN uint8_t *JS_GetUint8Array(JSContext *ctx, size_t *psize, JSValueConst obj); typedef enum JSTypedArrayEnum { @@ -1111,6 +1115,7 @@ JS_EXTERN JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValueConst promise); JS_EXTERN JSValue JS_PromiseResult(JSContext *ctx, JSValueConst promise); JS_EXTERN bool JS_IsPromise(JSValueConst val); +JS_EXTERN JSValue JS_NewSettledPromise(JSContext *ctx, bool is_reject, JSValueConst value); JS_EXTERN JSValue JS_NewSymbol(JSContext *ctx, const char *description, bool is_global); @@ -1152,6 +1157,11 @@ typedef struct JSModuleDef JSModuleDef; typedef char *JSModuleNormalizeFunc(JSContext *ctx, const char *module_base_name, const char *module_name, void *opaque); +typedef char *JSModuleNormalizeFunc2(JSContext *ctx, + const char *module_base_name, + const char *module_name, + JSValueConst attributes, + void *opaque); typedef JSModuleDef *JSModuleLoaderFunc(JSContext *ctx, const char *module_name, void *opaque); @@ -1177,6 +1187,10 @@ JS_EXTERN void JS_SetModuleLoaderFunc2(JSRuntime *rt, JSModuleCheckSupportedImportAttributes *module_check_attrs, void *opaque); +/* Set an attributes-aware module normalizer. Call after JS_SetModuleLoaderFunc2. */ +JS_EXTERN void JS_SetModuleNormalizeFunc2(JSRuntime *rt, + JSModuleNormalizeFunc2 *module_normalize); + /* return the import.meta object of a module */ JS_EXTERN JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m); JS_EXTERN JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m); @@ -1272,7 +1286,7 @@ JS_EXTERN JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func, JS_EXTERN JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func, const char *name, int length, JSCFunctionEnum cproto, int magic, - JSValueConst proto_val); + JSValueConst proto_val, int n_fields); JS_EXTERN JSValue JS_NewCFunctionData(JSContext *ctx, JSCFunctionData *func, int length, int magic, int data_len, JSValueConst *data); @@ -1301,8 +1315,8 @@ static inline JSValue JS_NewCFunctionMagic(JSContext *ctx, JSCFunctionMagic *fun ft.generic_magic = func; return JS_NewCFunction2(ctx, ft.generic, name, length, cproto, magic); } -JS_EXTERN void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj, - JSValueConst proto); +JS_EXTERN int JS_SetConstructor(JSContext *ctx, JSValueConst func_obj, + JSValueConst proto); /* C property definition */ @@ -1347,6 +1361,8 @@ typedef struct JSCFunctionListEntry { #define JS_DEF_PROP_UNDEFINED 7 #define JS_DEF_OBJECT 8 #define JS_DEF_ALIAS 9 +#define JS_DEF_PROP_SYMBOL 10 +#define JS_DEF_PROP_BOOL 11 /* Note: c++ does not like nested designators */ #define JS_CFUNC_DEF(name, length, func1) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, 0, { .func = { length, JS_CFUNC_generic, { .generic = func1 } } } } @@ -1363,6 +1379,8 @@ typedef struct JSCFunctionListEntry { #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_PROP_SYMBOL_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_SYMBOL, 0, { .i32 = val } } +#define JS_PROP_BOOL_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_BOOL, 0, { .i32 = val } } #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 } } } #define JS_ALIAS_BASE_DEF(name, from, base) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, { .alias = { from, base } } } @@ -1390,8 +1408,8 @@ JS_EXTERN int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m, /* Version */ #define QJS_VERSION_MAJOR 0 -#define QJS_VERSION_MINOR 12 -#define QJS_VERSION_PATCH 1 +#define QJS_VERSION_MINOR 13 +#define QJS_VERSION_PATCH 0 #define QJS_VERSION_SUFFIX "" JS_EXTERN const char* JS_GetVersion(void);