- inline float allocation needs a gc check
- docs: don't pass volatile aliens to callbacks
-- don't save big free chunk at the end of the code heap
- some instability remains
-- overhaul alien docs
+ ui:
return (CELL)(scan + 1);
}
- return 0; /* can't happen */
+ return 0;
}
/* After code GC, all referenced code blocks have status set to B_MARKED, so any
return size;
}
+/* The size of the heap, not including the last block if it's free */
CELL heap_size(F_HEAP *heap)
{
- CELL start = heap->base;
- F_BLOCK *scan = (F_BLOCK *)start;
- while(next_block(heap,scan))
+ F_BLOCK *scan = (F_BLOCK *)heap->base;
+
+ while(next_block(heap,scan) != NULL)
scan = next_block(heap,scan);
- return (CELL)scan - (CELL)start;
+
+ /* this is the last block in the heap, and it is free */
+ if(scan->status == B_FREE)
+ return (CELL)scan - heap->base;
+ /* otherwise the last block is allocated */
+ else
+ return heap->limit - heap->base;
}
/* Apply a function to every code block */
h.bignum_zero = bignum_zero;
h.bignum_pos_one = bignum_pos_one;
h.bignum_neg_one = bignum_neg_one;
+
h.code_size = heap_size(&compiling);
h.code_relocation_base = compiling.base;
fwrite(&h,sizeof(F_HEADER),1,file);