dead code removal

classic Classic list List threaded Threaded
43 messages Options
123
Reply | Threaded
Open this post in threaded view
|

dead code removal

Franco Ponticelli
Hello List,
I am glad to announce a new nice feature that "may" go in the next official release of haxe: "dead code removal".
Add --dead-code-removal to your compilation command and the compiler will discard any method that is not referenced sparing a few precious bytes in the final output (in theory it should work on all platforms).
Important notes:
  • the command only makes sense if you are compiling using -main
  • it can create issues with Reflect/Type.createInstance/serialization
To keep a class or method untouched you can mark it with the @:keep metadata ... this has been done on the platform specific x.Boot classes.

If you are interested in this feature, please test it ... because it will not be included in the next release unless proven stable and worthy.

Also let me know if/what would you like to improve about it.

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Pimm Hogeling
Sounds really good, Franco.

Will test.

On 14 December 2010 17:18, Franco Ponticelli <[hidden email]> wrote:
Hello List,
I am glad to announce a new nice feature that "may" go in the next official release of haxe: "dead code removal".
Add --dead-code-removal to your compilation command and the compiler will discard any method that is not referenced sparing a few precious bytes in the final output (in theory it should work on all platforms).
Important notes:
  • the command only makes sense if you are compiling using -main
  • it can create issues with Reflect/Type.createInstance/serialization
To keep a class or method untouched you can mark it with the @:keep metadata ... this has been done on the platform specific x.Boot classes.

If you are interested in this feature, please test it ... because it will not be included in the next release unless proven stable and worthy.

Also let me know if/what would you like to improve about it.

Franco

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Baluta Cristian
Very nice feature, i'll test it from nightly builds osx, if it's there?

On Tue, Dec 14, 2010 at 6:49 PM, Pimm Hogeling <[hidden email]> wrote:
Sounds really good, Franco.

Will test.

On 14 December 2010 17:18, Franco Ponticelli <[hidden email]> wrote:
Hello List,
I am glad to announce a new nice feature that "may" go in the next official release of haxe: "dead code removal".
Add --dead-code-removal to your compilation command and the compiler will discard any method that is not referenced sparing a few precious bytes in the final output (in theory it should work on all platforms).
Important notes:
  • the command only makes sense if you are compiling using -main
  • it can create issues with Reflect/Type.createInstance/serialization
To keep a class or method untouched you can mark it with the @:keep metadata ... this has been done on the platform specific x.Boot classes.

If you are interested in this feature, please test it ... because it will not be included in the next release unless proven stable and worthy.

Also let me know if/what would you like to improve about it.

Franco

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Franco Ponticelli
I guess it will be there tonight ... I made my commit a few hours back.

Franco

On Tue, Dec 14, 2010 at 5:18 PM, Baluta Cristian <[hidden email]> wrote:
Very nice feature, i'll test it from nightly builds osx, if it's there?


On Tue, Dec 14, 2010 at 6:49 PM, Pimm Hogeling <[hidden email]> wrote:
Sounds really good, Franco.

Will test.

On 14 December 2010 17:18, Franco Ponticelli <[hidden email]> wrote:
Hello List,
I am glad to announce a new nice feature that "may" go in the next official release of haxe: "dead code removal".
Add --dead-code-removal to your compilation command and the compiler will discard any method that is not referenced sparing a few precious bytes in the final output (in theory it should work on all platforms).
Important notes:
  • the command only makes sense if you are compiling using -main
  • it can create issues with Reflect/Type.createInstance/serialization
To keep a class or method untouched you can mark it with the @:keep metadata ... this has been done on the platform specific x.Boot classes.

If you are interested in this feature, please test it ... because it will not be included in the next release unless proven stable and worthy.

Also let me know if/what would you like to improve about it.

Franco

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Simon Krajewski
In reply to this post by Franco Ponticelli
Hello Franco,

this sounds like an interesting feature. I'm not sure about the @:keep approach though. It's designed to be used in my own classes, but why would I have methods there that I don't want to export into the output? I probably end up putting @:keep in front of every class statement, so it doesn't seem to be too useful like that. Then again, if the compiler cannot tell apart "my classes" and "lib classes", it might actually be necessary when using this feature.

On the other hand I might want to mark methods of library classes to be kept in case I want to use them only via Reflection or something. Since I cannot put @:keep there without modifying the lib class files and making fake method calls is just boring, maybe it makes more sense to allow @:keep for import:

import hsl.haxe.Signaler @:keep([dispatch, bind]);

Reads: Keep Signaler.dispatch and Signaler.bind along with every method of Signaler that is called directly anyway. This would allow the *user* of a lib to specify the class methods to be kept, and since the user is the one who should know which methods might be used only via Reflection/Serialization/VoodooMagic, it seems like a good idea. Obviously, import hsl.haxe.Signaler @:keep; to just keep every method would make sense too.

I'm not an extensive Reflection user, but I think this feature and Reflection-only-used methods should not be mutually exclusive.

Regards
Simon


Am 14.12.2010 17:18, schrieb Franco Ponticelli:
Hello List,
I am glad to announce a new nice feature that "may" go in the next official release of haxe: "dead code removal".
Add --dead-code-removal to your compilation command and the compiler will discard any method that is not referenced sparing a few precious bytes in the final output (in theory it should work on all platforms).
Important notes:
  • the command only makes sense if you are compiling using -main
  • it can create issues with Reflect/Type.createInstance/serialization
To keep a class or method untouched you can mark it with the @:keep metadata ... this has been done on the platform specific x.Boot classes.

If you are interested in this feature, please test it ... because it will not be included in the next release unless proven stable and worthy.

Also let me know if/what would you like to improve about it.

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Franco Ponticelli
Hi Simon, thank you for yours considerations. With John we have already discussed that topic and we agreed that maybe a good solution could be to add the "keep" using a compiler switch; To do that I guess I will leverage on the following:

- "keep" is a metadata 
- macros can add metadatas 
- macros can be called using a switch

That should do the trick ... I'll let you know.

Franco

On Tue, Dec 14, 2010 at 5:26 PM, Simon Krajewski <[hidden email]> wrote:
Hello Franco,

this sounds like an interesting feature. I'm not sure about the @:keep approach though. It's designed to be used in my own classes, but why would I have methods there that I don't want to export into the output? I probably end up putting @:keep in front of every class statement, so it doesn't seem to be too useful like that. Then again, if the compiler cannot tell apart "my classes" and "lib classes", it might actually be necessary when using this feature.

On the other hand I might want to mark methods of library classes to be kept in case I want to use them only via Reflection or something. Since I cannot put @:keep there without modifying the lib class files and making fake method calls is just boring, maybe it makes more sense to allow @:keep for import:

import hsl.haxe.Signaler @:keep([dispatch, bind]);

Reads: Keep Signaler.dispatch and Signaler.bind along with every method of Signaler that is called directly anyway. This would allow the *user* of a lib to specify the class methods to be kept, and since the user is the one who should know which methods might be used only via Reflection/Serialization/VoodooMagic, it seems like a good idea. Obviously, import hsl.haxe.Signaler @:keep; to just keep every method would make sense too.

I'm not an extensive Reflection user, but I think this feature and Reflection-only-used methods should not be mutually exclusive.

Regards
Simon


Am 14.12.2010 17:18, schrieb Franco Ponticelli:
Hello List,
I am glad to announce a new nice feature that "may" go in the next official release of haxe: "dead code removal".
Add --dead-code-removal to your compilation command and the compiler will discard any method that is not referenced sparing a few precious bytes in the final output (in theory it should work on all platforms).
Important notes:
  • the command only makes sense if you are compiling using -main
  • it can create issues with Reflect/Type.createInstance/serialization
To keep a class or method untouched you can mark it with the @:keep metadata ... this has been done on the platform specific x.Boot classes.

If you are interested in this feature, please test it ... because it will not be included in the next release unless proven stable and worthy.

Also let me know if/what would you like to improve about it.

Franco

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Simon Krajewski
Hello again,

sorry for the slight off topic, but could you give a pointer to the "macros can add metadatas" topic? The macro and metadata pages on haxe.org don't mention this and I couldn't find any way of pulling it off.

Thanks in advance!
Simon

Am 14.12.2010 18:33, schrieb Franco Ponticelli:
Hi Simon, thank you for yours considerations. With John we have already discussed that topic and we agreed that maybe a good solution could be to add the "keep" using a compiler switch; To do that I guess I will leverage on the following:

- "keep" is a metadata 
- macros can add metadatas 
- macros can be called using a switch

That should do the trick ... I'll let you know.

Franco

On Tue, Dec 14, 2010 at 5:26 PM, Simon Krajewski <[hidden email]> wrote:
Hello Franco,

this sounds like an interesting feature. I'm not sure about the @:keep approach though. It's designed to be used in my own classes, but why would I have methods there that I don't want to export into the output? I probably end up putting @:keep in front of every class statement, so it doesn't seem to be too useful like that. Then again, if the compiler cannot tell apart "my classes" and "lib classes", it might actually be necessary when using this feature.

On the other hand I might want to mark methods of library classes to be kept in case I want to use them only via Reflection or something. Since I cannot put @:keep there without modifying the lib class files and making fake method calls is just boring, maybe it makes more sense to allow @:keep for import:

import hsl.haxe.Signaler @:keep([dispatch, bind]);

Reads: Keep Signaler.dispatch and Signaler.bind along with every method of Signaler that is called directly anyway. This would allow the *user* of a lib to specify the class methods to be kept, and since the user is the one who should know which methods might be used only via Reflection/Serialization/VoodooMagic, it seems like a good idea. Obviously, import hsl.haxe.Signaler @:keep; to just keep every method would make sense too.

I'm not an extensive Reflection user, but I think this feature and Reflection-only-used methods should not be mutually exclusive.

Regards
Simon


Am 14.12.2010 17:18, schrieb Franco Ponticelli:
Hello List,
I am glad to announce a new nice feature that "may" go in the next official release of haxe: "dead code removal".
Add --dead-code-removal to your compilation command and the compiler will discard any method that is not referenced sparing a few precious bytes in the final output (in theory it should work on all platforms).
Important notes:
  • the command only makes sense if you are compiling using -main
  • it can create issues with Reflect/Type.createInstance/serialization
To keep a class or method untouched you can mark it with the @:keep metadata ... this has been done on the platform specific x.Boot classes.

If you are interested in this feature, please test it ... because it will not be included in the next release unless proven stable and worthy.

Also let me know if/what would you like to improve about it.

Franco

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

MarcWeber
In reply to this post by Franco Ponticelli
Excerpts from Franco Ponticelli's message of Tue Dec 14 17:18:37 +0100 2010:
> Hello List,
> I am glad to announce a new nice feature that "may" go in the next official
> release of haxe: "dead code removal".
That's highly appreciated in particular when targeting JS!

Thanks!
Marc Weber

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Nathan
In reply to this post by Franco Ponticelli
Franco Ponticelli wrote:
> Hello List,
> I am glad to announce a new nice feature that "may" go in the next official
> release of haxe: "dead code removal".
> Add --dead-code-removal

really minor thing, any chance it could be called --dead-code-elimination ?


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Franco Ponticelli
In reply to this post by Simon Krajewski
sorry for the slight off topic, but could you give a pointer to the "macros can add metadatas" topic? The macro and metadata pages on haxe.org don't mention this and I couldn't find any way of pulling it off.

You can obtain a type using Context.getType("pack.MyClass") ... it returns a TInst that contains a ref to ClassField that contains a field Meta. In that object you can use get/add/remove ... fields can have metas too ... and enum fields too :)
Documentation is not updated yet because they are not in any official release yet.

Franco 


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Franco Ponticelli
In reply to this post by Nathan
really minor thing, any chance it could be called --dead-code-elimination ?

Not really an issue for me since no one has used it yet ;) just raise your hand if you prefer elimination.

Franco
 


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

John A. De Goes

Sounds fine by me. 

Regards,

John A. De Goes
Twitter: @jdegoes 
LinkedIn: http://linkedin.com/in/jdegoes

On Dec 14, 2010, at 10:02 AM, Franco Ponticelli wrote:

really minor thing, any chance it could be called --dead-code-elimination ?

Not really an issue for me since no one has used it yet ;) just raise your hand if you prefer elimination.

Franco
 

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Franco Ponticelli
I have changed it to --dead-code-elimination ;)

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Bernard Visscher
In reply to this post by Franco Ponticelli
The builders I have running check every 5 minutes if there is a change
in the svn rev. if so the new rev. is compiled and uploaded. I think the
other builders also run every 5 -10 minutes.
So the name nightly isn't correct, it's more like the 5-minutely builds.

If there is a commit within 5 minutes of the last commit it would be
possible the former isn't compiled.

Bernard

On Tue, 2010-12-14 at 17:26 +0000, Franco Ponticelli wrote:

> I guess it will be there tonight ... I made my commit a few hours
> back.
>
>
> Franco
>
> On Tue, Dec 14, 2010 at 5:18 PM, Baluta Cristian
> <[hidden email]> wrote:
>         Very nice feature, i'll test it from nightly builds osx, if
>         it's there?
>        
>        
>        
>         On Tue, Dec 14, 2010 at 6:49 PM, Pimm Hogeling
>         <[hidden email]> wrote:
>                 Sounds really good, Franco.
>                
>                 Will test.
>                
>                
>                 On 14 December 2010 17:18, Franco Ponticelli
>                 <[hidden email]> wrote:
>                
>                        
>                         Hello List,
>                         I am glad to announce a new nice feature that
>                         "may" go in the next official release of haxe:
>                         "dead code removal".
>                         Add --dead-code-removal to your compilation
>                         command and the compiler will discard any
>                         method that is not referenced sparing a few
>                         precious bytes in the final output (in theory
>                         it should work on all platforms).
>                         Important notes:
>                               * the command only makes sense if you
>                                 are compiling using -main
>                               * it can create issues with
>                                 Reflect/Type.createInstance/serialization
>                         To keep a class or method untouched you can
>                         mark it with the @:keep metadata ... this has
>                         been done on the platform specific x.Boot
>                         classes.
>                        
>                        
>                         If you are interested in this feature, please
>                         test it ... because it will not be included in
>                         the next release unless proven stable and
>                         worthy.
>                        
>                        
>                         Also let me know if/what would you like to
>                         improve about it.
>                        
>                        
>                         Franco
>                        
>                        
>                         --
>                         haXe - an open source web programming language
>                         http://haxe.org
>                
>                
>                 --
>                 haXe - an open source web programming language
>                 http://haxe.org
>        
>        
>        
>        
>         --
>         Băluță Cristian
>         http://ralcr.com
>         http://imagin.ro
>        
>         --
>         haXe - an open source web programming language
>         http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Franco Ponticelli
So the name nightly isn't correct, it's more like the 5-minutely builds.

Very nice ;)

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

MarcWeber
In reply to this post by Franco Ponticelli
Hi Franco & list,

some time ago I announced that I extended the builder script for HaXe.

Do you think there is any chance getting this in as well?

It now contains code to checkout and build HaXe.
It also can run ocamake so that you can use the resulting makefile to
build HaXe incrementally. Even if nobody is using it it serves as
documentation.

I added multiple targets to the install.ml file. So it should be
possible to run it like this easily or the like (syntax may sligthly
differ):

  intall.ml .. some options .. --actions fetch,build,test

Is sending the patch the proposed way contributing this change?

Marc Weber

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Baluta Cristian
I gained 5k for a swf with this feature, long life to you Franco.


On Wed, Dec 15, 2010 at 8:50 PM, Marc Weber <[hidden email]> wrote:
Hi Franco & list,

some time ago I announced that I extended the builder script for HaXe.

Do you think there is any chance getting this in as well?

It now contains code to checkout and build HaXe.
It also can run ocamake so that you can use the resulting makefile to
build HaXe incrementally. Even if nobody is using it it serves as
documentation.

I added multiple targets to the install.ml file. So it should be
possible to run it like this easily or the like (syntax may sligthly
differ):

 intall.ml .. some options .. --actions fetch,build,test

Is sending the patch the proposed way contributing this change?

Marc Weber

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Franco Ponticelli
In reply to this post by MarcWeber
I am not much in the buil process but send the patch and I or Nicolas will review it.
Thanks,
Franco.

On Wed, Dec 15, 2010 at 6:50 PM, Marc Weber <[hidden email]> wrote:
Hi Franco & list,

some time ago I announced that I extended the builder script for HaXe.

Do you think there is any chance getting this in as well?

It now contains code to checkout and build HaXe.
It also can run ocamake so that you can use the resulting makefile to
build HaXe incrementally. Even if nobody is using it it serves as
documentation.

I added multiple targets to the install.ml file. So it should be
possible to run it like this easily or the like (syntax may sligthly
differ):

 intall.ml .. some options .. --actions fetch,build,test

Is sending the patch the proposed way contributing this change?

Marc Weber

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Franco Ponticelli
In reply to this post by Baluta Cristian
On Wed, Dec 15, 2010 at 8:42 PM, Baluta Cristian <[hidden email]> wrote:
I gained 5k for a swf with this feature, long life to you Franco.

It doesn't sound like a big gain :) How big was the SWF before elimination?

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: dead code removal

Baluta Cristian
80k
but about half the size are the fonts.

On Wed, Dec 15, 2010 at 10:56 PM, Franco Ponticelli <[hidden email]> wrote:
On Wed, Dec 15, 2010 at 8:42 PM, Baluta Cristian <[hidden email]> wrote:
I gained 5k for a swf with this feature, long life to you Franco.

It doesn't sound like a big gain :) How big was the SWF before elimination?

Franco

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org
123