omdev-cext 0.0.72__tar.gz → 0.0.73__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {omdev_cext-0.0.72/omdev_cext.egg-info → omdev_cext-0.0.73}/PKG-INFO +2 -2
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/quickjs.c +303 -77
- {omdev_cext-0.0.72 → omdev_cext-0.0.73/omdev_cext.egg-info}/PKG-INFO +2 -2
- omdev_cext-0.0.73/omdev_cext.egg-info/requires.txt +1 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/pyproject.toml +2 -2
- omdev_cext-0.0.72/omdev_cext.egg-info/requires.txt +0 -1
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/LICENSE +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/MANIFEST.in +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/README.md +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/cexts/_boilerplate.cc +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_pyqjsng.c +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/builtin-array-fromasync.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/builtin-iterator-zip-keyed.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/builtin-iterator-zip.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/cutils.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/dtoa.c +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/dtoa.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/libregexp-opcode.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/libregexp.c +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/libregexp.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/libunicode-table.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/libunicode.c +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/libunicode.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/list.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/quickjs-atom.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/quickjs-c-atomics.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/quickjs-libc.c +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/quickjs-libc.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/quickjs-opcode.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/quickjs.h +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev_cext.egg-info/SOURCES.txt +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev_cext.egg-info/dependency_links.txt +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev_cext.egg-info/top_level.txt +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/setup.cfg +0 -0
- {omdev_cext-0.0.72 → omdev_cext-0.0.73}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: omdev-cext
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.73
|
|
4
4
|
Summary: omdev
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.15
|
|
|
14
14
|
Requires-Python: >=3.14
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: omdev==0.0.
|
|
17
|
+
Requires-Dist: omdev==0.0.73
|
|
18
18
|
Dynamic: license-file
|
|
19
19
|
|
|
20
20
|
# Overview
|
|
@@ -269,6 +269,14 @@ typedef struct JSMallocState {
|
|
|
269
269
|
#define JS_ARENA_MAX_SMALL_SIZE 512
|
|
270
270
|
#define JS_ARENA_FREE_NIL 0xffff
|
|
271
271
|
|
|
272
|
+
// gcc defines __SANITIZE_ADDRESS__ under -fsanitize=address, clang only
|
|
273
|
+
// answers __has_feature(address_sanitizer)
|
|
274
|
+
#if !defined(__SANITIZE_ADDRESS__) && defined(__has_feature)
|
|
275
|
+
#if __has_feature(address_sanitizer)
|
|
276
|
+
#define __SANITIZE_ADDRESS__ 1
|
|
277
|
+
#endif
|
|
278
|
+
#endif
|
|
279
|
+
|
|
272
280
|
#if defined(__SANITIZE_ADDRESS__) || defined(FORCE_GC_AT_MALLOC)
|
|
273
281
|
/* Route every allocation through the backing malloc so each block is seen
|
|
274
282
|
individually: ASan can then poison a freed block, and a GC-stress build
|
|
@@ -479,13 +487,13 @@ typedef struct JSVarRef {
|
|
|
479
487
|
is itself a GC object, so the cycle collector can see the closure ->
|
|
480
488
|
var_ref -> coroutine edge and keep the suspended coroutine (hence the
|
|
481
489
|
captured variable it points into) alive. The coroutine is recovered
|
|
482
|
-
as stack_frame->cur_gc_obj (valid while open).
|
|
483
|
-
|
|
484
|
-
cur_gc_obj
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
detach/free. */
|
|
490
|
+
as stack_frame->cur_gc_obj (valid while open). The flag says whether
|
|
491
|
+
this var_ref holds that reference; it is NOT rederived from
|
|
492
|
+
cur_gc_obj at read time. For a generator, cur_gc_obj is only set
|
|
493
|
+
after the initial resume: the var_refs created before that (mapped
|
|
494
|
+
`arguments`, closures in parameter initialisers) are adopted by
|
|
495
|
+
async_func_set_gc_obj(). Cleared when the var_ref is detached; the
|
|
496
|
+
ref is released on detach/free. */
|
|
489
497
|
uint8_t is_coro;
|
|
490
498
|
JSValue *pvalue; /* pointer to the value, either on the stack or
|
|
491
499
|
to 'value' */
|
|
@@ -780,6 +788,12 @@ typedef struct JSClosureVar {
|
|
|
780
788
|
#define ARG_SCOPE_INDEX 1
|
|
781
789
|
#define ARG_SCOPE_END (-2)
|
|
782
790
|
|
|
791
|
+
// decode the scope operand of OP_eval and OP_apply_eval
|
|
792
|
+
static inline int eval_scope_operand_decode(int operand)
|
|
793
|
+
{
|
|
794
|
+
return operand == 0xFFFF ? ARG_SCOPE_END : operand - 1;
|
|
795
|
+
}
|
|
796
|
+
|
|
783
797
|
typedef struct JSVarScope {
|
|
784
798
|
int parent; /* index into fd->scopes of the enclosing scope */
|
|
785
799
|
int first; /* index into fd->vars of the last variable in this scope */
|
|
@@ -1473,6 +1487,7 @@ static JSValue JS_EvalInternal(JSContext *ctx, JSValueConst this_obj,
|
|
|
1473
1487
|
const char *input, size_t input_len,
|
|
1474
1488
|
const char *filename, int line, int flags, int scope_idx);
|
|
1475
1489
|
static void js_free_module_def(JSContext *ctx, JSModuleDef *m);
|
|
1490
|
+
static void js_unresolve_modules(JSContext *ctx, JSModuleDef *failed);
|
|
1476
1491
|
static int js_module_attributes_equal(JSContext *ctx, JSValueConst attr1,
|
|
1477
1492
|
JSValueConst attr2);
|
|
1478
1493
|
static void js_mark_module_def(JSRuntime *rt, JSModuleDef *m,
|
|
@@ -2963,6 +2978,10 @@ typedef enum JSFreeModuleEnum {
|
|
|
2963
2978
|
static void js_free_modules(JSContext *ctx, JSFreeModuleEnum flag)
|
|
2964
2979
|
{
|
|
2965
2980
|
struct list_head *el, *el1;
|
|
2981
|
+
// a module that requests an unresolved module is not resolved either
|
|
2982
|
+
// and must go with it: it holds a pointer to it
|
|
2983
|
+
if (flag == JS_FREE_MODULE_NOT_RESOLVED)
|
|
2984
|
+
js_unresolve_modules(ctx, NULL);
|
|
2966
2985
|
list_for_each_safe(el, el1, &ctx->loaded_modules) {
|
|
2967
2986
|
JSModuleDef *m = list_entry(el, JSModuleDef, link);
|
|
2968
2987
|
if (flag == JS_FREE_MODULE_ALL ||
|
|
@@ -3541,12 +3560,16 @@ static JSAtom __JS_NewAtom(JSRuntime *rt, JSString *str, int atom_type)
|
|
|
3541
3560
|
}
|
|
3542
3561
|
|
|
3543
3562
|
if (str) {
|
|
3544
|
-
if (str->atom_type == 0) {
|
|
3563
|
+
if (str->atom_type == 0 && str->kind == JS_STRING_KIND_NORMAL) {
|
|
3545
3564
|
p = str;
|
|
3546
3565
|
p->atom_type = atom_type;
|
|
3547
3566
|
} else {
|
|
3548
|
-
|
|
3549
|
-
|
|
3567
|
+
// 'str' is already an atom of another type, or it is a slice
|
|
3568
|
+
// of another string. Make a flat copy: an atom owns its
|
|
3569
|
+
// characters, and JS_FreeAtomStruct() would not release the
|
|
3570
|
+
// parent of a slice.
|
|
3571
|
+
size_t size = (size_t)str->len << str->is_wide_char;
|
|
3572
|
+
p = js_malloc_rt(rt, sizeof(JSString) + size +
|
|
3550
3573
|
1 - str->is_wide_char);
|
|
3551
3574
|
if (unlikely(!p))
|
|
3552
3575
|
goto fail;
|
|
@@ -3557,8 +3580,10 @@ static JSAtom __JS_NewAtom(JSRuntime *rt, JSString *str, int atom_type)
|
|
|
3557
3580
|
#ifdef ENABLE_DUMPS // JS_DUMP_LEAKS
|
|
3558
3581
|
list_add_tail(&p->link, &rt->string_list);
|
|
3559
3582
|
#endif
|
|
3560
|
-
memcpy(str8(p), str8(str),
|
|
3561
|
-
|
|
3583
|
+
memcpy(str8(p), str8(str), size);
|
|
3584
|
+
// the characters of a slice are not followed by a null byte
|
|
3585
|
+
if (!str->is_wide_char)
|
|
3586
|
+
str8(p)[size] = '\0';
|
|
3562
3587
|
js_free_string(rt, str);
|
|
3563
3588
|
}
|
|
3564
3589
|
} else {
|
|
@@ -7174,7 +7199,15 @@ static void js_free_value_rt(JSRuntime *rt, JSValue v)
|
|
|
7174
7199
|
}
|
|
7175
7200
|
break;
|
|
7176
7201
|
case JS_TAG_MODULE:
|
|
7177
|
-
|
|
7202
|
+
{
|
|
7203
|
+
// The module list of the context holds a reference, so the
|
|
7204
|
+
// last one can only go away after js_free_module_def() has
|
|
7205
|
+
// released the contents and unlinked the definition.
|
|
7206
|
+
JSModuleDef *m = JS_VALUE_GET_PTR(v);
|
|
7207
|
+
if (m->link.next != NULL)
|
|
7208
|
+
abort();
|
|
7209
|
+
js_free_rt(rt, m);
|
|
7210
|
+
}
|
|
7178
7211
|
break;
|
|
7179
7212
|
case JS_TAG_BIG_INT:
|
|
7180
7213
|
{
|
|
@@ -18733,7 +18766,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
|
|
|
18733
18766
|
JSValue obj;
|
|
18734
18767
|
int scope_idx;
|
|
18735
18768
|
call_argc = get_u16(pc);
|
|
18736
|
-
scope_idx = get_u16(pc + 2)
|
|
18769
|
+
scope_idx = eval_scope_operand_decode(get_u16(pc + 2));
|
|
18737
18770
|
pc += 4;
|
|
18738
18771
|
call_argv = sp - call_argc;
|
|
18739
18772
|
sf->cur_pc = pc;
|
|
@@ -18765,7 +18798,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
|
|
|
18765
18798
|
JSValue *tab;
|
|
18766
18799
|
JSValue obj;
|
|
18767
18800
|
|
|
18768
|
-
scope_idx = get_u16(pc)
|
|
18801
|
+
scope_idx = eval_scope_operand_decode(get_u16(pc));
|
|
18769
18802
|
pc += 2;
|
|
18770
18803
|
sf->cur_pc = pc;
|
|
18771
18804
|
tab = build_arg_list(ctx, &len, sp[-1]);
|
|
@@ -21207,6 +21240,31 @@ static __exception int async_func_init(JSContext *ctx, JSAsyncFunctionState *s,
|
|
|
21207
21240
|
return 0;
|
|
21208
21241
|
}
|
|
21209
21242
|
|
|
21243
|
+
// Set the GC object that owns the frame of a generator, once it exists.
|
|
21244
|
+
// The generator object is created after the function prologue has run
|
|
21245
|
+
// (up to OP_initial_yield), and the prologue can already create open
|
|
21246
|
+
// var_refs: it builds the mapped arguments object and evaluates the
|
|
21247
|
+
// parameter initialisers, which may create closures. Those var_refs were
|
|
21248
|
+
// created without an owner. Make them hold a reference to the generator
|
|
21249
|
+
// like the ones created later, otherwise nothing keeps the frame they
|
|
21250
|
+
// point into alive.
|
|
21251
|
+
static void async_func_set_gc_obj(JSRuntime *rt, JSAsyncFunctionState *s,
|
|
21252
|
+
JSGCObjectHeader *gc_obj)
|
|
21253
|
+
{
|
|
21254
|
+
JSStackFrame *sf = &s->frame;
|
|
21255
|
+
int i;
|
|
21256
|
+
|
|
21257
|
+
sf->cur_gc_obj = gc_obj;
|
|
21258
|
+
for(i = 0; i < sf->var_ref_count; i++) {
|
|
21259
|
+
JSVarRef *var_ref = sf->var_refs[i];
|
|
21260
|
+
if (var_ref && !var_ref->is_coro) {
|
|
21261
|
+
var_ref->is_coro = true;
|
|
21262
|
+
JS_REF_COUNT(gc_obj)++;
|
|
21263
|
+
add_gc_object(rt, &var_ref->header, JS_GC_OBJ_TYPE_VAR_REF);
|
|
21264
|
+
}
|
|
21265
|
+
}
|
|
21266
|
+
}
|
|
21267
|
+
|
|
21210
21268
|
static void async_func_mark(JSRuntime *rt, JSAsyncFunctionState *s,
|
|
21211
21269
|
JS_MarkFunc *mark_func)
|
|
21212
21270
|
{
|
|
@@ -21432,10 +21490,10 @@ static JSValue js_call_generator_function(JSContext *ctx, JSValueConst func_obj,
|
|
|
21432
21490
|
if (JS_IsException(obj))
|
|
21433
21491
|
goto fail;
|
|
21434
21492
|
JS_SetOpaqueInternal(obj, s);
|
|
21435
|
-
|
|
21436
|
-
|
|
21437
|
-
|
|
21438
|
-
|
|
21493
|
+
// root captured locals against the generator object from now on,
|
|
21494
|
+
// including those captured while the prologue ran
|
|
21495
|
+
async_func_set_gc_obj(ctx->rt, &s->func_state,
|
|
21496
|
+
&JS_VALUE_GET_OBJ(obj)->header);
|
|
21439
21497
|
return obj;
|
|
21440
21498
|
fail:
|
|
21441
21499
|
free_generator_stack_rt(ctx->rt, s);
|
|
@@ -22088,9 +22146,9 @@ static JSValue js_async_generator_function_call(JSContext *ctx,
|
|
|
22088
22146
|
if (JS_IsException(obj))
|
|
22089
22147
|
goto fail;
|
|
22090
22148
|
s->generator = JS_VALUE_GET_OBJ(obj);
|
|
22091
|
-
|
|
22092
|
-
|
|
22093
|
-
s->func_state
|
|
22149
|
+
// root captured locals against the async generator object from now
|
|
22150
|
+
// on, including those captured while the prologue ran
|
|
22151
|
+
async_func_set_gc_obj(ctx->rt, &s->func_state, &s->generator->header);
|
|
22094
22152
|
JS_SetOpaqueInternal(obj, s);
|
|
22095
22153
|
return obj;
|
|
22096
22154
|
fail:
|
|
@@ -22317,6 +22375,11 @@ typedef struct JSFunctionDef {
|
|
|
22317
22375
|
bool need_home_object : 1;
|
|
22318
22376
|
bool use_short_opcodes : 1; /* true if short opcodes are used in byte_code */
|
|
22319
22377
|
bool has_await : 1; /* true if await is used (used in module eval) */
|
|
22378
|
+
// set when a variable, argument or closure variable could not be
|
|
22379
|
+
// added (limit reached or out of memory). The exception is pending.
|
|
22380
|
+
// Most callers in the variable resolver cannot report a failure, so
|
|
22381
|
+
// js_create_function() checks this instead.
|
|
22382
|
+
bool has_compile_error : 1;
|
|
22320
22383
|
|
|
22321
22384
|
JSFunctionKindEnum func_kind : 8;
|
|
22322
22385
|
JSParseFunctionEnum func_type : 7;
|
|
@@ -24454,18 +24517,21 @@ static int add_var(JSContext *ctx, JSFunctionDef *fd, JSAtom name)
|
|
|
24454
24517
|
// XXX: add_var() should take JSParseState *s and use js_parse_error
|
|
24455
24518
|
JS_ThrowSyntaxError(ctx, "too many variables declared (only %d allowed)",
|
|
24456
24519
|
JS_MAX_LOCAL_VARS - 1);
|
|
24457
|
-
|
|
24520
|
+
goto fail;
|
|
24458
24521
|
}
|
|
24459
24522
|
if (js_resize_array(ctx, (void **)&fd->vars, sizeof(fd->vars[0]),
|
|
24460
24523
|
&fd->var_size, fd->var_count + 1))
|
|
24461
|
-
|
|
24524
|
+
goto fail;
|
|
24462
24525
|
vd = &fd->vars[fd->var_count++];
|
|
24463
24526
|
memset(vd, 0, sizeof(*vd));
|
|
24464
24527
|
vd->var_name = JS_DupAtom(ctx, name);
|
|
24465
24528
|
vd->func_pool_idx = -1;
|
|
24466
24529
|
if (update_var_htab(ctx, fd))
|
|
24467
|
-
|
|
24530
|
+
goto fail;
|
|
24468
24531
|
return fd->var_count - 1;
|
|
24532
|
+
fail:
|
|
24533
|
+
fd->has_compile_error = true;
|
|
24534
|
+
return -1;
|
|
24469
24535
|
}
|
|
24470
24536
|
|
|
24471
24537
|
static int add_scope_var(JSContext *ctx, JSFunctionDef *fd, JSAtom name,
|
|
@@ -24538,16 +24604,19 @@ static int add_arg(JSContext *ctx, JSFunctionDef *fd, JSAtom name)
|
|
|
24538
24604
|
// XXX: add_arg() should take JSParseState *s and use js_parse_error
|
|
24539
24605
|
JS_ThrowSyntaxError(ctx, "too many parameters in function definition (only %d allowed)",
|
|
24540
24606
|
JS_MAX_LOCAL_VARS - 1);
|
|
24541
|
-
|
|
24607
|
+
goto fail;
|
|
24542
24608
|
}
|
|
24543
24609
|
if (js_resize_array(ctx, (void **)&fd->args, sizeof(fd->args[0]),
|
|
24544
24610
|
&fd->arg_size, fd->arg_count + 1))
|
|
24545
|
-
|
|
24611
|
+
goto fail;
|
|
24546
24612
|
vd = &fd->args[fd->arg_count++];
|
|
24547
24613
|
memset(vd, 0, sizeof(*vd));
|
|
24548
24614
|
vd->var_name = JS_DupAtom(ctx, name);
|
|
24549
24615
|
vd->func_pool_idx = -1;
|
|
24550
24616
|
return fd->arg_count - 1;
|
|
24617
|
+
fail:
|
|
24618
|
+
fd->has_compile_error = true;
|
|
24619
|
+
return -1;
|
|
24551
24620
|
}
|
|
24552
24621
|
|
|
24553
24622
|
/* add a global variable definition */
|
|
@@ -27317,6 +27386,10 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags)
|
|
|
27317
27386
|
if (s->token.val == '(') {
|
|
27318
27387
|
if (!s->cur_func->super_call_allowed)
|
|
27319
27388
|
return js_parse_error(s, "super() is only valid in a derived class constructor");
|
|
27389
|
+
// `new super()`: the operand of `new` is parsed without the
|
|
27390
|
+
// call, so nothing would be pushed for it
|
|
27391
|
+
if (!accept_lparen)
|
|
27392
|
+
return js_parse_error(s, "'super' keyword unexpected here");
|
|
27320
27393
|
call_type = FUNC_CALL_SUPER_CTOR;
|
|
27321
27394
|
} else if (s->token.val == '.' || s->token.val == '[') {
|
|
27322
27395
|
if (!s->cur_func->super_allowed)
|
|
@@ -29096,6 +29169,10 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name,
|
|
|
29096
29169
|
bool is_await_using = false;
|
|
29097
29170
|
if (tok == TOK_AWAIT) {
|
|
29098
29171
|
int u;
|
|
29172
|
+
// 'await' is also a token in the plain functions of a module and
|
|
29173
|
+
// in class static blocks, where there is nothing to await in
|
|
29174
|
+
if (!(s->cur_func->func_kind & JS_FUNC_ASYNC))
|
|
29175
|
+
return js_parse_error(s, "unexpected 'await' keyword");
|
|
29099
29176
|
if (next_token(s))
|
|
29100
29177
|
return -1;
|
|
29101
29178
|
u = is_using(s, false);
|
|
@@ -30381,7 +30458,15 @@ static void js_free_module_def(JSContext *ctx, JSModuleDef *m)
|
|
|
30381
30458
|
JS_FreeValue(ctx, m->private_value);
|
|
30382
30459
|
JS_FreeValue(ctx, m->attributes);
|
|
30383
30460
|
list_del(&m->link);
|
|
30384
|
-
|
|
30461
|
+
// JS_TAG_MODULE values hold references to the definition and can
|
|
30462
|
+
// outlive it: the reactions attached to the evaluation promise of a
|
|
30463
|
+
// module with a pending top-level await are only freed with the
|
|
30464
|
+
// runtime, after the context and its module list. Drop the reference
|
|
30465
|
+
// of the list; the memory goes with the last one. Until then leave
|
|
30466
|
+
// nothing dangling behind.
|
|
30467
|
+
memset(m, 0, sizeof(*m));
|
|
30468
|
+
if (--JS_REF_COUNT(m) == 0)
|
|
30469
|
+
js_free(ctx, m);
|
|
30385
30470
|
}
|
|
30386
30471
|
|
|
30387
30472
|
#ifndef QJS_DISABLE_PARSER
|
|
@@ -31364,14 +31449,61 @@ static int js_resolve_module(JSContext *ctx, JSModuleDef *m)
|
|
|
31364
31449
|
rme->module_name,
|
|
31365
31450
|
rme->attributes);
|
|
31366
31451
|
if (!m1)
|
|
31367
|
-
|
|
31452
|
+
goto fail;
|
|
31368
31453
|
rme->module = m1;
|
|
31369
31454
|
/* already done in js_host_resolve_imported_module() except if
|
|
31370
31455
|
the module was loaded with JS_EvalBinary() */
|
|
31371
31456
|
if (js_resolve_module(ctx, m1) < 0)
|
|
31372
|
-
|
|
31457
|
+
goto fail;
|
|
31373
31458
|
}
|
|
31374
31459
|
return 0;
|
|
31460
|
+
fail:
|
|
31461
|
+
// the flag was set early to stop at import cycles
|
|
31462
|
+
m->resolved = false;
|
|
31463
|
+
return -1;
|
|
31464
|
+
}
|
|
31465
|
+
|
|
31466
|
+
// Modules are marked as resolved before their requested modules are, so
|
|
31467
|
+
// that import cycles terminate. When resolution then fails, a module in
|
|
31468
|
+
// such a cycle is left marked as resolved although it requests, directly
|
|
31469
|
+
// or not, a module that is not: reset those.
|
|
31470
|
+
//
|
|
31471
|
+
// 'failed', if not NULL, is a module about to be freed: also remove the
|
|
31472
|
+
// pointers that other modules recorded to it. They are resolved again
|
|
31473
|
+
// when they are next needed.
|
|
31474
|
+
static void js_unresolve_modules(JSContext *ctx, JSModuleDef *failed)
|
|
31475
|
+
{
|
|
31476
|
+
struct list_head *el;
|
|
31477
|
+
bool changed;
|
|
31478
|
+
int i;
|
|
31479
|
+
|
|
31480
|
+
if (failed)
|
|
31481
|
+
failed->resolved = false;
|
|
31482
|
+
do {
|
|
31483
|
+
changed = false;
|
|
31484
|
+
list_for_each(el, &ctx->loaded_modules) {
|
|
31485
|
+
JSModuleDef *m = list_entry(el, JSModuleDef, link);
|
|
31486
|
+
if (!m->resolved)
|
|
31487
|
+
continue;
|
|
31488
|
+
for(i = 0; i < m->req_module_entries_count; i++) {
|
|
31489
|
+
JSModuleDef *m1 = m->req_module_entries[i].module;
|
|
31490
|
+
if (m1 && !m1->resolved) {
|
|
31491
|
+
m->resolved = false;
|
|
31492
|
+
changed = true;
|
|
31493
|
+
break;
|
|
31494
|
+
}
|
|
31495
|
+
}
|
|
31496
|
+
}
|
|
31497
|
+
} while (changed);
|
|
31498
|
+
if (failed) {
|
|
31499
|
+
list_for_each(el, &ctx->loaded_modules) {
|
|
31500
|
+
JSModuleDef *m = list_entry(el, JSModuleDef, link);
|
|
31501
|
+
for(i = 0; i < m->req_module_entries_count; i++) {
|
|
31502
|
+
if (m->req_module_entries[i].module == failed)
|
|
31503
|
+
m->req_module_entries[i].module = NULL;
|
|
31504
|
+
}
|
|
31505
|
+
}
|
|
31506
|
+
}
|
|
31375
31507
|
}
|
|
31376
31508
|
|
|
31377
31509
|
static JSVarRef *js_create_module_var(JSContext *ctx, bool is_lexical)
|
|
@@ -32277,7 +32409,7 @@ static int js_execute_async_module(JSContext *ctx, JSModuleDef *m)
|
|
|
32277
32409
|
return -1;
|
|
32278
32410
|
m_obj = JS_NewModuleValue(ctx, m);
|
|
32279
32411
|
resolve_funcs[0] = JS_NewCFunctionData(ctx, js_async_module_execution_fulfilled, 0, 0, 1, vc(&m_obj));
|
|
32280
|
-
resolve_funcs[1] = JS_NewCFunctionData(ctx, js_async_module_execution_rejected,
|
|
32412
|
+
resolve_funcs[1] = JS_NewCFunctionData(ctx, js_async_module_execution_rejected, 1, 0, 1, vc(&m_obj));
|
|
32281
32413
|
ret_val = js_promise_then(ctx, promise, 2, vc(resolve_funcs));
|
|
32282
32414
|
JS_FreeValue(ctx, ret_val);
|
|
32283
32415
|
JS_FreeValue(ctx, m_obj);
|
|
@@ -33683,13 +33815,13 @@ static int add_closure_var(JSContext *ctx, JSFunctionDef *s,
|
|
|
33683
33815
|
// XXX: add_closure_var() should take JSParseState *s and use js_parse_error
|
|
33684
33816
|
JS_ThrowSyntaxError(ctx, "too many closure variables used (only %d allowed)",
|
|
33685
33817
|
JS_MAX_LOCAL_VARS - 1);
|
|
33686
|
-
|
|
33818
|
+
goto fail;
|
|
33687
33819
|
}
|
|
33688
33820
|
|
|
33689
33821
|
if (js_resize_array(ctx, (void **)&s->closure_var,
|
|
33690
33822
|
sizeof(s->closure_var[0]),
|
|
33691
33823
|
&s->closure_var_size, s->closure_var_count + 1))
|
|
33692
|
-
|
|
33824
|
+
goto fail;
|
|
33693
33825
|
cv = &s->closure_var[s->closure_var_count++];
|
|
33694
33826
|
cv->closure_type = closure_type;
|
|
33695
33827
|
cv->is_const = is_const;
|
|
@@ -33698,6 +33830,9 @@ static int add_closure_var(JSContext *ctx, JSFunctionDef *s,
|
|
|
33698
33830
|
cv->var_idx = var_idx;
|
|
33699
33831
|
cv->var_name = JS_DupAtom(ctx, var_name);
|
|
33700
33832
|
return s->closure_var_count - 1;
|
|
33833
|
+
fail:
|
|
33834
|
+
s->has_compile_error = true;
|
|
33835
|
+
return -1;
|
|
33701
33836
|
}
|
|
33702
33837
|
|
|
33703
33838
|
static int find_closure_var(JSContext *ctx, JSFunctionDef *s,
|
|
@@ -33726,8 +33861,10 @@ static int get_closure_var(JSContext *ctx, JSFunctionDef *s,
|
|
|
33726
33861
|
var_idx = get_closure_var(ctx, s->parent, fd, closure_type,
|
|
33727
33862
|
var_idx, var_name,
|
|
33728
33863
|
is_const, is_lexical, var_kind);
|
|
33729
|
-
if (var_idx < 0)
|
|
33864
|
+
if (var_idx < 0) {
|
|
33865
|
+
s->has_compile_error = true;
|
|
33730
33866
|
return -1;
|
|
33867
|
+
}
|
|
33731
33868
|
if (closure_type != JS_CLOSURE_GLOBAL_REF)
|
|
33732
33869
|
closure_type = JS_CLOSURE_REF;
|
|
33733
33870
|
}
|
|
@@ -33923,6 +34060,17 @@ static void var_object_test(JSContext *ctx, JSFunctionDef *s,
|
|
|
33923
34060
|
static inline void capture_var(JSFunctionDef *s, JSVarDef *vd)
|
|
33924
34061
|
{
|
|
33925
34062
|
if (!vd->is_captured) {
|
|
34063
|
+
// the variable reference indexes and their count are stored on
|
|
34064
|
+
// 16 bits. Arguments and variables are limited separately, so
|
|
34065
|
+
// together they can exceed that.
|
|
34066
|
+
if (s->var_ref_count >= JS_MAX_LOCAL_VARS) {
|
|
34067
|
+
if (!s->has_compile_error) {
|
|
34068
|
+
JS_ThrowSyntaxError(s->ctx, "too many captured variables (only %d allowed)",
|
|
34069
|
+
JS_MAX_LOCAL_VARS);
|
|
34070
|
+
s->has_compile_error = true;
|
|
34071
|
+
}
|
|
34072
|
+
return;
|
|
34073
|
+
}
|
|
33926
34074
|
vd->is_captured = 1;
|
|
33927
34075
|
vd->var_ref_idx = s->var_ref_count++;
|
|
33928
34076
|
}
|
|
@@ -34818,6 +34966,15 @@ static __exception int add_closure_variables(JSContext *ctx, JSFunctionDef *s,
|
|
|
34818
34966
|
cv->var_idx = i;
|
|
34819
34967
|
cv->var_name = JS_DupAtom(ctx, cv0->var_name);
|
|
34820
34968
|
}
|
|
34969
|
+
// same limit as add_closure_var(): the indexes and the count are
|
|
34970
|
+
// stored on 16 bits. The arguments, variables and closure variables
|
|
34971
|
+
// of the calling function are limited separately, so their sum can
|
|
34972
|
+
// exceed it.
|
|
34973
|
+
if (s->closure_var_count > JS_MAX_LOCAL_VARS) {
|
|
34974
|
+
JS_ThrowSyntaxError(ctx, "too many closure variables used (only %d allowed)",
|
|
34975
|
+
JS_MAX_LOCAL_VARS - 1);
|
|
34976
|
+
return -1;
|
|
34977
|
+
}
|
|
34821
34978
|
return 0;
|
|
34822
34979
|
}
|
|
34823
34980
|
|
|
@@ -35174,6 +35331,25 @@ static int get_label_pos(JSFunctionDef *s, int label)
|
|
|
35174
35331
|
|
|
35175
35332
|
/* convert global variable accesses to local variables or closure
|
|
35176
35333
|
variables when necessary */
|
|
35334
|
+
// The scope operand of OP_eval and OP_apply_eval is the index of the first
|
|
35335
|
+
// variable of the scope, stored on 16 bits as index + 1 so that -1 (no
|
|
35336
|
+
// variable) fits. 0xFFFF stands for ARG_SCOPE_END, the end of an argument
|
|
35337
|
+
// scope that has no variable of its own; see eval_scope_operand_decode().
|
|
35338
|
+
// Return -1 if the index cannot be encoded.
|
|
35339
|
+
#define EVAL_SCOPE_ARG_END 0xFFFF
|
|
35340
|
+
|
|
35341
|
+
static int eval_scope_operand(JSContext *ctx, int first)
|
|
35342
|
+
{
|
|
35343
|
+
if (first == ARG_SCOPE_END)
|
|
35344
|
+
return EVAL_SCOPE_ARG_END;
|
|
35345
|
+
if (first + 1 >= EVAL_SCOPE_ARG_END) {
|
|
35346
|
+
JS_ThrowSyntaxError(ctx, "too many variables declared (only %d allowed)",
|
|
35347
|
+
JS_MAX_LOCAL_VARS - 1);
|
|
35348
|
+
return -1;
|
|
35349
|
+
}
|
|
35350
|
+
return first + 1;
|
|
35351
|
+
}
|
|
35352
|
+
|
|
35177
35353
|
static __exception int resolve_variables(JSContext *ctx, JSFunctionDef *s)
|
|
35178
35354
|
{
|
|
35179
35355
|
int pos, pos_next, bc_len, op, len, i, idx, line_num, col_num;
|
|
@@ -35242,18 +35418,28 @@ static __exception int resolve_variables(JSContext *ctx, JSFunctionDef *s)
|
|
|
35242
35418
|
case OP_eval: /* convert scope index to adjusted variable index */
|
|
35243
35419
|
{
|
|
35244
35420
|
int call_argc = get_u16(bc_buf + pos + 1);
|
|
35421
|
+
int operand;
|
|
35245
35422
|
scope = get_u16(bc_buf + pos + 1 + 2);
|
|
35246
35423
|
mark_eval_captured_variables(ctx, s, scope);
|
|
35424
|
+
operand = eval_scope_operand(ctx, s->scopes[scope].first);
|
|
35425
|
+
if (operand < 0)
|
|
35426
|
+
goto fail;
|
|
35247
35427
|
dbuf_putc(&bc_out, op);
|
|
35248
35428
|
dbuf_put_u16(&bc_out, call_argc);
|
|
35249
|
-
dbuf_put_u16(&bc_out,
|
|
35429
|
+
dbuf_put_u16(&bc_out, operand);
|
|
35250
35430
|
}
|
|
35251
35431
|
break;
|
|
35252
35432
|
case OP_apply_eval: /* convert scope index to adjusted variable index */
|
|
35253
|
-
|
|
35254
|
-
|
|
35255
|
-
|
|
35256
|
-
|
|
35433
|
+
{
|
|
35434
|
+
int operand;
|
|
35435
|
+
scope = get_u16(bc_buf + pos + 1);
|
|
35436
|
+
mark_eval_captured_variables(ctx, s, scope);
|
|
35437
|
+
operand = eval_scope_operand(ctx, s->scopes[scope].first);
|
|
35438
|
+
if (operand < 0)
|
|
35439
|
+
goto fail;
|
|
35440
|
+
dbuf_putc(&bc_out, op);
|
|
35441
|
+
dbuf_put_u16(&bc_out, operand);
|
|
35442
|
+
}
|
|
35257
35443
|
break;
|
|
35258
35444
|
case OP_scope_get_var_undef:
|
|
35259
35445
|
case OP_scope_get_var:
|
|
@@ -37097,6 +37283,8 @@ static JSValue js_create_function(JSContext *ctx, JSFunctionDef *fd)
|
|
|
37097
37283
|
|
|
37098
37284
|
if (resolve_variables(ctx, fd))
|
|
37099
37285
|
goto fail;
|
|
37286
|
+
if (fd->has_compile_error)
|
|
37287
|
+
goto fail;
|
|
37100
37288
|
|
|
37101
37289
|
#ifdef ENABLE_DUMPS // JS_DUMP_BYTECODE_PASS2
|
|
37102
37290
|
if (check_dump_flag(ctx->rt, JS_DUMP_BYTECODE_PASS2)) {
|
|
@@ -37112,6 +37300,8 @@ static JSValue js_create_function(JSContext *ctx, JSFunctionDef *fd)
|
|
|
37112
37300
|
|
|
37113
37301
|
if (resolve_labels(ctx, fd))
|
|
37114
37302
|
goto fail;
|
|
37303
|
+
if (fd->has_compile_error)
|
|
37304
|
+
goto fail;
|
|
37115
37305
|
|
|
37116
37306
|
if (compute_stack_size(ctx, fd, &stack_size) < 0)
|
|
37117
37307
|
goto fail;
|
|
@@ -37673,6 +37863,8 @@ static __exception int js_parse_function_decl2(JSParseState *s,
|
|
|
37673
37863
|
} else {
|
|
37674
37864
|
/* unnamed arg for destructuring */
|
|
37675
37865
|
idx = add_arg(ctx, fd, JS_ATOM_NULL);
|
|
37866
|
+
if (idx < 0)
|
|
37867
|
+
goto fail;
|
|
37676
37868
|
emit_op(s, OP_get_arg);
|
|
37677
37869
|
emit_u16(s, idx);
|
|
37678
37870
|
}
|
|
@@ -38320,9 +38512,12 @@ static JSValue __JS_EvalInternal(JSContext *ctx, JSValueConst this_obj,
|
|
|
38320
38512
|
}
|
|
38321
38513
|
return ret_val;
|
|
38322
38514
|
fail1:
|
|
38323
|
-
|
|
38324
|
-
|
|
38515
|
+
if (m) {
|
|
38516
|
+
// modules that were resolved while this one was being resolved
|
|
38517
|
+
// (import cycles) may point to it
|
|
38518
|
+
js_unresolve_modules(ctx, m);
|
|
38325
38519
|
js_free_module_def(ctx, m);
|
|
38520
|
+
}
|
|
38326
38521
|
return JS_EXCEPTION;
|
|
38327
38522
|
}
|
|
38328
38523
|
|
|
@@ -40026,10 +40221,9 @@ static JSValue JS_ReadModule(BCReaderState *s)
|
|
|
40026
40221
|
m = js_new_module_def(ctx, module_name);
|
|
40027
40222
|
if (!m)
|
|
40028
40223
|
goto fail;
|
|
40029
|
-
obj =
|
|
40224
|
+
obj = JS_NewModuleValue(ctx, m);
|
|
40030
40225
|
if (bc_get_leb128_int(s, &m->req_module_entries_count))
|
|
40031
40226
|
goto fail;
|
|
40032
|
-
obj = JS_NewModuleValue(ctx, m);
|
|
40033
40227
|
if (m->req_module_entries_count != 0) {
|
|
40034
40228
|
m->req_module_entries_size = m->req_module_entries_count;
|
|
40035
40229
|
m->req_module_entries = js_mallocz(ctx, sizeof(m->req_module_entries[0]) * m->req_module_entries_size);
|
|
@@ -40126,6 +40320,7 @@ static JSValue JS_ReadModule(BCReaderState *s)
|
|
|
40126
40320
|
fail:
|
|
40127
40321
|
if (m) {
|
|
40128
40322
|
js_free_module_def(ctx, m);
|
|
40323
|
+
JS_FreeValue(ctx, obj);
|
|
40129
40324
|
}
|
|
40130
40325
|
return JS_EXCEPTION;
|
|
40131
40326
|
}
|
|
@@ -47330,6 +47525,8 @@ slow_path:
|
|
|
47330
47525
|
static int string_cmp(JSString *p1, JSString *p2, int x1, int x2, int len)
|
|
47331
47526
|
{
|
|
47332
47527
|
int i, c1, c2;
|
|
47528
|
+
if (!p1->is_wide_char && !p2->is_wide_char)
|
|
47529
|
+
return memcmp(str8(p1) + x1, str8(p2) + x2, len);
|
|
47333
47530
|
for (i = 0; i < len; i++) {
|
|
47334
47531
|
if ((c1 = string_get(p1, x1 + i)) != (c2 = string_get(p2, x2 + i)))
|
|
47335
47532
|
return c1 - c2;
|
|
@@ -47347,11 +47544,10 @@ static int string_indexof_char(JSString *p, int c, int from)
|
|
|
47347
47544
|
return i;
|
|
47348
47545
|
}
|
|
47349
47546
|
} else {
|
|
47350
|
-
if ((c & ~0xff) == 0) {
|
|
47351
|
-
|
|
47352
|
-
|
|
47353
|
-
|
|
47354
|
-
}
|
|
47547
|
+
if ((c & ~0xff) == 0 && from < len) {
|
|
47548
|
+
const uint8_t *q = memchr(str8(p) + from, c, len - from);
|
|
47549
|
+
if (q)
|
|
47550
|
+
return q - str8(p);
|
|
47355
47551
|
}
|
|
47356
47552
|
}
|
|
47357
47553
|
return -1;
|
|
@@ -47505,7 +47701,10 @@ static JSValue js_string_indexOf(JSContext *ctx, JSValueConst this_val,
|
|
|
47505
47701
|
inc = 1;
|
|
47506
47702
|
}
|
|
47507
47703
|
ret = -1;
|
|
47508
|
-
if (
|
|
47704
|
+
if (inc > 0) {
|
|
47705
|
+
if (len >= v_len && start <= stop)
|
|
47706
|
+
ret = string_indexof(p, p1, start);
|
|
47707
|
+
} else if (len >= v_len && inc * (stop - start) >= 0) {
|
|
47509
47708
|
for (i = start;; i += inc) {
|
|
47510
47709
|
if (!string_cmp(p, p1, i, 0, v_len)) {
|
|
47511
47710
|
ret = i;
|
|
@@ -47532,7 +47731,7 @@ static JSValue js_string_includes(JSContext *ctx, JSValueConst this_val,
|
|
|
47532
47731
|
int argc, JSValueConst *argv, int magic)
|
|
47533
47732
|
{
|
|
47534
47733
|
JSValue str, v = JS_UNDEFINED;
|
|
47535
|
-
int
|
|
47734
|
+
int len, v_len, pos, start, stop, ret;
|
|
47536
47735
|
JSString *p;
|
|
47537
47736
|
JSString *p1;
|
|
47538
47737
|
|
|
@@ -47572,14 +47771,10 @@ static JSValue js_string_includes(JSContext *ctx, JSValueConst this_val,
|
|
|
47572
47771
|
start = stop = pos;
|
|
47573
47772
|
}
|
|
47574
47773
|
if (start >= 0 && start <= stop) {
|
|
47575
|
-
|
|
47576
|
-
|
|
47577
|
-
|
|
47578
|
-
|
|
47579
|
-
}
|
|
47580
|
-
if (i == stop)
|
|
47581
|
-
break;
|
|
47582
|
-
}
|
|
47774
|
+
if (magic == 0)
|
|
47775
|
+
ret = string_indexof(p, p1, start) >= 0;
|
|
47776
|
+
else
|
|
47777
|
+
ret = !string_cmp(p, p1, start, 0, v_len);
|
|
47583
47778
|
}
|
|
47584
47779
|
done:
|
|
47585
47780
|
JS_FreeValue(ctx, str);
|
|
@@ -48317,16 +48512,14 @@ static JSValue js_string_localeCompare(JSContext *ctx, JSValueConst this_val,
|
|
|
48317
48512
|
goto exception;
|
|
48318
48513
|
|
|
48319
48514
|
// TODO(bnoordhuis) skip normalization when input is latin1
|
|
48320
|
-
an = unicode_normalize(&ts, as, an, UNICODE_NFC, ctx,
|
|
48321
|
-
(DynBufReallocFunc *)js_realloc);
|
|
48515
|
+
an = unicode_normalize(&ts, as, an, UNICODE_NFC, ctx, js_dbuf_realloc);
|
|
48322
48516
|
if (an == -1)
|
|
48323
48517
|
goto exception;
|
|
48324
48518
|
js_free(ctx, as);
|
|
48325
48519
|
as = ts;
|
|
48326
48520
|
|
|
48327
48521
|
// TODO(bnoordhuis) skip normalization when input is latin1
|
|
48328
|
-
bn = unicode_normalize(&ts, bs, bn, UNICODE_NFC, ctx,
|
|
48329
|
-
(DynBufReallocFunc *)js_realloc);
|
|
48522
|
+
bn = unicode_normalize(&ts, bs, bn, UNICODE_NFC, ctx, js_dbuf_realloc);
|
|
48330
48523
|
if (bn == -1)
|
|
48331
48524
|
goto exception;
|
|
48332
48525
|
js_free(ctx, bs);
|
|
@@ -48468,7 +48661,7 @@ static JSValue js_string_normalize(JSContext *ctx, JSValueConst this_val,
|
|
|
48468
48661
|
}
|
|
48469
48662
|
|
|
48470
48663
|
out_len = unicode_normalize(&out_buf, buf, buf_len, n_type,
|
|
48471
|
-
ctx
|
|
48664
|
+
ctx, js_dbuf_realloc);
|
|
48472
48665
|
js_free(ctx, buf);
|
|
48473
48666
|
if (out_len < 0)
|
|
48474
48667
|
return JS_EXCEPTION;
|
|
@@ -53776,14 +53969,21 @@ static JSValue js_map_clear(JSContext *ctx, JSValueConst this_val,
|
|
|
53776
53969
|
int argc, JSValueConst *argv, int magic)
|
|
53777
53970
|
{
|
|
53778
53971
|
JSMapState *s = JS_GetOpaque2(ctx, this_val, JS_CLASS_MAP + magic);
|
|
53779
|
-
struct list_head *el
|
|
53972
|
+
struct list_head *el;
|
|
53780
53973
|
JSMapRecord *mr;
|
|
53781
53974
|
|
|
53782
53975
|
if (!s)
|
|
53783
53976
|
return JS_EXCEPTION;
|
|
53784
|
-
|
|
53977
|
+
el = s->records.next;
|
|
53978
|
+
while (el != &s->records) {
|
|
53785
53979
|
mr = list_entry(el, JSMapRecord, link);
|
|
53980
|
+
// Freeing the key or the value can free other records: a map
|
|
53981
|
+
// iterator may be the last holder of an already deleted record.
|
|
53982
|
+
// Keep 'mr' alive and read its successor only afterwards.
|
|
53983
|
+
mr->ref_count++;
|
|
53786
53984
|
map_delete_record(ctx->rt, s, mr);
|
|
53985
|
+
el = el->next;
|
|
53986
|
+
map_decref_record(ctx->rt, mr);
|
|
53787
53987
|
}
|
|
53788
53988
|
return JS_UNDEFINED;
|
|
53789
53989
|
}
|
|
@@ -57599,7 +57799,7 @@ static JSValue set_date_field(JSContext *ctx, JSValueConst this_val,
|
|
|
57599
57799
|
{
|
|
57600
57800
|
// _field(obj, first_field, end_field, args, is_local)
|
|
57601
57801
|
double fields[9];
|
|
57602
|
-
int res, first_field, end_field, is_local, i, n;
|
|
57802
|
+
int res, res1, first_field, end_field, is_local, i, n;
|
|
57603
57803
|
double d, a;
|
|
57604
57804
|
|
|
57605
57805
|
d = NAN;
|
|
@@ -57610,6 +57810,7 @@ static JSValue set_date_field(JSContext *ctx, JSValueConst this_val,
|
|
|
57610
57810
|
res = get_date_fields(ctx, this_val, fields, is_local, first_field == 0);
|
|
57611
57811
|
if (res < 0)
|
|
57612
57812
|
return JS_EXCEPTION;
|
|
57813
|
+
res1 = res;
|
|
57613
57814
|
|
|
57614
57815
|
// Argument coercion is observable and must be done unconditionally.
|
|
57615
57816
|
n = min_int(argc, end_field - first_field);
|
|
@@ -57621,10 +57822,11 @@ static JSValue set_date_field(JSContext *ctx, JSValueConst this_val,
|
|
|
57621
57822
|
fields[first_field + i] = trunc(a);
|
|
57622
57823
|
}
|
|
57623
57824
|
|
|
57624
|
-
if (!
|
|
57625
|
-
return JS_NAN;
|
|
57825
|
+
if (!res1)
|
|
57826
|
+
return JS_NAN; /* thisTimeValue is NaN: leave it */
|
|
57626
57827
|
|
|
57627
|
-
|
|
57828
|
+
/* a non-finite argument makes the new time value NaN */
|
|
57829
|
+
if (res && argc > 0)
|
|
57628
57830
|
d = set_date_fields(fields, is_local);
|
|
57629
57831
|
|
|
57630
57832
|
return JS_SetThisTimeValue(ctx, this_val, d);
|
|
@@ -60060,7 +60262,7 @@ JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValueConst obj,
|
|
|
60060
60262
|
if (pbyte_offset)
|
|
60061
60263
|
*pbyte_offset = ta->offset;
|
|
60062
60264
|
if (pbyte_length)
|
|
60063
|
-
*pbyte_length =
|
|
60265
|
+
*pbyte_length = (size_t)p->u.array.count << typed_array_size_log2(p->class_id);
|
|
60064
60266
|
if (pbytes_per_element) {
|
|
60065
60267
|
*pbytes_per_element = 1 << typed_array_size_log2(p->class_id);
|
|
60066
60268
|
}
|
|
@@ -60088,7 +60290,7 @@ uint8_t *JS_GetUint8Array(JSContext *ctx, size_t *psize, JSValueConst obj)
|
|
|
60088
60290
|
ta = p->u.typed_array;
|
|
60089
60291
|
abuf = ta->buffer->u.array_buffer;
|
|
60090
60292
|
|
|
60091
|
-
*psize =
|
|
60293
|
+
*psize = p->u.array.count;
|
|
60092
60294
|
return abuf->data + ta->offset;
|
|
60093
60295
|
fail:
|
|
60094
60296
|
*psize = 0;
|
|
@@ -63373,18 +63575,31 @@ static JSValue js_finrec_unregister(JSContext *ctx, JSValueConst this_val, int a
|
|
|
63373
63575
|
return JS_ThrowTypeError(ctx, "invalid unregister token");
|
|
63374
63576
|
|
|
63375
63577
|
struct list_head *el, *el1;
|
|
63376
|
-
|
|
63578
|
+
struct list_head removed;
|
|
63579
|
+
bool found;
|
|
63580
|
+
|
|
63581
|
+
// First pass: unlink the matching entries and drop their weak
|
|
63582
|
+
// references. Freeing a held value can free the target of another
|
|
63583
|
+
// entry of this registry, which would otherwise unlink and free that
|
|
63584
|
+
// entry while we iterate.
|
|
63585
|
+
init_list_head(&removed);
|
|
63377
63586
|
list_for_each_safe(el, el1, &frd->entries) {
|
|
63378
63587
|
JSFinRecEntry *fre = list_entry(el, JSFinRecEntry, link);
|
|
63379
63588
|
if (js_same_value(ctx, fre->token, token)) {
|
|
63380
63589
|
list_del(&fre->link);
|
|
63381
63590
|
delete_finrec_weakref(ctx->rt, fre);
|
|
63382
|
-
|
|
63383
|
-
removed = true;
|
|
63591
|
+
list_add_tail(&fre->link, &removed);
|
|
63384
63592
|
}
|
|
63385
63593
|
}
|
|
63594
|
+
found = !list_empty(&removed);
|
|
63595
|
+
// Second pass: free them. Nothing else can reach 'removed'.
|
|
63596
|
+
list_for_each_safe(el, el1, &removed) {
|
|
63597
|
+
JSFinRecEntry *fre = list_entry(el, JSFinRecEntry, link);
|
|
63598
|
+
list_del(&fre->link);
|
|
63599
|
+
js_finrec_free(ctx->rt, fre);
|
|
63600
|
+
}
|
|
63386
63601
|
|
|
63387
|
-
return js_bool(
|
|
63602
|
+
return js_bool(found);
|
|
63388
63603
|
}
|
|
63389
63604
|
|
|
63390
63605
|
static const JSCFunctionListEntry js_finrec_proto_funcs[] = {
|
|
@@ -63609,7 +63824,19 @@ static void js_new_callsite_data(JSContext *ctx, JSCallSiteData *csd, JSStackFra
|
|
|
63609
63824
|
JSObject *p;
|
|
63610
63825
|
|
|
63611
63826
|
csd->constructor = sf->is_constructor;
|
|
63612
|
-
|
|
63827
|
+
p = JS_VALUE_GET_OBJ(sf->cur_func);
|
|
63828
|
+
// Do not hand out functions that script cannot obtain otherwise and
|
|
63829
|
+
// that are not meant to be called by it: the engine's own closures
|
|
63830
|
+
// (promise reactions, async generator continuations, ...) and the
|
|
63831
|
+
// body of a module, which is async bytecode in a plain function
|
|
63832
|
+
// object and only runs correctly through js_async_function_call().
|
|
63833
|
+
if (p->class_id == JS_CLASS_C_FUNCTION_DATA ||
|
|
63834
|
+
(p->class_id == JS_CLASS_BYTECODE_FUNCTION &&
|
|
63835
|
+
p->u.func.function_bytecode->func_kind != JS_FUNC_NORMAL)) {
|
|
63836
|
+
csd->func = JS_UNDEFINED;
|
|
63837
|
+
} else {
|
|
63838
|
+
csd->func = js_dup(sf->cur_func);
|
|
63839
|
+
}
|
|
63613
63840
|
/* func_name_str is UTF-8 encoded if needed */
|
|
63614
63841
|
func_name_str = get_func_name(ctx, sf->cur_func);
|
|
63615
63842
|
if (!func_name_str || func_name_str[0] == '\0')
|
|
@@ -63620,7 +63847,6 @@ static void js_new_callsite_data(JSContext *ctx, JSCallSiteData *csd, JSStackFra
|
|
|
63620
63847
|
if (JS_IsException(csd->func_name))
|
|
63621
63848
|
csd->func_name = JS_NULL;
|
|
63622
63849
|
|
|
63623
|
-
p = JS_VALUE_GET_OBJ(sf->cur_func);
|
|
63624
63850
|
if (js_class_has_bytecode(p->class_id)) {
|
|
63625
63851
|
JSFunctionBytecode *b = p->u.func.function_bytecode;
|
|
63626
63852
|
int line_num1, col_num1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: omdev-cext
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.73
|
|
4
4
|
Summary: omdev
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.15
|
|
|
14
14
|
Requires-Python: >=3.14
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: omdev==0.0.
|
|
17
|
+
Requires-Dist: omdev==0.0.73
|
|
18
18
|
Dynamic: license-file
|
|
19
19
|
|
|
20
20
|
# Overview
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
omdev==0.0.73
|
|
@@ -13,7 +13,7 @@ urls = {source = 'https://github.com/wrmsr/om'}
|
|
|
13
13
|
license = 'BSD-3-Clause'
|
|
14
14
|
readme = 'README.md'
|
|
15
15
|
requires-python = '>=3.14'
|
|
16
|
-
version = '0.0.
|
|
16
|
+
version = '0.0.73'
|
|
17
17
|
classifiers = [
|
|
18
18
|
'Intended Audience :: Developers',
|
|
19
19
|
'Operating System :: OS Independent',
|
|
@@ -24,7 +24,7 @@ classifiers = [
|
|
|
24
24
|
]
|
|
25
25
|
description = 'omdev'
|
|
26
26
|
dependencies = [
|
|
27
|
-
'omdev == 0.0.
|
|
27
|
+
'omdev == 0.0.73',
|
|
28
28
|
]
|
|
29
29
|
|
|
30
30
|
[tool.setuptools]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
omdev==0.0.72
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{omdev_cext-0.0.72 → omdev_cext-0.0.73}/omdev/js/quickjs/_quickjs/builtin-iterator-zip-keyed.h
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|