Ensure all structured constants are registered (#9940)

Allocated constants from other compilation units were not registered, resulting in missed opportunities for unboxing FP and boxed-integer constants.
master
Vincent Laviron 2020-10-06 15:19:51 +02:00 committed by GitHub
parent 952281944d
commit eb342da8a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 1 deletions

View File

@ -534,6 +534,10 @@ Working version
- #9927: Restore Cygwin64 support.
(David Allsopp, review by Xavier Leroy)
- #9940: Fix unboxing of allocated constants from other compilation units
(Vincent Laviron, report by Stephen Dolan, review by Xavier Leroy and
Stephen Dolan)
OCaml 4.11.1
------------

View File

@ -178,7 +178,10 @@ let rec expr_size env = function
let transl_constant dbg = function
| Uconst_int n ->
int_const dbg n
| Uconst_ref (label, _) ->
| Uconst_ref (label, def_opt) ->
Option.iter
(fun def -> Cmmgen_state.add_structured_constant label def)
def_opt;
Cconst_symbol (label, dbg)
let emit_constant cst cont =

View File

@ -76,6 +76,9 @@ let set_structured_constants l =
)
l
let add_structured_constant sym cst =
Hashtbl.replace state.structured_constants sym cst
let get_structured_constant s =
Hashtbl.find_opt state.structured_constants s

View File

@ -41,5 +41,7 @@ val no_more_functions : unit -> bool
val set_structured_constants : Clambda.preallocated_constant list -> unit
val add_structured_constant : string -> Clambda.ustructured_constant -> unit
(* Also looks up using Compilenv.structured_constant_of_symbol *)
val structured_constant_of_sym : string -> Clambda.ustructured_constant option