1Obj(3) OCaml library Obj(3)
2
3
4
6 Obj - Operations on internal representations of values.
7
9 Module Obj
10
12 Module Obj
13 : sig end
14
15
16 Operations on internal representations of values.
17
18 Not for the casual user.
19
20
21
22
23
24 type t
25
26
27
28
29 type raw_data = nativeint
30
31
32
33
34
35 val repr : 'a -> t
36
37
38
39
40 val obj : t -> 'a
41
42
43
44
45 val magic : 'a -> 'b
46
47
48
49
50 val is_block : t -> bool
51
52
53
54
55 val is_int : t -> bool
56
57
58
59
60 val tag : t -> int
61
62
63
64
65 val size : t -> int
66
67
68
69
70 val reachable_words : t -> int
71
72 Computes the total size (in words, including the headers) of all heap
73 blocks accessible from the argument. Statically allocated blocks are
74 excluded, unless the runtime system was configured with --dis‐
75 able-naked-pointers .
76
77 @Since 4.04
78
79
80
81 val field : t -> int -> t
82
83
84
85
86 val set_field : t -> int -> t -> unit
87
88 When using flambda:
89
90
91 set_field MUST NOT be called on immutable blocks. (Blocks allocated in
92 C stubs, or with new_block below, are always considered mutable.)
93
94 The same goes for set_double_field and set_tag . However, for set_tag
95 , in the case of immutable blocks where the middle-end optimizers never
96 see code that discriminates on their tag (for example records), the op‐
97 eration should be safe. Such uses are nonetheless discouraged.
98
99 For experts only: set_field et al can be made safe by first wrapping
100 the block in Sys.opaque_identity , so any information about its con‐
101 tents will not be propagated.
102
103
104
105 val set_tag : t -> int -> unit
106
107
108
109
110 val double_field : t -> int -> float
111
112
113
114
115 val set_double_field : t -> int -> float -> unit
116
117
118
119
120 val raw_field : t -> int -> raw_data
121
122
123
124
125 val set_raw_field : t -> int -> raw_data -> unit
126
127
128
129
130 val new_block : int -> int -> t
131
132
133
134
135 val dup : t -> t
136
137
138
139
140 val truncate : t -> int -> unit
141
142
143
144
145 val add_offset : t -> Int32.t -> t
146
147
148
149
150 val with_tag : int -> t -> t
151
152
153
154
155 val first_non_constant_constructor_tag : int
156
157
158
159
160 val last_non_constant_constructor_tag : int
161
162
163
164
165 val lazy_tag : int
166
167
168
169
170 val closure_tag : int
171
172
173
174
175 val object_tag : int
176
177
178
179
180 val infix_tag : int
181
182
183
184
185 val forward_tag : int
186
187
188
189
190 val no_scan_tag : int
191
192
193
194
195 val abstract_tag : int
196
197
198
199
200 val string_tag : int
201
202
203
204
205 val double_tag : int
206
207
208
209
210 val double_array_tag : int
211
212
213
214
215 val custom_tag : int
216
217
218
219
220 val final_tag : int
221
222
223
224
225 val int_tag : int
226
227
228
229
230 val out_of_heap_tag : int
231
232
233
234
235 val unaligned_tag : int
236
237
238
239 module Closure : sig end
240
241
242
243
244 module Extension_constructor : sig end
245
246
247
248
249
250 val extension_constructor : 'a -> extension_constructor
251
252
253
254
255 val extension_name : extension_constructor -> string
256
257
258
259
260 val extension_id : extension_constructor -> int
261
262
263
264
265
266 The following two functions are deprecated. Use module Marshal in‐
267 stead.
268
269 val marshal : t -> bytes
270
271
272
273
274 val unmarshal : bytes -> int -> t * int
275
276
277
278 module Ephemeron : sig end
279
280
281
282
283
284
285
286OCamldoc 2022-02-04 Obj(3)