The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

manual: add explanation about 'simple' GC rules (#14273)

* manual: add explanation about 'simple' GC rules

* Review

authored by

Nicolás Ojeda Bär and committed by
GitHub
c4ae499b b5cfb447

+12
+12
manual/src/cmds/intf-c.etex
··· 935 935 936 936 \subsection{ss:c-simple-gc-harmony}{Simple interface} 937 937 938 + In general, any variable in C code that references a heap-allocated OCaml value 939 + must be known to the runtime when the GC runs, as references to any objects 940 + moved by the GC need to be updated. Modifications of mutable fields must also be 941 + tracked by the GC for correctness. Listed below are simple rules to achieve 942 + this. In some cases, the rules dictate registration of variables that may not be 943 + technically needed (eg because the referenced OCaml value is an immediate, or 944 + because the GC is guaranteed not to be invoked during the lifetime of the 945 + variable). However, trying to optimize root registration is a common source of 946 + safety bugs, so it is strongly recommended to follow the rules below in most 947 + cases. The implementation of the root registration mechanism is efficient and 948 + will not typically result in any performance penalty. 949 + 938 950 All the macros described in this section are declared in the 939 951 "<caml/memory.h>" header file. 940 952