You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6337 Reporter:@alainfrisch Assigned to:@alainfrisch Status: closed (set by @xavierleroy on 2015-12-11T18:25:45Z) Resolution: fixed Priority: normal Severity: minor Fixed in version: 4.02.0+dev Category: back end (clambda to assembly) Related to:#5779 Monitored by:@gasche
Bug description
The following code:
let g () =
let r = ref 0 in
let rec f () =
incr r;
print_endline "foo";
in
f
results in the string constant "foo" to be emitted twice. ocamlopt -dcmm shows:
(data int 1024 global "camlFoo" "camlFoo": skip 8)
(data int 2295 "camlFoo__3": addr "camlFoo__g_1010" int 3)
(data global "camlFoo__1" int 1276 "camlFoo__1": string "foo" skip 4 byte 4)
(data global "camlFoo__2" int 1276 "camlFoo__2": string "foo" skip 4 byte 4)
...
Note the presence of camlFoo_1 and camlFoo_2. Only the second one is actually used.
This comes from Closure.close_functions, which tries to compile first the functions under the assumption that their environment is not used, and do it again if this assumption is invalidated. Since structured constants are now allocated during this pass, they can be allocated several times.
One possible fix is to backtrack the list of allocated structured constants when a second pass is required.
Note that even if the sharing of constants is added (#5779), this will still apply because of string literals (which won't be shared, since they are mutable).
The text was updated successfully, but these errors were encountered:
Original bug ID: 6337
Reporter: @alainfrisch
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:25:45Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.02.0+dev
Category: back end (clambda to assembly)
Related to: #5779
Monitored by: @gasche
Bug description
The following code:
results in the string constant "foo" to be emitted twice. ocamlopt -dcmm shows:
Note the presence of camlFoo_1 and camlFoo_2. Only the second one is actually used.
This comes from Closure.close_functions, which tries to compile first the functions under the assumption that their environment is not used, and do it again if this assumption is invalidated. Since structured constants are now allocated during this pass, they can be allocated several times.
One possible fix is to backtrack the list of allocated structured constants when a second pass is required.
Note that even if the sharing of constants is added (#5779), this will still apply because of string literals (which won't be shared, since they are mutable).
The text was updated successfully, but these errors were encountered: