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.

gc blk protection fixes

+32 -9
+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.28') 77 + version_conf.set('ANT_VERSION', '0.0.7.29') 78 78 version_conf.set('ANT_GIT_HASH', git_hash) 79 79 version_conf.set('ANT_BUILD_DATE', build_date) 80 80
+31 -8
src/ant.c
··· 470 470 471 471 static void enqueue_coroutine(coroutine_t *coro) { 472 472 if (!coro) return; 473 + coro->next = NULL; 473 474 474 - if (pending_coroutines.tail) { 475 + if (pending_coroutines.tail && pending_coroutines.tail != coro) { 475 476 pending_coroutines.tail->next = coro; 476 477 pending_coroutines.tail = coro; 477 - } else { 478 + } else if (!pending_coroutines.tail) { 478 479 pending_coroutines.head = coro; 479 480 pending_coroutines.tail = coro; 480 481 } ··· 539 540 free_coroutine(temp); 540 541 } else if (res == MCO_SUCCESS) { 541 542 temp->is_ready = false; 543 + temp->next = NULL; 542 544 if (pending_coroutines.tail) { 543 545 pending_coroutines.tail->next = temp; 544 - pending_coroutines.tail = temp; 545 546 } else { 546 - pending_coroutines.head = pending_coroutines.tail = temp; 547 + pending_coroutines.head = temp; 547 548 } 548 - temp->next = NULL; 549 - prev = temp; 549 + pending_coroutines.tail = temp; 550 550 } else { 551 551 free_coroutine(temp); 552 552 } ··· 1751 1751 } 1752 1752 1753 1753 static jsoff_t js_unmark_entity(struct js *js, jsoff_t off) { 1754 + if (off >= js->brk) return 0; 1754 1755 jsoff_t v = loadoff(js, off); 1755 1756 if (v & GCMASK) { 1756 1757 saveoff(js, off, v & ~GCMASK); ··· 1782 1783 js_unmark_entity(js, 0); 1783 1784 if (js->nogc) js_unmark_entity(js, js->nogc); 1784 1785 1786 + mco_coro *running = mco_running(); 1787 + if (running) { 1788 + async_exec_context_t *ctx = (async_exec_context_t *)mco_get_user_data(running); 1789 + if (ctx) { 1790 + js_unmark_jsval(js, ctx->closure_scope); 1791 + js_unmark_jsval(js, ctx->result); 1792 + js_unmark_jsval(js, ctx->promise); 1793 + if (ctx->coro) { 1794 + js_unmark_jsval(js, ctx->coro->scope); 1795 + js_unmark_jsval(js, ctx->coro->this_val); 1796 + js_unmark_jsval(js, ctx->coro->awaited_promise); 1797 + js_unmark_jsval(js, ctx->coro->result); 1798 + js_unmark_jsval(js, ctx->coro->async_func); 1799 + js_unmark_jsval(js, ctx->coro->yield_value); 1800 + for (int i = 0; i < ctx->coro->nargs; i++) js_unmark_jsval(js, ctx->coro->args[i]); 1801 + } 1802 + } 1803 + } 1804 + 1785 1805 for (coroutine_t *coro = pending_coroutines.head; coro != NULL; coro = coro->next) { 1786 1806 js_unmark_jsval(js, coro->scope); 1787 1807 js_unmark_jsval(js, coro->this_val); ··· 1841 1861 unsigned int len = utarray_len(global_free_list); 1842 1862 if (len == 0) return 0; 1843 1863 1864 + jsoff_t safe_threshold = protected_brk > 0 ? protected_brk + 0x400 : 0x1000; 1844 1865 jsoff_t total_freed = 0; 1845 1866 FreeListEntry *entries = (FreeListEntry *)utarray_front(global_free_list); 1846 1867 for (unsigned int i = 0; i < len; i++) { 1847 1868 if (entries[i].offset > 0 && entries[i].size > 0) { 1869 + if (entries[i].offset < safe_threshold) continue; 1848 1870 if (entries[i].offset + entries[i].size > js->size) continue; 1849 1871 memset(&js->mem[entries[i].offset], 0, entries[i].size); 1850 1872 total_freed += entries[i].size; ··· 1860 1882 size = align32((jsoff_t) size); 1861 1883 1862 1884 FreeListEntry *entries = (FreeListEntry *)utarray_front(global_free_list); 1863 - jsoff_t safe_reuse_threshold = protected_brk > 0 ? protected_brk + 0x8000 : 0x10000; 1885 + jsoff_t safe_reuse_threshold = protected_brk > 0 ? protected_brk + 0x400 : 0x1000; 1864 1886 1865 1887 for (unsigned int i = 0; i < len; i++) { 1866 1888 if (entries[i].offset >= safe_reuse_threshold && entries[i].size >= size) { ··· 1897 1919 1898 1920 static void free_list_add(jsoff_t offset, jsoff_t size, struct js *js) { 1899 1921 if (offset >= js->size || size == 0 || offset + size > js->size * 2) return; 1900 - if (protected_brk > 0) if (offset <= protected_brk) return; 1922 + jsoff_t safe_threshold = protected_brk > 0 ? protected_brk + 0x400 : 0x1000; 1923 + if (offset < safe_threshold) return; 1901 1924 1902 1925 jsoff_t entity_val = loadoff(js, offset); 1903 1926 uint8_t entity_type = entity_val & 3;