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: 6874 Reporter:@mmottl Assigned to:@garrigue Status: closed (set by @xavierleroy on 2016-12-07T10:49:25Z) Resolution: fixed Priority: normal Severity: minor Platform: Mac OS: Mac OS X OS Version: Yosemite Version: 4.02.1 Target version: 4.03.0+dev / +beta1 Fixed in version: 4.03.0+dev / +beta1 Category: middle end (typedtree to clambda) Monitored by:@yakobowski@mmottl
Bug description
Consider the following three implementations of essentially the same function:
module type ARG = sig val f : unit -> unit end
let foo_bad (module Arg : ARG) b =
if b then Arg.f ()
let foo_good1 (arg : (module ARG)) b =
let module Arg = (val arg) in
if b then Arg.f ()
let foo_good2 b (module Arg : ARG) =
if b then Arg.f ()
"foo_bad" generates a lot of unnecessary and expensive machine code whereas "foo_good1" doesn't. "foo_good2" just changes the argument order compared to "foo_bad" and generates equivalently efficient code as "foo_good1".
This seems to indicate that the compiler doesn't check whether subsequent function arguments (initializers for default arguments) actually refer to the unpacked module. The compiler then unnecessarily allocates closures to deal with that situation.
One could improve the compiler by introducing a check whether the module argument is being referred to by others. Maybe one can even solve this issue without any closure allocations in general.
The text was updated successfully, but these errors were encountered:
Fixed in trunk at revision 16135.
Push bindings of module patterns together with defaults.
Also added merging of Lfunctions in Simplif.simplify_lets, while this is not strictly needed for this.
Original bug ID: 6874
Reporter: @mmottl
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:49:25Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: Mac
OS: Mac OS X
OS Version: Yosemite
Version: 4.02.1
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: middle end (typedtree to clambda)
Monitored by: @yakobowski @mmottl
Bug description
Consider the following three implementations of essentially the same function:
"foo_bad" generates a lot of unnecessary and expensive machine code whereas "foo_good1" doesn't. "foo_good2" just changes the argument order compared to "foo_bad" and generates equivalently efficient code as "foo_good1".
This seems to indicate that the compiler doesn't check whether subsequent function arguments (initializers for default arguments) actually refer to the unpacked module. The compiler then unnecessarily allocates closures to deal with that situation.
One could improve the compiler by introducing a check whether the module argument is being referred to by others. Maybe one can even solve this issue without any closure allocations in general.
The text was updated successfully, but these errors were encountered: