Skip to content

Commit 8331712

Browse files
authored
flambda-backend: Unconditionally reserve the top header byte in runtime 4 and runtime 5 (#2389)
1 parent a4cd586 commit 8331712

File tree

7 files changed

+48
-35
lines changed

7 files changed

+48
-35
lines changed

configure

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+10-9
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ CSCFLAGS=""
6161
ostype="Unix"
6262
SO="so"
6363
toolchain="cc"
64-
reserved_header_bits=0
64+
reserved_header_bits=8
65+
profinfo=true
66+
profinfo_width=8
6567
custom_ops_struct_size=64
6668
instrumented_runtime=false
6769
instrumented_runtime_libs=""
@@ -205,6 +207,8 @@ AC_SUBST([install_bytecode_programs])
205207
AC_SUBST([install_source_artifacts])
206208
AC_SUBST([install_ocamlnat])
207209
AC_SUBST([reserved_header_bits])
210+
AC_SUBST([profinfo])
211+
AC_SUBST([profinfo_width])
208212
AC_SUBST([custom_ops_struct_size])
209213
AC_SUBST([frame_pointers])
210214
AC_SUBST([cpp_mangling])
@@ -463,14 +467,6 @@ AC_ARG_WITH([target-bindir],
463467
[AS_HELP_STRING([--with-target-bindir],
464468
[location of binary programs on target system])])
465469

466-
AC_ARG_ENABLE([reserved-header-bits],
467-
[AS_HELP_STRING([--enable-reserved-header-bits=BITS],
468-
[reserve BITS (between 0 and 31) bits in block headers])],
469-
[AS_CASE([$enable_reserved_header_bits],
470-
[[[0-9]]|[[1-2]][[0-9]]|3[[0-1]]],
471-
[ reserved_header_bits=$enable_reserved_header_bits],
472-
[AC_MSG_ERROR([invalid argument to --enable-reserved-header-bits])])])
473-
474470
AC_ARG_ENABLE([stdlib-manpages],
475471
[AS_HELP_STRING([--disable-stdlib-manpages],
476472
[do not build or install the library man pages])])
@@ -2207,7 +2203,12 @@ AS_IF([test x"$enable_naked_pointers_checker" = "xyes" ],
22072203
## Check for mmap support for huge pages and contiguous heap
22082204
OCAML_MMAP_SUPPORTS_HUGE_PAGES
22092205

2206+
# Unconditionally reserve 8 header bits in both runtime 4 and
2207+
# runtime 5, which is required for mixed block support.
22102208
AC_DEFINE_UNQUOTED([HEADER_RESERVED_BITS], [$reserved_header_bits])
2209+
AC_DEFINE_UNQUOTED([PROFINFO_WIDTH], [$profinfo_width])
2210+
AS_IF([$profinfo], [AC_DEFINE([WITH_PROFINFO])])
2211+
22112212
AC_DEFINE_UNQUOTED([CUSTOM_OPS_STRUCT_SIZE], [$custom_ops_struct_size])
22122213

22132214
AS_IF([test x"$enable_installing_bytecode_programs" = "xno"],

runtime/caml/mlvalues.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ For 64-bit architectures:
105105
+----------+--------+-------+-----+
106106
bits 63 64-R 63-R 10 9 8 7 0
107107
108-
where 0 <= R <= 31 is HEADER_RESERVED_BITS, set with the
109-
--enable-reserved-header-bits=R argument to configure.
108+
where 0 <= R <= 31 is HEADER_RESERVED_BITS. R is always
109+
set to 8 for the flambda-backend compiler in order to support
110+
mixed blocks. In the upstream compiler, R is set with the
111+
--enable-reserved-header-bits=R argument.
110112
111113
*/
112114

runtime4/caml/mlvalues.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,15 @@ For 64-bit architectures:
103103
+--------+-------+-----+
104104
bits 63 10 9 8 7 0
105105
106-
For x86-64 with Spacetime profiling:
107-
P = PROFINFO_WIDTH (as set by "configure", currently 26 bits, giving a
108-
maximum block size of just under 4Gb)
106+
For 64-bit architectures with mixed block support enabled:
107+
P = PROFINFO_WIDTH (as set by "configure", currently 8 bits)
109108
+----------------+----------------+-------------+
110-
| profiling info | wosize | color | tag |
109+
| scannable size | wosize | color | tag |
111110
+----------------+----------------+-------------+
112111
bits 63 (64-P) (63-P) 10 9 8 7 0
113112
113+
Mixed block support uses the PROFINFO_WIDTH functionality
114+
originally built for Spacetime profiling, hence the odd name.
114115
*/
115116

116117
#define Tag_hd(hd) ((tag_t) ((hd) & 0xFF))

tools/ci/inria/other-configs/script

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ ${main} -conf --disable-native-compiler \
3939
-no-native
4040
${main} -conf --disable-flat-float-array
4141
${main} -conf --enable-flambda
42-
${main} -conf --enable-frame-pointers -conf --enable-reserved-header-bits=27
42+
${main} -conf --enable-frame-pointers
4343
${main} -with-bootstrap -conf --with-pic
4444
OCAMLRUNPARAM="c=1" ${main}

utils/config.generated.ml.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ let asm = {@QS@|@AS@|@QS@}
9999
let asm_cfi_supported = @asm_cfi_supported@
100100
let with_frame_pointers = @frame_pointers@
101101
let with_cpp_mangling = @cpp_mangling@
102-
let reserved_header_bits = @reserved_header_bits@
103102
let custom_ops_struct_size = @custom_ops_struct_size@
104103

105104
let ext_exe = {@QS@|@exeext@|@QS@}
@@ -119,3 +118,6 @@ let ar_supports_response_files = @ar_supports_response_files@
119118

120119
let naked_pointers = "@naked_pointers@" = "true"
121120
let runtime5 = "@enable_runtime5@" = "yes"
121+
122+
let reserved_header_bits =
123+
if runtime5 then @reserved_header_bits@ else @profinfo_width@

utils/config.mli

+8-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,14 @@ val with_cmm_invariants : bool
233233
(** Whether the invariants checks for Cmm are enabled *)
234234

235235
val reserved_header_bits : int
236-
(** How many bits of a block's header are reserved *)
236+
(** How many bits of a block's header are reserved. This is correct
237+
regardless of whether we're in runtime 4 or runtime 5.
238+
239+
In runtime 5, this corresponds to the HEADER_RESERVED_BITS C preprocessor
240+
macro. In runtime 4, this corresponds to the PROFINFO_WIDTH C preprocessor
241+
macro. Both of these are unconditionally set to a constant by the configure
242+
script in order to enable mixed block support.
243+
*)
237244

238245
val custom_ops_struct_size : int
239246
(** Size in bytes of the custom operations structure. *)

0 commit comments

Comments
 (0)