mirror of
https://github.com/bellard/quickjs.git
synced 2025-09-27 13:48:45 +03:00
fixed module async evaluation logic - added DUMP_MODULE_EXEC
This commit is contained in:
parent
f1b1c000c2
commit
2fd48bf7df
2
TODO
2
TODO
@ -62,5 +62,5 @@ Optimization ideas:
|
|||||||
Test262o: 0/11262 errors, 463 excluded
|
Test262o: 0/11262 errors, 463 excluded
|
||||||
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
|
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
|
||||||
|
|
||||||
Result: 48/79398 errors, 1637 excluded, 6771 skipped
|
Result: 47/79398 errors, 1637 excluded, 6771 skipped
|
||||||
Test262 commit: 1e38cbeb1c878a352b55c3ebe03ee8eda74a33ed
|
Test262 commit: 1e38cbeb1c878a352b55c3ebe03ee8eda74a33ed
|
||||||
|
46
quickjs.c
46
quickjs.c
@ -103,6 +103,7 @@
|
|||||||
//#define DUMP_ATOMS /* dump atoms in JS_FreeContext */
|
//#define DUMP_ATOMS /* dump atoms in JS_FreeContext */
|
||||||
//#define DUMP_SHAPES /* dump shapes in JS_FreeContext */
|
//#define DUMP_SHAPES /* dump shapes in JS_FreeContext */
|
||||||
//#define DUMP_MODULE_RESOLVE
|
//#define DUMP_MODULE_RESOLVE
|
||||||
|
//#define DUMP_MODULE_EXEC
|
||||||
//#define DUMP_PROMISE
|
//#define DUMP_PROMISE
|
||||||
//#define DUMP_READ_OBJECT
|
//#define DUMP_READ_OBJECT
|
||||||
//#define DUMP_ROPE_REBALANCE
|
//#define DUMP_ROPE_REBALANCE
|
||||||
@ -839,7 +840,8 @@ struct JSModuleDef {
|
|||||||
int async_parent_modules_count;
|
int async_parent_modules_count;
|
||||||
int async_parent_modules_size;
|
int async_parent_modules_size;
|
||||||
int pending_async_dependencies;
|
int pending_async_dependencies;
|
||||||
BOOL async_evaluation;
|
BOOL async_evaluation; /* true: async_evaluation_timestamp corresponds to [[AsyncEvaluationOrder]]
|
||||||
|
false: [[AsyncEvaluationOrder]] is UNSET or DONE */
|
||||||
int64_t async_evaluation_timestamp;
|
int64_t async_evaluation_timestamp;
|
||||||
JSModuleDef *cycle_root;
|
JSModuleDef *cycle_root;
|
||||||
JSValue promise; /* corresponds to spec field: capability */
|
JSValue promise; /* corresponds to spec field: capability */
|
||||||
@ -29833,6 +29835,14 @@ static int exec_module_list_cmp(const void *p1, const void *p2, void *opaque)
|
|||||||
static int js_execute_async_module(JSContext *ctx, JSModuleDef *m);
|
static int js_execute_async_module(JSContext *ctx, JSModuleDef *m);
|
||||||
static int js_execute_sync_module(JSContext *ctx, JSModuleDef *m,
|
static int js_execute_sync_module(JSContext *ctx, JSModuleDef *m,
|
||||||
JSValue *pvalue);
|
JSValue *pvalue);
|
||||||
|
#ifdef DUMP_MODULE_EXEC
|
||||||
|
static void js_dump_module(JSContext *ctx, const char *str, JSModuleDef *m)
|
||||||
|
{
|
||||||
|
char buf1[ATOM_GET_STR_BUF_SIZE];
|
||||||
|
static const char *module_status_str[] = { "unlinked", "linking", "linked", "evaluating", "evaluating_async", "evaluated" };
|
||||||
|
printf("%s: %s status=%s\n", str, JS_AtomGetStr(ctx, buf1, sizeof(buf1), m->module_name), module_status_str[m->status]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static JSValue js_async_module_execution_rejected(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_async_module_execution_rejected(JSContext *ctx, JSValueConst this_val,
|
||||||
int argc, JSValueConst *argv, int magic, JSValue *func_data)
|
int argc, JSValueConst *argv, int magic, JSValue *func_data)
|
||||||
@ -29841,6 +29851,9 @@ static JSValue js_async_module_execution_rejected(JSContext *ctx, JSValueConst t
|
|||||||
JSValueConst error = argv[0];
|
JSValueConst error = argv[0];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
#ifdef DUMP_MODULE_EXEC
|
||||||
|
js_dump_module(ctx, __func__, module);
|
||||||
|
#endif
|
||||||
if (js_check_stack_overflow(ctx->rt, 0))
|
if (js_check_stack_overflow(ctx->rt, 0))
|
||||||
return JS_ThrowStackOverflow(ctx);
|
return JS_ThrowStackOverflow(ctx);
|
||||||
|
|
||||||
@ -29856,6 +29869,7 @@ static JSValue js_async_module_execution_rejected(JSContext *ctx, JSValueConst t
|
|||||||
module->eval_has_exception = TRUE;
|
module->eval_has_exception = TRUE;
|
||||||
module->eval_exception = JS_DupValue(ctx, error);
|
module->eval_exception = JS_DupValue(ctx, error);
|
||||||
module->status = JS_MODULE_STATUS_EVALUATED;
|
module->status = JS_MODULE_STATUS_EVALUATED;
|
||||||
|
module->async_evaluation = FALSE;
|
||||||
|
|
||||||
for(i = 0; i < module->async_parent_modules_count; i++) {
|
for(i = 0; i < module->async_parent_modules_count; i++) {
|
||||||
JSModuleDef *m = module->async_parent_modules[i];
|
JSModuleDef *m = module->async_parent_modules[i];
|
||||||
@ -29882,6 +29896,9 @@ static JSValue js_async_module_execution_fulfilled(JSContext *ctx, JSValueConst
|
|||||||
ExecModuleList exec_list_s, *exec_list = &exec_list_s;
|
ExecModuleList exec_list_s, *exec_list = &exec_list_s;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
#ifdef DUMP_MODULE_EXEC
|
||||||
|
js_dump_module(ctx, __func__, module);
|
||||||
|
#endif
|
||||||
if (module->status == JS_MODULE_STATUS_EVALUATED) {
|
if (module->status == JS_MODULE_STATUS_EVALUATED) {
|
||||||
assert(module->eval_has_exception);
|
assert(module->eval_has_exception);
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
@ -29907,6 +29924,9 @@ static JSValue js_async_module_execution_fulfilled(JSContext *ctx, JSValueConst
|
|||||||
|
|
||||||
for(i = 0; i < exec_list->count; i++) {
|
for(i = 0; i < exec_list->count; i++) {
|
||||||
JSModuleDef *m = exec_list->tab[i];
|
JSModuleDef *m = exec_list->tab[i];
|
||||||
|
#ifdef DUMP_MODULE_EXEC
|
||||||
|
printf(" %d/%d", i, exec_list->count); js_dump_module(ctx, "", m);
|
||||||
|
#endif
|
||||||
if (m->status == JS_MODULE_STATUS_EVALUATED) {
|
if (m->status == JS_MODULE_STATUS_EVALUATED) {
|
||||||
assert(m->eval_has_exception);
|
assert(m->eval_has_exception);
|
||||||
} else if (m->has_tla) {
|
} else if (m->has_tla) {
|
||||||
@ -29921,6 +29941,7 @@ static JSValue js_async_module_execution_fulfilled(JSContext *ctx, JSValueConst
|
|||||||
JS_FreeValue(ctx, m_obj);
|
JS_FreeValue(ctx, m_obj);
|
||||||
JS_FreeValue(ctx, error);
|
JS_FreeValue(ctx, error);
|
||||||
} else {
|
} else {
|
||||||
|
m->async_evaluation = FALSE;
|
||||||
js_set_module_evaluated(ctx, m);
|
js_set_module_evaluated(ctx, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29933,6 +29954,9 @@ static int js_execute_async_module(JSContext *ctx, JSModuleDef *m)
|
|||||||
{
|
{
|
||||||
JSValue promise, m_obj;
|
JSValue promise, m_obj;
|
||||||
JSValue resolve_funcs[2], ret_val;
|
JSValue resolve_funcs[2], ret_val;
|
||||||
|
#ifdef DUMP_MODULE_EXEC
|
||||||
|
js_dump_module(ctx, __func__, m);
|
||||||
|
#endif
|
||||||
promise = js_async_function_call(ctx, m->func_obj, JS_UNDEFINED, 0, NULL, 0);
|
promise = js_async_function_call(ctx, m->func_obj, JS_UNDEFINED, 0, NULL, 0);
|
||||||
if (JS_IsException(promise))
|
if (JS_IsException(promise))
|
||||||
return -1;
|
return -1;
|
||||||
@ -29952,6 +29976,9 @@ static int js_execute_async_module(JSContext *ctx, JSModuleDef *m)
|
|||||||
static int js_execute_sync_module(JSContext *ctx, JSModuleDef *m,
|
static int js_execute_sync_module(JSContext *ctx, JSModuleDef *m,
|
||||||
JSValue *pvalue)
|
JSValue *pvalue)
|
||||||
{
|
{
|
||||||
|
#ifdef DUMP_MODULE_EXEC
|
||||||
|
js_dump_module(ctx, __func__, m);
|
||||||
|
#endif
|
||||||
if (m->init_func) {
|
if (m->init_func) {
|
||||||
/* C module init : no asynchronous execution */
|
/* C module init : no asynchronous execution */
|
||||||
if (m->init_func(ctx, m) < 0)
|
if (m->init_func(ctx, m) < 0)
|
||||||
@ -29991,19 +30018,16 @@ static int js_inner_module_evaluation(JSContext *ctx, JSModuleDef *m,
|
|||||||
JSModuleDef *m1;
|
JSModuleDef *m1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
#ifdef DUMP_MODULE_EXEC
|
||||||
|
js_dump_module(ctx, __func__, m);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (js_check_stack_overflow(ctx->rt, 0)) {
|
if (js_check_stack_overflow(ctx->rt, 0)) {
|
||||||
JS_ThrowStackOverflow(ctx);
|
JS_ThrowStackOverflow(ctx);
|
||||||
*pvalue = JS_GetException(ctx);
|
*pvalue = JS_GetException(ctx);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DUMP_MODULE_RESOLVE
|
|
||||||
{
|
|
||||||
char buf1[ATOM_GET_STR_BUF_SIZE];
|
|
||||||
printf("js_inner_module_evaluation '%s':\n", JS_AtomGetStr(ctx, buf1, sizeof(buf1), m->module_name));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (m->status == JS_MODULE_STATUS_EVALUATING_ASYNC ||
|
if (m->status == JS_MODULE_STATUS_EVALUATING_ASYNC ||
|
||||||
m->status == JS_MODULE_STATUS_EVALUATED) {
|
m->status == JS_MODULE_STATUS_EVALUATED) {
|
||||||
if (m->eval_has_exception) {
|
if (m->eval_has_exception) {
|
||||||
@ -30104,6 +30128,9 @@ static JSValue js_evaluate_module(JSContext *ctx, JSModuleDef *m)
|
|||||||
JSModuleDef *m1, *stack_top;
|
JSModuleDef *m1, *stack_top;
|
||||||
JSValue ret_val, result;
|
JSValue ret_val, result;
|
||||||
|
|
||||||
|
#ifdef DUMP_MODULE_EXEC
|
||||||
|
js_dump_module(ctx, __func__, m);
|
||||||
|
#endif
|
||||||
assert(m->status == JS_MODULE_STATUS_LINKED ||
|
assert(m->status == JS_MODULE_STATUS_LINKED ||
|
||||||
m->status == JS_MODULE_STATUS_EVALUATING_ASYNC ||
|
m->status == JS_MODULE_STATUS_EVALUATING_ASYNC ||
|
||||||
m->status == JS_MODULE_STATUS_EVALUATED);
|
m->status == JS_MODULE_STATUS_EVALUATED);
|
||||||
@ -30136,6 +30163,9 @@ static JSValue js_evaluate_module(JSContext *ctx, JSModuleDef *m)
|
|||||||
1, (JSValueConst *)&m->eval_exception);
|
1, (JSValueConst *)&m->eval_exception);
|
||||||
JS_FreeValue(ctx, ret_val);
|
JS_FreeValue(ctx, ret_val);
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef DUMP_MODULE_EXEC
|
||||||
|
js_dump_module(ctx, " done", m);
|
||||||
|
#endif
|
||||||
assert(m->status == JS_MODULE_STATUS_EVALUATING_ASYNC ||
|
assert(m->status == JS_MODULE_STATUS_EVALUATING_ASYNC ||
|
||||||
m->status == JS_MODULE_STATUS_EVALUATED);
|
m->status == JS_MODULE_STATUS_EVALUATED);
|
||||||
assert(!m->eval_has_exception);
|
assert(!m->eval_has_exception);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34: TypeError: ArrayBuffer is detached
|
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34: TypeError: ArrayBuffer is detached
|
||||||
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34: strict mode: TypeError: ArrayBuffer is detached
|
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34: strict mode: TypeError: ArrayBuffer is detached
|
||||||
test262/test/language/module-code/top-level-await/module-graphs-does-not-hang.js:10: TypeError: $DONE() not called
|
|
||||||
test262/test/staging/sm/Date/UTC-convert-all-arguments.js:75: Test262Error: index 1: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
|
test262/test/staging/sm/Date/UTC-convert-all-arguments.js:75: Test262Error: index 1: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
|
||||||
test262/test/staging/sm/Date/constructor-convert-all-arguments.js:75: Test262Error: index undefined: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
|
test262/test/staging/sm/Date/constructor-convert-all-arguments.js:75: Test262Error: index undefined: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
|
||||||
test262/test/staging/sm/Date/non-iso.js:76: Test262Error: Expected SameValue(«NaN», «-40071559730000») to be true
|
test262/test/staging/sm/Date/non-iso.js:76: Test262Error: Expected SameValue(«NaN», «-40071559730000») to be true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user