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.

add support for coroutine execution tracking

+26 -7
+7 -1
include/ant.h
··· 1 + #ifndef ANT_H 2 + #define ANT_H 3 + 1 4 #pragma once 2 5 #define PCRE2_CODE_UNIT_WIDTH 8 3 6 ··· 12 15 #define ANT_LIMIT_SIZE_CACHE 16384 13 16 14 17 struct js; 18 + extern bool executing_coro; 15 19 16 20 typedef uint32_t jsoff_t; 17 21 typedef uint64_t jsval_t; ··· 156 160 jsoff_t js_next_prop(jsoff_t header); 157 161 jsoff_t js_loadoff(struct js *js, jsoff_t off); 158 162 159 - void js_print_stack_trace(FILE *stream); 163 + void js_print_stack_trace(FILE *stream); 164 + 165 + #endif
-3
include/arena.h
··· 1 1 #ifndef ARENA_H 2 2 #define ARENA_H 3 3 4 - #define NO_EXECUTE_PERMISSION 1 5 - #define GC_NO_THREAD_REDIRECTS 1 6 - #define GC_THREADS 1 7 4 #include <gc.h> 8 5 9 6 static inline void ant_gc_init(void) {
+9 -3
meson.build
··· 32 32 endif 33 33 34 34 tlsuv_opts = cmake.subproject_options() 35 + tlsuv_opts.add_cmake_defines({'BUILD_TESTING': 'OFF'}) 35 36 tlsuv_opts.append_compile_args('c', [ 36 37 '-Wno-unused-function', 37 38 '-Wno-unused-variable', ··· 39 40 '-Wno-sometimes-uninitialized' 40 41 ]) 41 42 42 - tlsuv_opts.add_cmake_defines({'BUILD_TESTING': 'OFF'}) 43 + bdwgc_opts = cmake.subproject_options() 44 + tlsuv_opts.append_compile_args('c', [ 45 + '-DGC_NO_THREAD_REDIRECTS', 46 + '-DGC_THREADS', 47 + ]) 48 + 43 49 tlsuv_dep = cmake.subproject('tlsuv', options: tlsuv_opts).dependency('tlsuv') 50 + bdwgc_dep = cmake.subproject('bdwgc', options: bdwgc_opts).dependency('gc') 44 51 45 52 pcre2_dep = subproject('pcre2').get_variable('libpcre2_8') 46 - bdwgc_dep = subproject('bdwgc').get_variable('bdwgc_dep') 47 53 uthash_dep = subproject('uthash').get_variable('uthash_dep') 48 54 yyjson_dep = subproject('yyjson').get_variable('yyjson_dep') 49 55 uuidv7_dep = subproject('uuidv7').get_variable('uuidv7_dep') ··· 79 85 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 80 86 81 87 version_conf = configuration_data() 82 - version_conf.set('ANT_VERSION', '0.2.3.17') 88 + version_conf.set('ANT_VERSION', '0.2.3.18') 83 89 version_conf.set('ANT_GIT_HASH', git_hash) 84 90 version_conf.set('ANT_BUILD_DATE', build_date) 85 91
+4
src/ant.c
··· 867 867 return 0; 868 868 } 869 869 870 + bool executing_coro = false; 871 + 870 872 static void mco_async_entry(mco_coro* mco) { 871 873 async_exec_context_t *ctx = (async_exec_context_t *)mco_get_user_data(mco); 872 874 873 875 struct js *js = ctx->js; 874 876 coroutine_t *coro = ctx->coro; 875 877 jsval_t result; 878 + executing_coro = true; 876 879 877 880 if (coro && coro->nargs > 0 && coro->args) { 878 881 result = call_js_code_with_args(js, ctx->code, (jsoff_t)ctx->code_len, ctx->closure_scope, coro->args, coro->nargs); ··· 895 898 js_resolve_promise(js, ctx->promise, result); 896 899 } 897 900 901 + executing_coro = false; 898 902 } 899 903 900 904 static void enqueue_coroutine(coroutine_t *coro) {
+6
src/modules/builtin.c
··· 66 66 static jsval_t js_gc_trigger(struct js *js, jsval_t *args, int nargs) { 67 67 (void) args; (void) nargs; 68 68 69 + if (executing_coro) { 70 + jsval_t result = js_mkobj(js); 71 + js_set(js, result, "skipped", js_mktrue()); 72 + return result; 73 + } 74 + 69 75 size_t heap_before = GC_get_heap_size(); 70 76 size_t used_before = GC_get_heap_size() - GC_get_free_bytes(); 71 77