mirror of
https://github.com/bellard/quickjs.git
synced 2025-09-30 15:04:24 +03:00
fixed GC logic so that a module can live after a JSContext is destroyed (#280) - update the reference count for the realm in jobs and FinalizationRegistry
This commit is contained in:
@@ -4230,17 +4230,15 @@ static void js_std_promise_rejection_check(JSContext *ctx)
|
||||
/* main loop which calls the user JS callbacks */
|
||||
void js_std_loop(JSContext *ctx)
|
||||
{
|
||||
JSContext *ctx1;
|
||||
int err;
|
||||
|
||||
for(;;) {
|
||||
/* execute the pending jobs */
|
||||
for(;;) {
|
||||
err = JS_ExecutePendingJob(JS_GetRuntime(ctx), &ctx1);
|
||||
err = JS_ExecutePendingJob(JS_GetRuntime(ctx), NULL);
|
||||
if (err <= 0) {
|
||||
if (err < 0) {
|
||||
js_std_dump_error(ctx1);
|
||||
}
|
||||
if (err < 0)
|
||||
js_std_dump_error(ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -4271,11 +4269,10 @@ JSValue js_std_await(JSContext *ctx, JSValue obj)
|
||||
JS_FreeValue(ctx, obj);
|
||||
break;
|
||||
} else if (state == JS_PROMISE_PENDING) {
|
||||
JSContext *ctx1;
|
||||
int err;
|
||||
err = JS_ExecutePendingJob(JS_GetRuntime(ctx), &ctx1);
|
||||
err = JS_ExecutePendingJob(JS_GetRuntime(ctx), NULL);
|
||||
if (err < 0) {
|
||||
js_std_dump_error(ctx1);
|
||||
js_std_dump_error(ctx);
|
||||
}
|
||||
if (err == 0) {
|
||||
js_std_promise_rejection_check(ctx);
|
||||
|
Reference in New Issue
Block a user