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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 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. *)
(* *)
(**************************************************************************)
(** Operations on internal representations of values.
Not for the casual user.
*)
type t
type raw_data = nativeint (* @since 4.12 *)
external repr : 'a -> t = "%identity"
external obj : t -> 'a = "%identity"
external magic : 'a -> 'b = "%identity"
val [@inline always] is_block : t -> bool
external is_int : t -> bool = "%obj_is_int"
external tag : t -> int = "caml_obj_tag" [@@noalloc]
external size : t -> int = "%obj_size"
external reachable_words : t -> int = "caml_obj_reachable_words"
(**
Computes the total size (in words, including the headers) of all
heap blocks accessible from the argument. Statically
allocated blocks are excluded, unless the runtime system
was configured with [--disable-naked-pointers].
@Since 4.04
*)
external field : t -> int -> t = "%obj_field"
(** When using flambda:
[set_field] MUST NOT be called on immutable blocks. (Blocks allocated
in C stubs, or with [new_block] below, are always considered mutable.)
The same goes for [set_double_field] and [set_tag]. However, for
[set_tag], in the case of immutable blocks where the middle-end optimizers
never see code that discriminates on their tag (for example records), the
operation should be safe. Such uses are nonetheless discouraged.
For experts only:
[set_field] et al can be made safe by first wrapping the block in
{!Sys.opaque_identity}, so any information about its contents will not
be propagated.
*)
external set_field : t -> int -> t -> unit = "%obj_set_field"
external compare_and_swap_field : t -> int -> t -> t -> bool
= "caml_obj_compare_and_swap"
external is_shared : t -> bool = "caml_obj_is_shared"
external set_tag : t -> int -> unit = "caml_obj_set_tag"
[@@ocaml.deprecated "Use with_tag instead."]
val [@inline always] double_field : t -> int -> float (* @since 3.11.2 *)
val [@inline always] set_double_field : t -> int -> float -> unit
(* @since 3.11.2 *)
external raw_field : t -> int -> raw_data = "caml_obj_raw_field"
(* @since 4.12 *)
external set_raw_field : t -> int -> raw_data -> unit
= "caml_obj_set_raw_field"
(* @since 4.12 *)
external new_block : int -> int -> t = "caml_obj_block"
external dup : t -> t = "caml_obj_dup"
external truncate : t -> int -> unit = "caml_obj_truncate"
[@@ocaml.deprecated]
external add_offset : t -> Int32.t -> t = "caml_obj_add_offset"
(* @since 3.12.0 *)
external with_tag : int -> t -> t = "caml_obj_with_tag"
(* @since 4.09.0 *)
val first_non_constant_constructor_tag : int
val last_non_constant_constructor_tag : int
val forcing_tag : int
val cont_tag : int
val lazy_tag : int
val closure_tag : int
val object_tag : int
val infix_tag : int
val forward_tag : int
val no_scan_tag : int
val abstract_tag : int
val string_tag : int (* both [string] and [bytes] *)
val double_tag : int
val double_array_tag : int
val custom_tag : int
val final_tag : int
[@@ocaml.deprecated "Replaced by custom_tag."]
val int_tag : int
val out_of_heap_tag : int
val unaligned_tag : int (* should never happen @since 3.11.0 *)
module Closure : sig
type info = {
arity: int;
start_env: int;
}
val info : t -> info
end
module Extension_constructor :
sig
type t = extension_constructor
val of_val : 'a -> t
val [@inline always] name : t -> string
val [@inline always] id : t -> int
end
val extension_constructor : 'a -> extension_constructor
[@@ocaml.deprecated "use Obj.Extension_constructor.of_val"]
val [@inline always] extension_name : extension_constructor -> string
[@@ocaml.deprecated "use Obj.Extension_constructor.name"]
val [@inline always] extension_id : extension_constructor -> int
[@@ocaml.deprecated "use Obj.Extension_constructor.id"]
(** The following two functions are deprecated. Use module {!Marshal}
instead. *)
val marshal : t -> bytes
[@@ocaml.deprecated "Use Marshal.to_bytes instead."]
val unmarshal : bytes -> int -> t * int
[@@ocaml.deprecated "Use Marshal.from_bytes and Marshal.total_size instead."]
external clone_continuation : ('a,'b) continuation -> ('a,'b) continuation =
"caml_clone_continuation"
module Ephemeron: sig
(** Ephemeron with arbitrary arity and untyped *)
type obj_t = t
(** alias for {!Obj.t} *)
type t
(** an ephemeron cf {!Ephemeron} *)
val create: int -> t
(** [create n] returns an ephemeron with [n] keys.
All the keys and the data are initially empty.
The argument [n] must be between zero
and {!max_ephe_length} (limits included).
*)
val length: t -> int
(** return the number of keys *)
val get_key: t -> int -> obj_t option
(** Same as {!Ephemeron.K1.get_key} *)
val get_key_copy: t -> int -> obj_t option
(** Same as {!Ephemeron.K1.get_key_copy} *)
val set_key: t -> int -> obj_t -> unit
(** Same as {!Ephemeron.K1.set_key} *)
val unset_key: t -> int -> unit
(** Same as {!Ephemeron.K1.unset_key} *)
val check_key: t -> int -> bool
(** Same as {!Ephemeron.K1.check_key} *)
val blit_key : t -> int -> t -> int -> int -> unit
(** Same as {!Ephemeron.K1.blit_key} *)
val get_data: t -> obj_t option
(** Same as {!Ephemeron.K1.get_data} *)
val get_data_copy: t -> obj_t option
(** Same as {!Ephemeron.K1.get_data_copy} *)
val set_data: t -> obj_t -> unit
(** Same as {!Ephemeron.K1.set_data} *)
val unset_data: t -> unit
(** Same as {!Ephemeron.K1.unset_data} *)
val check_data: t -> bool
(** Same as {!Ephemeron.K1.check_data} *)
val blit_data : t -> t -> unit
(** Same as {!Ephemeron.K1.blit_data} *)
val max_ephe_length: int
(** Maximum length of an ephemeron, ie the maximum number of keys an
ephemeron could contain *)
end
|