MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix coro async stack

+53 -4
+1 -1
meson.build
··· 74 74 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 75 75 76 76 version_conf = configuration_data() 77 - version_conf.set('ANT_VERSION', '0.0.7.19') 77 + version_conf.set('ANT_VERSION', '0.0.7.20') 78 78 version_conf.set('ANT_GIT_HASH', git_hash) 79 79 version_conf.set('ANT_BUILD_DATE', build_date) 80 80
+52 -3
src/ant.c
··· 1389 1389 return v & ~(GCMASK | CONSTMASK | 3U); 1390 1390 } 1391 1391 1392 + static void js_unmark_jsval(struct js *js, jsval_t v) { 1393 + if (is_mem_entity(vtype(v))) js_unmark_entity(js, (jsoff_t) vdata(v)); 1394 + } 1395 + 1392 1396 static void js_unmark_used_entities(struct js *js) { 1393 1397 js_unmark_entity(js, (jsoff_t) vdata(js->scope)); 1394 1398 if (global_scope_stack) { ··· 1397 1401 js_unmark_entity(js, *p); 1398 1402 } 1399 1403 } 1404 + 1400 1405 js_unmark_entity(js, 0); 1401 1406 if (js->nogc) js_unmark_entity(js, js->nogc); 1407 + 1408 + for (coroutine_t *coro = pending_coroutines.head; coro != NULL; coro = coro->next) { 1409 + js_unmark_jsval(js, coro->scope); 1410 + js_unmark_jsval(js, coro->this_val); 1411 + js_unmark_jsval(js, coro->awaited_promise); 1412 + js_unmark_jsval(js, coro->result); 1413 + js_unmark_jsval(js, coro->async_func); 1414 + js_unmark_jsval(js, coro->yield_value); 1415 + for (int i = 0; i < coro->nargs; i++) js_unmark_jsval(js, coro->args[i]); 1416 + } 1402 1417 } 1403 1418 1404 1419 static void init_free_list(void) { ··· 1553 1568 if (js->nogc >= start) js->nogc -= size; 1554 1569 if (js->code > (char *) js->mem && js->code - (char *) js->mem < js->size && js->code - (char *) js->mem > start) { 1555 1570 js->code -= size; 1571 + } 1572 + 1573 + if (global_scope_stack) { 1574 + jsoff_t *p = NULL; 1575 + while ((p = (jsoff_t *)utarray_next(global_scope_stack, p)) != NULL) { 1576 + if (*p > start) *p -= size; 1577 + } 1578 + } 1579 + 1580 + for (coroutine_t *coro = pending_coroutines.head; coro != NULL; coro = coro->next) { 1581 + if (is_mem_entity(vtype(coro->scope)) && vdata(coro->scope) > start) 1582 + coro->scope = mkval(vtype(coro->scope), vdata(coro->scope) - size); 1583 + if (is_mem_entity(vtype(coro->this_val)) && vdata(coro->this_val) > start) 1584 + coro->this_val = mkval(vtype(coro->this_val), vdata(coro->this_val) - size); 1585 + if (is_mem_entity(vtype(coro->awaited_promise)) && vdata(coro->awaited_promise) > start) 1586 + coro->awaited_promise = mkval(vtype(coro->awaited_promise), vdata(coro->awaited_promise) - size); 1587 + if (is_mem_entity(vtype(coro->result)) && vdata(coro->result) > start) 1588 + coro->result = mkval(vtype(coro->result), vdata(coro->result) - size); 1589 + if (is_mem_entity(vtype(coro->async_func)) && vdata(coro->async_func) > start) 1590 + coro->async_func = mkval(vtype(coro->async_func), vdata(coro->async_func) - size); 1591 + if (is_mem_entity(vtype(coro->yield_value)) && vdata(coro->yield_value) > start) 1592 + coro->yield_value = mkval(vtype(coro->yield_value), vdata(coro->yield_value) - size); 1593 + for (int i = 0; i < coro->nargs; i++) { 1594 + if (is_mem_entity(vtype(coro->args[i])) && vdata(coro->args[i]) > start) 1595 + coro->args[i] = mkval(vtype(coro->args[i]), vdata(coro->args[i]) - size); 1596 + } 1556 1597 } 1557 1598 } 1558 1599 ··· 2381 2422 parent_scope_offset = (jsoff_t) vdata(js->scope); 2382 2423 } 2383 2424 2425 + if (global_scope_stack == NULL) utarray_new(global_scope_stack, &jsoff_icd); 2426 + utarray_push_back(global_scope_stack, &parent_scope_offset); 2384 2427 jsval_t function_scope = mkobj(js, parent_scope_offset); 2385 2428 2386 2429 const char *caller_code = js->code; ··· 2492 2535 2493 2536 jsval_t res = js_eval(js, &fn[fnpos], n); 2494 2537 if (!is_err(res) && !(js->flags & F_RETURN)) res = js_mkundef(); 2538 + if (global_scope_stack && utarray_len(global_scope_stack) > 0) utarray_pop_back(global_scope_stack); 2539 + 2495 2540 js->scope = saved_scope; 2496 - 2497 2541 return res; 2498 2542 } 2499 2543 ··· 2541 2585 } 2542 2586 2543 2587 jsval_t saved_scope = js->scope; 2588 + if (global_scope_stack == NULL) utarray_new(global_scope_stack, &jsoff_icd); 2589 + utarray_push_back(global_scope_stack, &parent_scope_offset); 2544 2590 jsval_t function_scope = mkobj(js, parent_scope_offset); 2545 2591 js->scope = function_scope; 2546 2592 ··· 2633 2679 if (!is_err(res) && !(js->flags & F_RETURN)) res = js_mkundef(); 2634 2680 2635 2681 js->this_val = saved_this; 2636 - js->scope = saved_scope; 2682 + if (global_scope_stack && utarray_len(global_scope_stack) > 0) utarray_pop_back(global_scope_stack); 2637 2683 2684 + js->scope = saved_scope; 2638 2685 return res; 2639 2686 } 2640 2687 ··· 5279 5326 } 5280 5327 5281 5328 jsoff_t parent_scope_offset = (jsoff_t) vdata(js->scope); 5329 + if (global_scope_stack == NULL) utarray_new(global_scope_stack, &jsoff_icd); 5330 + utarray_push_back(global_scope_stack, &parent_scope_offset); 5282 5331 jsval_t with_scope = mkentity(js, 0 | T_OBJ, &parent_scope_offset, sizeof(parent_scope_offset)); 5283 5332 5284 5333 jsoff_t prop_off = loadoff(js, (jsoff_t) vdata(with_obj)) & ~(3U | CONSTMASK); ··· 5296 5345 js->scope = with_scope; 5297 5346 5298 5347 res = js_block_or_stmt(js); 5299 - 5348 + if (global_scope_stack && utarray_len(global_scope_stack) > 0) utarray_pop_back(global_scope_stack); 5300 5349 js->scope = saved_scope; 5301 5350 } else { 5302 5351 res = js_block_or_stmt(js);