File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -392,6 +392,16 @@ void gc_info(gc_info_t *info) {
392392 GC_EXIT ();
393393}
394394
395+ void gc_mark_block (void * ptr ) {
396+ if (VERIFY_PTR (ptr )) {
397+ size_t _block = BLOCK_FROM_PTR (ptr );
398+ if (ATB_GET_KIND (_block ) == AT_HEAD ) {
399+ /* an unmarked head, mark it, and push it on gc stack */
400+ ATB_HEAD_TO_MARK (_block );
401+ }
402+ }
403+ }
404+
395405void * gc_alloc (size_t n_bytes , bool has_finaliser ) {
396406 size_t n_blocks = ((n_bytes + BYTES_PER_BLOCK - 1 ) & (~(BYTES_PER_BLOCK - 1 ))) / BYTES_PER_BLOCK ;
397407 DEBUG_printf ("gc_alloc(" UINT_FMT " bytes -> " UINT_FMT " blocks)\n" , n_bytes , n_blocks );
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ void gc_collect_start(void);
4545void gc_collect_root (void * * ptrs , size_t len );
4646void gc_collect_end (void );
4747
48+ // During a collect, use this to mark blocks used in C but allocated using gc_alloc.
49+ void gc_mark_block (void * ptr );
50+
4851void * gc_alloc (size_t n_bytes , bool has_finaliser );
4952void gc_free (void * ptr ); // does not call finaliser
5053size_t gc_nbytes (const void * ptr );
You can’t perform that action at this time.
0 commit comments