forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
finalise.h
87 lines (73 loc) · 2.99 KB
/
finalise.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**************************************************************************/
/* */
/* OCaml */
/* */
/* Damien Doligez, projet Moscova, INRIA Rocquencourt */
/* */
/* Copyright 2000 Institut National de Recherche en Informatique et */
/* en Automatique. */
/* */
/* All rights reserved. This file is distributed under the terms of */
/* the GNU Lesser General Public License version 2.1, with the */
/* special exception on linking described in the file LICENSE. */
/* */
/**************************************************************************/
#ifndef CAML_FINALISE_H
#define CAML_FINALISE_H
#ifdef CAML_INTERNALS
#include "roots.h"
#include "domain.h"
struct final {
value fun;
value val;
int offset;
};
struct finalisable {
struct final *table;
uintnat old;
uintnat young;
uintnat size;
};
/* [0..old) : finalisable set, the values are in the major heap
[old..young) : recent set, the values could be in the minor heap
[young..size) : free space
The element of the finalisable set are moved to the finalising set
below when the value are unreachable (for the first or last time).
*/
struct final_todo {
struct final_todo *next;
int size;
struct final item[1]; /* variable size */
};
/*
todo_head: head of the list of finalisation functions that can be run.
todo_tail: tail of the list of finalisation functions that can be run.
It is the finalising set.
*/
struct caml_final_info {
struct finalisable first;
uintnat updated_first;
struct finalisable last;
uintnat updated_last;
struct final_todo *todo_head;
struct final_todo *todo_tail;
uintnat running_finalisation_function;
struct caml_final_info* next; /* used for orphaned finalisers.
See major_gc.c */
};
void caml_final_merge_finalisable (struct finalisable *source,
struct finalisable *target);
int caml_final_update_first (caml_domain_state* d);
int caml_final_update_last (caml_domain_state* d);
value caml_final_do_calls_exn (void);
void caml_final_do_roots (
scanning_action f, scanning_action_flags fflags, void* fdata,
caml_domain_state* domain, int do_val);
void caml_final_do_young_roots (
scanning_action f, scanning_action_flags fflags, void* fdata,
caml_domain_state* d, int do_last_val);
void caml_final_empty_young (caml_domain_state* d);
void caml_final_update_last_minor (caml_domain_state* d);
struct caml_final_info* caml_alloc_final_info(void);
#endif /* CAML_INTERNALS */
#endif /* CAML_FINALISE_H */