19
19
external custom_block_padding : unit -> int = " custom_block_padding_byte" " custom_block_padding_native"
20
20
let custom_block_padding = custom_block_padding ()
21
21
22
+ (* We can't use [Obj.size] because that uses [Parraylength], which will be
23
+ specialized even though [Sys.opaque_identity] is present, thus giving a
24
+ "proper" array length computation rather than what we want. *)
25
+ external obj_size : _ -> int = " %obj_size" [@@ noalloc]
26
+
22
27
(* We only compile for 64 bits. *)
23
28
let bytes_per_word = 8
24
29
@@ -36,7 +41,7 @@ let check_value ~init ~element_size =
36
41
we don't have layout polymorphism. *)
37
42
let check_one n =
38
43
let x = makearray_dynamic n (fun _ -> init) in
39
- assert ((element_size * n / bytes_per_word) = (Obj. size (Obj. repr x)))
44
+ assert ((element_size * n / bytes_per_word) = (obj_size (Obj. repr x)))
40
45
in
41
46
List. iter check_one array_sizes_to_check
42
47
@@ -59,7 +64,7 @@ let _ = check_value ~init:42l ~element_size:int_array_element_size
59
64
let check_floatu ~init ~element_size =
60
65
let check_one n =
61
66
let x = makearray_dynamic n (fun _ -> init) in
62
- assert ((element_size * n / bytes_per_word) = (Obj. size (Obj. repr x)))
67
+ assert ((element_size * n / bytes_per_word) = (obj_size (Obj. repr x)))
63
68
in
64
69
List. iter check_one array_sizes_to_check
65
70
@@ -72,7 +77,7 @@ let check_int64u ~(init : int64#) ~element_size =
72
77
let check_one n =
73
78
let x = makearray_dynamic n (fun _ -> init) in
74
79
assert ((custom_block_padding + (element_size * n / bytes_per_word))
75
- = (Obj. size (Obj. repr x)))
80
+ = (obj_size (Obj. repr x)))
76
81
in
77
82
List. iter check_one array_sizes_to_check
78
83
@@ -85,7 +90,7 @@ let check_float32u ~(init : float32#) ~element_size =
85
90
let check_one n =
86
91
let x = makearray_dynamic n (fun _ -> init) in
87
92
assert ((custom_block_padding + (element_size * n / bytes_per_word))
88
- = (Obj. size (Obj. repr x)))
93
+ = (obj_size (Obj. repr x)))
89
94
in
90
95
List. iter check_one array_sizes_to_check
91
96
@@ -98,7 +103,7 @@ let check_int32u ~(init : int32#) ~element_size =
98
103
let check_one n =
99
104
let x = makearray_dynamic n (fun _ -> init) in
100
105
assert ((custom_block_padding + (element_size * n / bytes_per_word))
101
- = (Obj. size (Obj. repr x)))
106
+ = (obj_size (Obj. repr x)))
102
107
in
103
108
List. iter check_one array_sizes_to_check
104
109
@@ -111,7 +116,7 @@ let check_scannable_product1 ~(init : #(int * string * int * float array))
111
116
~element_size =
112
117
let check_one n =
113
118
let x = makearray_dynamic n (fun _ -> init) in
114
- assert ((element_size * n / bytes_per_word) = (Obj. size (Obj. repr x)))
119
+ assert ((element_size * n / bytes_per_word) = (obj_size (Obj. repr x)))
115
120
in
116
121
List. iter check_one array_sizes_to_check
117
122
@@ -128,7 +133,7 @@ let check_scannable_product2 ~(init : #(int * t_scan * string * t_scan))
128
133
~element_size =
129
134
let check_one n =
130
135
let x = makearray_dynamic n (fun _ -> init) in
131
- assert ((element_size * n / bytes_per_word) = (Obj. size (Obj. repr x)))
136
+ assert ((element_size * n / bytes_per_word) = (obj_size (Obj. repr x)))
132
137
in
133
138
List. iter check_one array_sizes_to_check
134
139
@@ -149,7 +154,7 @@ let check_ignorable_product1 ~(init : #(int * float32# * int * int64#))
149
154
~element_size =
150
155
let check_one n =
151
156
let x = makearray_dynamic n (fun _ -> init) in
152
- assert ((element_size * n / bytes_per_word) = (Obj. size (Obj. repr x)))
157
+ assert ((element_size * n / bytes_per_word) = (obj_size (Obj. repr x)))
153
158
in
154
159
List. iter check_one array_sizes_to_check
155
160
@@ -166,7 +171,7 @@ let check_ignorable_product2 ~(init : #(int * t_ignore * bool * t_ignore))
166
171
~element_size =
167
172
let check_one n =
168
173
let x = makearray_dynamic n (fun _ -> init) in
169
- assert ((element_size * n / bytes_per_word) = (Obj. size (Obj. repr x)))
174
+ assert ((element_size * n / bytes_per_word) = (obj_size (Obj. repr x)))
170
175
in
171
176
List. iter check_one array_sizes_to_check
172
177
@@ -186,7 +191,7 @@ let _ = check_ignorable_product2 ~init:(mk_el ())
186
191
let check_float32u_pair ~(init : #(float32# * float32#) ) ~element_size =
187
192
let check_one n =
188
193
let x = makearray_dynamic n (fun _ -> init) in
189
- assert ((element_size * n / bytes_per_word) = (Obj. size (Obj. repr x)))
194
+ assert ((element_size * n / bytes_per_word) = (obj_size (Obj. repr x)))
190
195
in
191
196
List. iter check_one array_sizes_to_check
192
197
@@ -200,7 +205,7 @@ let _ = check_float32u_pair ~init:#(#1.0s, #42.1s)
200
205
let check_int32u_pair ~(init : #(int32# * int32#) ) ~element_size =
201
206
let check_one n =
202
207
let x = makearray_dynamic n (fun _ -> init) in
203
- assert ((element_size * n / bytes_per_word) = (Obj. size (Obj. repr x)))
208
+ assert ((element_size * n / bytes_per_word) = (obj_size (Obj. repr x)))
204
209
in
205
210
List. iter check_one array_sizes_to_check
206
211
0 commit comments