|Anonymous | Login | Signup for a new account||2015-07-03 17:43 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006029||OCaml||Ocaml optimization||public||2013-06-03 18:30||2015-02-25 23:29|
|Target Version||4.03.0+dev||Fixed in Version|
|Summary||0006029: lazy should be primitive|
|Description||Currently, only Lazy.force is compiled as a primitive function, while the keyword "lazy" is not. This has various drawbacks:|
1. One has to explicitly put Lazy.from_val to get an efficient lifting, while the compiler could do it automatically in front of syntactical values;
2. Even doing so, there is a small penalty to pay because of the special treatment of float values, which could be inferred statically, similarly to array accesses.
3. This is unlikely to happen, but that also permits code rewriting such as "Lazy.force (lazy t)" as "t".
|Steps To Reproduce||The following examples generates a lot of assembly noise:|
type 'a stream = 'a node Lazy.t
and 'a node = Cons of 'a * 'a stream
let cons1 x s = lazy (Cons (x, s))
let cons2 x s = Lazy.from_val (Cons (x, s))
while they could be compiled exactly like:
let cons3 x s = Obj.magic (Cons (x, s))
|Tags||No tags attached.|
> 1. One has to explicitly put Lazy.from_val to get an efficient lifting, while the compiler could do it automatically in front of syntactical values;
There is already some code in translcore.ml to do so (see the case for Texp_lazy).
The case of pure constructors with arguments (and records) is currently not optimized. I'm not sure why, but this is easy to change without changing more deeply the way "lazy" is compiled.
> 2. Even doing so, there is a small penalty to pay because of the special treatment of float values, which could be inferred statically, similarly to array accesses.
Note to anyone who wants to implement this: float values cannot always be inferred statically, so be ready to have the run-time test in some cases.
|2013-06-03 18:30||ppedrot||New Issue|
|2013-06-04 15:12||frisch||Note Added: 0009390|
|2013-06-18 15:50||doligez||Status||new => confirmed|
|2013-06-18 15:50||doligez||Target Version||=> 4.02.0+dev|
|2013-07-12 18:15||doligez||Target Version||4.02.0+dev => 4.01.1+dev|
|2013-12-16 16:40||doligez||Note Added: 0010724|
|2014-05-25 20:20||doligez||Target Version||4.01.1+dev => 4.02.0+dev|
|2014-07-16 20:38||doligez||Target Version||4.02.0+dev => 4.02.1+dev|
|2014-09-04 00:25||doligez||Target Version||4.02.1+dev => undecided|
|2014-09-22 21:53||doligez||Category||OCaml backend (code generation) => Ocaml optimization|
|2014-09-22 21:53||doligez||Target Version||undecided => 4.02.2+dev / +rc1|
|2015-02-25 23:29||doligez||Target Version||4.02.2+dev / +rc1 => 4.03.0+dev|
|Copyright © 2000 - 2011 MantisBT Group|