Two related changes for accurate GC with the MLDS->C back-end:

Estimated hours taken: 2
Branches: main

Two related changes for accurate GC with the MLDS->C back-end:
- Add a new runtime option --heap-margin-size for the
  threshold of free heap space before a collection is
  invoked, rather than the previous hack of reusing
  --heap-zone-size for that purpose.
- A minor optimization to reduce the cost of MR_gc_check():
  cache the value of MR_zone_end - MR_heap_margin_size.

runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
runtime/mercury_memory.c:
	Add new variable `MR_heap_margin_size',
	and add a new runtime option `--heap-margin-size' to set it.

runtime/mercury_memory_zones.h:
	Add new field `gc_threshold' to the MR_MemoryZone struct.

runtime/mercury_memory_zones.c:
	Initialize the new field to point to the zone end minus
	MR_heap_margin_size.

runtime/mercury.h:
	Change MR_GC_check() to use the `gc_threshold' field.
This commit is contained in:
Fergus Henderson
2002-02-06 08:41:47 +00:00
parent c0cfe92d3b
commit af62036bff
6 changed files with 43 additions and 4 deletions

View File

@@ -137,6 +137,7 @@ MR_init_memory(void)
MR_global_heap_zone_size = 0;
MR_debug_heap_size = 0;
MR_debug_heap_zone_size = 0;
MR_heap_margin_size = 0;
#else
MR_heap_size = MR_round_up(MR_heap_size * 1024,
MR_unit);
@@ -155,6 +156,8 @@ MR_init_memory(void)
MR_unit);
MR_debug_heap_zone_size = MR_round_up(MR_debug_heap_zone_size * 1024,
MR_unit);
/* Note that there's no need for the heap margin to be rounded up */
MR_heap_margin_size = MR_heap_margin_size * 1024;
#endif
MR_detstack_size = MR_round_up(MR_detstack_size * 1024,
MR_unit);