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
OCaml's compilation strategy for variable references in nested modules leaves
around unnecessary field accesses, which are implicit, and not felt by the
programmer.
For example, if I write:
open Core.Std
let f () = Result.ok_unit
the reference to [Result.ok_unit] gets compiled to three field accesses, one for
each dot in [Core.Std.Result.ok_unit]. Furthermore, these accesses happen every
time [f] is called. I think it would typically be prefereable if [f] were
compiled as if it had been written as follows:
let z = Result.ok_unit in
let f = fun () -> z
I think it is surprising to a programmer for variable reference to be such a
non-constant-time operation.
The text was updated successfully, but these errors were encountered:
The current trunk would compile the code from ygrek to:
camlFoo__access_1012:
.cfi_startproc
.L100:
movq camlFoo__3@GOTPCREL(%rip), %rax
ret
.cfi_endproc
since the value is known structured constant.
If we replace the constant [1;2;3], with, say "Random.int 100", we still get the access code reported by ygrek. With the patch from #6343, we get instead:
Original bug ID: 5537
Reporter: sweeks
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:25:49Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.01.1+dev
Fixed in version: 4.02.0+dev
Category: back end (clambda to assembly)
Has duplicate: #5573
Related to: #5546 #6343
Monitored by: meyer @gasche ronan.lehy@gmail.com dario @ygrek @hcarty @dbuenzli yminsky @yakobowski @alainfrisch
Bug description
OCaml's compilation strategy for variable references in nested modules leaves
around unnecessary field accesses, which are implicit, and not felt by the
programmer.
For example, if I write:
open Core.Std
let f () = Result.ok_unit
the reference to [Result.ok_unit] gets compiled to three field accesses, one for
each dot in [Core.Std.Result.ok_unit]. Furthermore, these accesses happen every
time [f] is called. I think it would typically be prefereable if [f] were
compiled as if it had been written as follows:
let z = Result.ok_unit in
let f = fun () -> z
I think it is surprising to a programmer for variable reference to be such a
non-constant-time operation.
The text was updated successfully, but these errors were encountered: