@@ -130,7 +130,7 @@ mixed blocks. In the upstream compiler, R is set with the
130
130
131
131
#define Tag_hd (hd ) ((tag_t) ((hd) & HEADER_TAG_MASK))
132
132
#define Hd_with_tag (hd , tag ) (((hd) &~ HEADER_TAG_MASK) | (tag))
133
- #define Wosize_hd (hd ) ((mlsize_t) (((hd) & HEADER_WOSIZE_MASK) \
133
+ #define Allocated_wosize_hd (hd ) ((mlsize_t) (((hd) & HEADER_WOSIZE_MASK) \
134
134
>> HEADER_WOSIZE_SHIFT))
135
135
136
136
/* A "clean" header, without reserved or color bits. */
@@ -192,7 +192,7 @@ Caml_inline mlsize_t Scannable_wosize_hd_native(header_t hd) {
192
192
return
193
193
Is_mixed_block_reserved (res )
194
194
? Mixed_block_scannable_wosize_reserved_native (res )
195
- : Wosize_hd (hd );
195
+ : Allocated_wosize_hd (hd );
196
196
}
197
197
198
198
/* Bytecode versions of mixed block macros.
@@ -203,8 +203,8 @@ Caml_inline mlsize_t Scannable_wosize_hd_native(header_t hd) {
203
203
in the header bits.
204
204
*/
205
205
206
- #define Scannable_wosize_hd_byte (hd ) (Wosize_hd (hd))
207
- #define Scannable_wosize_val_byte (val ) (Wosize_hd (Hd_val (val)))
206
+ #define Scannable_wosize_hd_byte (hd ) (Allocated_wosize_hd (hd))
207
+ #define Scannable_wosize_val_byte (val ) (Allocated_wosize_hd (Hd_val (val)))
208
208
Caml_inline mlsize_t Scannable_wosize_reserved_byte (reserved_t res ,
209
209
mlsize_t size ) {
210
210
(void )res ;
@@ -252,33 +252,61 @@ Caml_inline mlsize_t Scannable_wosize_reserved_byte(reserved_t res,
252
252
#define Num_tags (1ull << HEADER_TAG_BITS)
253
253
#define Max_wosize ((1ull << HEADER_WOSIZE_BITS) - 1ull)
254
254
255
- // Note that Wosize_val and the other macros that read headers will not
256
- // be optimized by common subexpression elimination, because of the
257
- // atomic header loads. It is best to bind the results of such macros
258
- // to variables if they will be tested repeatedly, e.g. as the end condition
259
- // in a for-loop.
260
-
261
- #define Wosize_val (val ) (Wosize_hd (Hd_val (val)))
262
- #define Wosize_op (op ) (Wosize_val (op))
263
- #define Wosize_bp (bp ) (Wosize_val (bp))
264
- #define Wosize_hp (hp ) (Wosize_hd (Hd_hp (hp)))
265
255
#define Whsize_wosize (sz ) ((sz) + 1)
266
256
#define Wosize_whsize (sz ) ((sz) - 1)
267
257
#define Wosize_bhsize (sz ) ((sz) / sizeof (value) - 1)
268
258
#define Bsize_wsize (sz ) ((sz) * sizeof (value))
269
259
#define Wsize_bsize (sz ) ((sz) / sizeof (value))
270
260
#define Bhsize_wosize (sz ) (Bsize_wsize (Whsize_wosize (sz)))
271
261
#define Bhsize_bosize (sz ) ((sz) + sizeof (header_t))
272
- #define Bosize_val (val ) (Bsize_wsize (Wosize_val (val)))
273
- #define Bosize_op (op ) (Bosize_val (Val_op (op)))
274
- #define Bosize_bp (bp ) (Bosize_val (Val_bp (bp)))
275
- #define Bosize_hd (hd ) (Bsize_wsize (Wosize_hd (hd)))
276
- #define Whsize_hp (hp ) (Whsize_wosize (Wosize_hp (hp)))
277
- #define Whsize_val (val ) (Whsize_hp (Hp_val (val)))
278
- #define Whsize_bp (bp ) (Whsize_val (Val_bp (bp)))
279
- #define Whsize_hd (hd ) (Whsize_wosize (Wosize_hd (hd)))
280
- #define Bhsize_hp (hp ) (Bsize_wsize (Whsize_hp (hp)))
281
- #define Bhsize_hd (hd ) (Bsize_wsize (Whsize_hd (hd)))
262
+
263
+ /* Note that Allocated_wosize_val and the other macros that read headers will not
264
+ be optimized by common subexpression elimination, because of the
265
+ atomic header loads. It is best to bind the results of such macros
266
+ to variables if they will be tested repeatedly, e.g. as the end condition
267
+ in a for-loop.
268
+ */
269
+
270
+ /* flambda-backend: We rename the size macros to [Allocated_...] so that we're
271
+ forced to think about whether C code needs to updated for mixed blocks, which
272
+ have separate notions of scannable size and total size of an object, even for
273
+ scannable tags. We call an object's size (including possibly non-scannable
274
+ fields) its "allocated" size to document the fact that you shouldn't scan
275
+ fields on the basis of this size alone.
276
+ */
277
+
278
+ #define Allocated_wosize_val (val ) (Allocated_wosize_hd (Hd_val (val)))
279
+ #define Allocated_wosize_op (op ) (Allocated_wosize_val (op))
280
+ #define Allocated_wosize_bp (bp ) (Allocated_wosize_val (bp))
281
+ #define Allocated_wosize_hp (hp ) (Allocated_wosize_hd (Hd_hp (hp)))
282
+ #define Allocated_bosize_val (val ) (Bsize_wsize (Allocated_wosize_val (val)))
283
+ #define Allocated_bosize_op (op ) (Allocated_bosize_val (Val_op (op)))
284
+ #define Allocated_bosize_bp (bp ) (Allocated_bosize_val (Val_bp (bp)))
285
+ #define Allocated_bosize_hd (hd ) (Bsize_wsize (Allocated_wosize_hd (hd)))
286
+ #define Allocated_whsize_hp (hp ) (Whsize_wosize (Allocated_wosize_hp (hp)))
287
+ #define Allocated_whsize_val (val ) (Allocated_whsize_hp (Hp_val (val)))
288
+ #define Allocated_whsize_bp (bp ) (Allocated_whsize_val (Val_bp (bp)))
289
+ #define Allocated_whsize_hd (hd ) (Whsize_wosize (Allocated_wosize_hd (hd)))
290
+ #define Allocated_bhsize_hp (hp ) (Bsize_wsize (Allocated_whsize_hp (hp)))
291
+ #define Allocated_bhsize_hd (hd ) (Bsize_wsize (Allocated_whsize_hd (hd)))
292
+
293
+ #ifndef Hide_upstream_size_macros
294
+ #define Wosize_hd (hd ) Allocated_wosize_hd(hd)
295
+ #define Wosize_val (val ) Allocated_wosize_val(val)
296
+ #define Wosize_op (op ) Allocated_wosize_op(op)
297
+ #define Wosize_bp (bp ) Allocated_wosize_bp(bp)
298
+ #define Wosize_hp (hp ) Allocated_wosize_hp(hp)
299
+ #define Bosize_val (val ) Allocated_bosize_val(val)
300
+ #define Bosize_op (op ) Allocated_bosize_op(op)
301
+ #define Bosize_bp (bp ) Allocated_bosize_bp(bp)
302
+ #define Bosize_hd (hd ) Allocated_bosize_hd(hd)
303
+ #define Whsize_hp (hp ) Allocated_whsize_hp(hp)
304
+ #define Whsize_val (val ) Allocated_whsize_val(val)
305
+ #define Whsize_bp (bp ) Allocated_whsize_bp(bp)
306
+ #define Whsize_hd (hd ) Allocated_whsize_hd(hd)
307
+ #define Bhsize_hp (hp ) Allocated_bhsize_hp(hp)
308
+ #define Bhsize_hd (hd ) Allocated_bhsize_hd(hd)
309
+ #endif // Hide_upstream_size_macros
282
310
283
311
#define Reserved_val (val ) (Reserved_hd (Hd_val (val)))
284
312
@@ -333,7 +361,7 @@ Caml_inline mlsize_t Scannable_wosize_reserved_byte(reserved_t res,
333
361
with tag Closure_tag (see compact.c). */
334
362
335
363
#define Infix_tag 249
336
- #define Infix_offset_hd (hd ) (Bosize_hd (hd))
364
+ #define Infix_offset_hd (hd ) (Allocated_bosize_hd (hd))
337
365
#define Infix_offset_val (v ) Infix_offset_hd(Hd_val(v))
338
366
339
367
/* Another special case: objects */
0 commit comments