summaryrefslogtreecommitdiff
path: root/py/gc.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2016-11-21 12:17:47 -0800
committerScott Shawcroft <scott.shawcroft@gmail.com>2016-11-21 14:11:49 -0800
commit93218281588b42331d83e4aaa45ac1abe4af130b (patch)
tree295c36456034853f2199461e78e89c9d1a6c1724 /py/gc.c
parentf03a9ac505c563d9c7d06f198d1af2674328bfe3 (diff)
py: Add ability to manually mark blocks during collect.
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/py/gc.c b/py/gc.c
index 7ed53cfc7..ca977ce09 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -392,6 +392,16 @@ void gc_info(gc_info_t *info) {
GC_EXIT();
}
+void gc_mark_block(void * ptr) {
+ if (VERIFY_PTR(ptr)) {
+ size_t _block = BLOCK_FROM_PTR(ptr);
+ if (ATB_GET_KIND(_block) == AT_HEAD) {
+ /* an unmarked head, mark it, and push it on gc stack */
+ ATB_HEAD_TO_MARK(_block);
+ }
+ }
+}
+
void *gc_alloc(size_t n_bytes, bool has_finaliser) {
size_t n_blocks = ((n_bytes + BYTES_PER_BLOCK - 1) & (~(BYTES_PER_BLOCK - 1))) / BYTES_PER_BLOCK;
DEBUG_printf("gc_alloc(" UINT_FMT " bytes -> " UINT_FMT " blocks)\n", n_bytes, n_blocks);