[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MirageOS-devel] Fwd: [Caml-list] Dead code detection



This is a really interesting new feature in the next OCaml.  We should be able 
to use it to do comprehensive dead code elimination on both Unix and Xen Mirage 
binaries on native code (since we don't need dynamic linking).

This, in combination with the new module aliases feature, should shrink binary 
sizes considerably.

-anil

Begin forwarded message:

> From: Alain Frisch <alain@xxxxxxxxx>
> Subject: Re: [Caml-list] Dead code detection
> Date: 11 December 2013 15:07:35 GMT
> To: Pierre-Yves Strub <pierre-yves@xxxxxxxx>, caml-list@xxxxxxxx
> Reply-To: Alain Frisch <alain@xxxxxxxxx>
> 
> At LexiFi, we use two different techniques for detecting dead code:
> 
> - Bisect, for a dynamic notion of "dead code" (i.e. code which is not 
> exercised by our testsuite).
> 
> - A custom static detection tool, which parses .cmt and .cmi files to detect 
> exported components (values, exceptions, etc) used by no other module in the 
> project.  This is of course combined with the existing compiler warnings on 
> locally unused and non-exported declarations.
> 
> 
> The next version of OCaml will make it extremely simple to implement such a 
> static detection tool.  This is because of the new -keep-locs compiler flag, 
> which allows us to keep the location of exported values in .cmi files, and 
> thus retrieve the same locations on references to such values in .cmt files.  
> It makes it very easy to create the link between an exported value and its 
> references in external modules, even if this goes through e.g. module 
> inclusions.  As a proof of concept of this approach, we can already try the 
> tool experimental/frisch/unused_exported_values.ml in the trunk:
> 
> http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/trunk/experimental/frisch/unused_exported_values.ml?revision=HEAD&view=markup
> 
> 
> (-keep-locs also gives "for free" a jump-to-definition feature, just by 
> parsing .cmt or .annot files.)
> 
> 
> Hope this helps,
> 
> Alain
> 
> 
> 
> 
> On 12/11/2013 03:52 PM, Pierre-Yves Strub wrote:
>> Hi all,
>> 
>> Does any of you know a tool for doing dead code detection?
>> 
>> Thanks,
>> -- Pierre-Yves.
>> 
>> 
> 
> 
> -- 
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 


_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.