aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel/byterun/coq_memory.c
diff options
context:
space:
mode:
authorGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2018-03-22 17:49:13 +0100
committerGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2018-04-30 09:44:24 +0200
commit74f6c8c40942d57ea66d9f28bd15309ce59438b6 (patch)
tree0e8b48eb936c7a9a8b2678a38b7c1a3973e8764b /kernel/byterun/coq_memory.c
parentc1e12fbc64c39739e4a9f7bbf92e42f1bcb6be24 (diff)
Wrap VM bytecode used on the OCaml side in an OCaml block.
This prevents the existence of a few naked pointers to C heap from the OCaml heap. VM bytecode is represented as any block of size at least 1 whose first field points to a C-allocated string. This representation is compatible with the Coq VM representation of (potentially recursive) closures, which are already specifically tailored in the OCaml GC to be able to contain out-of-heap data.
Diffstat (limited to 'kernel/byterun/coq_memory.c')
-rw-r--r--kernel/byterun/coq_memory.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/byterun/coq_memory.c b/kernel/byterun/coq_memory.c
index b2917a55e..9102af702 100644
--- a/kernel/byterun/coq_memory.c
+++ b/kernel/byterun/coq_memory.c
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <string.h>
+#include <caml/alloc.h>
#include "coq_gc.h"
#include "coq_instruct.h"
#include "coq_fix_code.h"
@@ -46,7 +47,11 @@ value coq_static_alloc(value size) /* ML */
value accumulate_code(value unit) /* ML */
{
- return (value) accumulate;
+ CAMLparam1(unit);
+ CAMLlocal1(res);
+ res = caml_alloc_small(1, Abstract_tag);
+ Code_val(res) = accumulate;
+ CAMLreturn(res);
}
static void (*coq_prev_scan_roots_hook) (scanning_action);