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
78 Since 4.04
79
80
81
82 val field : t -> int -> t
83
84
85
86
87 val set_field : t -> int -> t -> unit
88
89 When using flambda:
90
91
92 set_field MUST NOT be called on immutable blocks. (Blocks allocated in
93 C stubs, or with new_block below, are always considered mutable.)
94
95 The same goes for set_double_field and set_tag . However, for set_tag
96 , in the case of immutable blocks where the middle-end optimizers never
97 see code that discriminates on their tag (for example records), the op‐
98 eration should be safe. Such uses are nonetheless discouraged.
99
100 For experts only: set_field et al can be made safe by first wrapping
101 the block in Sys.opaque_identity , so any information about its con‐
102 tents will not be propagated.
103
104
105
106 val set_tag : t -> int -> unit
107
108
109
110
111 val double_field : t -> int -> float
112
113
114
115
116 val set_double_field : t -> int -> float -> unit
117
118
119
120
121 val raw_field : t -> int -> raw_data
122
123
124
125
126 val set_raw_field : t -> int -> raw_data -> unit
127
128
129
130
131 val new_block : int -> int -> t
132
133
134
135
136 val dup : t -> t
137
138
139
140
141 val truncate : t -> int -> unit
142
143
144
145
146 val add_offset : t -> Int32.t -> t
147
148
149
150
151 val with_tag : int -> t -> t
152
153
154
155
156 val first_non_constant_constructor_tag : int
157
158
159
160
161 val last_non_constant_constructor_tag : int
162
163
164
165
166 val lazy_tag : int
167
168
169
170
171 val closure_tag : int
172
173
174
175
176 val object_tag : int
177
178
179
180
181 val infix_tag : int
182
183
184
185
186 val forward_tag : int
187
188
189
190
191 val no_scan_tag : int
192
193
194
195
196 val abstract_tag : int
197
198
199
200
201 val string_tag : int
202
203
204
205
206 val double_tag : int
207
208
209
210
211 val double_array_tag : int
212
213
214
215
216 val custom_tag : int
217
218
219
220
221 val final_tag : int
222
223
224
225
226 val int_tag : int
227
228
229
230
231 val out_of_heap_tag : int
232
233
234
235
236 val unaligned_tag : int
237
238
239
240 module Closure : sig end
241
242
243
244
245 module Extension_constructor : sig end
246
247
248
249
250
251 val extension_constructor : 'a -> extension_constructor
252
253
254
255
256 val extension_name : extension_constructor -> string
257
258
259
260
261 val extension_id : extension_constructor -> int
262
263
264
265 module Ephemeron : sig end
266
267
268
269
270
271
272
273OCamldoc 2022-07-22 Obj(3)