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.

remove redundant gc_suppress flag and related logic

+5 -36
-4
include/ant.h
··· 187 187 jsoff_t js_next_prop(jsoff_t header); 188 188 jsoff_t js_loadoff(ant_t *js, jsoff_t off); 189 189 190 - void js_print_stack_trace(FILE *stream); 191 - void js_set_needs_gc(ant_t *js, bool needs); 192 - void js_set_gc_suppress(ant_t *js, bool suppress); 193 - 194 190 #endif
-1
include/internal.h
··· 60 60 bool is_hoisting; // true during function declaration hoisting pass 61 61 uint64_t sym_counter; // counter for generating unique symbol IDs 62 62 bool needs_gc; // deferred GC flag, checked at statement boundaries 63 - bool gc_suppress; // suppress GC during microtask batch processing 64 63 jsoff_t gc_alloc_since; // bytes allocated since last GC 65 64 int eval_depth; // recursion depth of js_eval calls 66 65 int parse_depth; // recursion depth of parser (for stack overflow protection)
+3 -25
src/ant.c
··· 422 422 return typestr_raw(t); 423 423 } 424 424 425 - void js_set_needs_gc(struct js *js, bool needs) { 426 - js->needs_gc = needs; 427 - } 428 - 429 - void js_set_gc_suppress(struct js *js, bool suppress) { 430 - js->gc_suppress = suppress; 431 - } 432 - 433 425 uint8_t vtype(jsval_t v) { 434 426 return is_tagged(v) ? ((v >> NANBOX_TYPE_SHIFT) & NANBOX_TYPE_MASK) : (uint8_t)T_NUM; 435 427 } ··· 20922 20914 js->errmsg_size = 4096; 20923 20915 js->errmsg = (char *)malloc(js->errmsg_size); 20924 20916 if (js->errmsg) js->errmsg[0] = '\0'; 20925 - js->gc_suppress = false; 20926 20917 20927 20918 #ifdef _WIN32 20928 20919 js->stack_limit = 512 * 1024; ··· 21995 21986 21996 21987 while (next(js) != TOK_EOF && !is_err(res)) { 21997 21988 res = js_stmt(js); 21998 - if (js->needs_gc && js->eval_depth == 1 && !js->gc_suppress) { 21989 + if (js->needs_gc && js->eval_depth == 1) { 21999 21990 js->needs_gc = false; 22000 21991 js_gc_compact(js); 22001 21992 js->gc_alloc_since = 0; ··· 22013 22004 } 22014 22005 22015 22006 static jsval_t js_call_internal(struct js *js, jsval_t func, jsval_t bound_this, jsval_t *args, int nargs, bool use_bound_this) { 22016 - bool saved_gc_suppress = js->gc_suppress; 22017 - js->gc_suppress = true; 22018 - 22019 22007 if (vtype(func) == T_FFI) { 22020 - jsval_t res = ffi_call_by_index(js, (unsigned int)vdata(func), args, nargs); 22021 - js->gc_suppress = saved_gc_suppress; 22022 - return res; 22008 + return ffi_call_by_index(js, (unsigned int)vdata(func), args, nargs); 22023 22009 } else if (vtype(func) == T_CFUNC) { 22024 22010 jsval_t saved_this = js->this_val; 22025 22011 if (use_bound_this) js->this_val = bound_this; 22026 22012 jsval_t (*fn)(struct js *, jsval_t *, int) = (jsval_t(*)(struct js *, jsval_t *, int)) vdata(func); 22027 22013 jsval_t res = fn(js, args, nargs); 22028 - js->this_val = saved_this; 22029 - js->gc_suppress = saved_gc_suppress; 22030 - return res; 22014 + js->this_val = saved_this; return res; 22031 22015 } else if (vtype(func) == T_FUNC) { 22032 22016 jsval_t func_obj = mkval(T_OBJ, vdata(func)); 22033 22017 jsval_t cfunc_slot = get_slot(js, func_obj, SLOT_CFUNC); ··· 22054 22038 js->this_val = saved_this; 22055 22039 22056 22040 if (combined_args) free(combined_args); 22057 - js->gc_suppress = saved_gc_suppress; 22058 22041 return res; 22059 22042 } 22060 22043 ··· 22076 22059 jsval_t closure_scope = get_slot(js, func_obj, SLOT_SCOPE); 22077 22060 jsval_t res = start_async_in_coroutine(js, fn, fnlen, closure_scope, final_args, final_nargs); 22078 22061 if (combined_args) free(combined_args); 22079 - js->gc_suppress = saved_gc_suppress; 22080 22062 return res; 22081 22063 } 22082 22064 ··· 22100 22082 if (global_scope_stack && utarray_len(global_scope_stack) > 0) utarray_pop_back(global_scope_stack); 22101 22083 delscope(js); js->scope = saved_scope; 22102 22084 if (combined_args) free(combined_args); 22103 - js->gc_suppress = saved_gc_suppress; 22104 22085 return js_mkerr(js, "failed to parse function"); 22105 22086 } 22106 22087 ··· 22175 22156 if (global_scope_stack && utarray_len(global_scope_stack) > 0) utarray_pop_back(global_scope_stack); 22176 22157 delscope(js); js->scope = saved_scope; 22177 22158 if (combined_args) free(combined_args); 22178 - 22179 - js->gc_suppress = saved_gc_suppress; 22180 22159 return res; 22181 22160 } 22182 22161 22183 - js->gc_suppress = saved_gc_suppress; 22184 22162 return js_mkerr(js, "not a function"); 22185 22163 } 22186 22164
-3
src/modules/timer.c
··· 268 268 } 269 269 270 270 void process_microtasks(struct js *js) { 271 - js_set_gc_suppress(js, true); 272 - 273 271 while (timer_state.microtasks != NULL) { 274 272 microtask_entry_t *entry = timer_state.microtasks; 275 273 timer_state.microtasks = entry->next; ··· 288 286 free(entry); 289 287 } 290 288 291 - js_set_gc_suppress(js, false); 292 289 js_check_unhandled_rejections(js); 293 290 } 294 291
+1 -1
src/modules/url.c
··· 540 540 541 541 js_set(js, this_val, "_entries", new_entries); 542 542 usp_sync_url(js, this_val); 543 - js_set_needs_gc(js, true); 543 + js->needs_gc = true; 544 544 return js_mkundef(); 545 545 } 546 546
+1 -2
src/reactor.c
··· 37 37 } else free_coroutine(temp); 38 38 } 39 39 40 - if (js->needs_gc && !js->gc_suppress) { 40 + if (js->needs_gc) { 41 41 js->needs_gc = false; 42 42 js_gc_compact(js); 43 43 js->gc_alloc_since = 0; ··· 72 72 73 73 void js_run_event_loop(ant_t *js) { 74 74 work_flags_t work; 75 - js->gc_suppress = false; 76 75 77 76 while ((work = get_pending_work()) & WORK_PENDING) { 78 77 js_poll_events(js);