···346346 return Wsize_bsize(bs);
347347}
348348349349+/* The current minor heap layout is as follows:
350350+351351+- A contiguous memory block of size [Minor_heap_max * Max_domains]
352352+ is reserved by [caml_init_domains]. The boundaries of this
353353+ reserved area are stored in the globals
354354+ [caml_minor_heaps_base]
355355+ and
356356+ [caml_minor_heaps_base_end}.
357357+358358+- Each domain gets a reserved section of this block of size
359359+ [Minor_heap_max], whose boundaries are stored as
360360+ [domain_self->minor_heap_base]
361361+ and
362362+ [domain_self->minor_heap_base_end]
363363+364364+- Each domain then commits a segment of size
365365+ [domain_state->minor_heap_wsz]
366366+ starting at
367367+ [domain_state->minor_heap_base]
368368+ that it actually uses.
369369+370370+ This is done below in
371371+ [caml_reallocate_minor_heap]
372372+ which is called both at domain-initialization (by [create_domain])
373373+ and if a request comes to change the minor heap size.
374374+375375+ The boundaries of this committed memory area are
376376+ [domain_state->young_start]
377377+ and
378378+ [domain_state->young_end].
379379+*/
349380int caml_reallocate_minor_heap(asize_t wsize)
350381{
351382 caml_domain_state* domain_state = Caml_state;
352383 CAMLassert(domain_state->young_ptr == domain_state->young_end);
353384385385+ CAMLassert(
386386+ (/* unitialized minor heap */
387387+ domain_state->young_start == NULL
388388+ && domain_state->young_end == NULL)
389389+ ||
390390+ (/* initialized minor heap */
391391+ domain_state->young_start == (value*)domain_self->minor_heap_area
392392+ && domain_state->young_end < (value*)domain_self->minor_heap_area_end));
393393+354394 /* free old minor heap.
355395 instead of unmapping the heap, we decommit it, so there's
356396 no race whereby other code could attempt to reuse the memory. */
357397 caml_mem_decommit(
358398 (void*)domain_self->minor_heap_area,
359359- domain_self->minor_heap_area_end - domain_self->minor_heap_area);
399399+ (char*)domain_state->young_end - (char*)domain_state->young_start);
360400361401 wsize = caml_norm_minor_heap_size(wsize);
362402···482522 goto init_signal_stack_failure;
483523 }
484524485485- domain_state->young_start = domain_state->young_end =
486486- domain_state->young_ptr = 0;
525525+ domain_state->young_start =
526526+ domain_state->young_end =
527527+ domain_state->young_ptr = NULL;
528528+487529 domain_state->minor_tables = caml_alloc_minor_tables();
488530 if(domain_state->minor_tables == NULL) {
489531 goto alloc_minor_tables_failure;