[Pas2js] DCE tool feature

Michael Van Canneyt michael at freepascal.org
Tue Feb 12 20:05:07 CET 2019



On Tue, 12 Feb 2019, warleyalex via Pas2js wrote:

> Just things that crosses my mind, and I want to discuss. Please don’t see
> that as an attack to someone´s work. I really like pas2js and the new
> possibilities.
>
> Pas2js could include an experimental feature called DCE (dead code
> elimination) tool. This tool allows to strip out unused properties,
> functions from the static RTL and the classes from the generated JS. 
>
> Running DCE takes a bit of extra time each build, and the output size does
> not matter during development, but I think important at production to get a
> small bundle JS possible. 
>
> This DCE tool does not perform minification your code by removing
> unnecessary whitespaces and shortening identifiers, for that, you should use
> existing tools, like UglifyJS or Google Closure Compiler for this purpose.

I don't understand. The optimizer normally already does this for all code.
It does WPO (Whole Program Optimization), which is equivalent to 
dead code elimination...

The only exception is that if you have published sections, then it will not 
remove anything related to published sections 
(because it can be set using RTTI which the compiler doesnot know about).

This is why we added {$modeswitch OmitRTTI}: treat class section 'published' as
'public'. In that case, the compiler will really eliminate everything that
is not used.

So I wonder what more do you expect ?

Michael.


More information about the Pas2js mailing list