Preloader doesn't allow dead code elimination

59 views
Skip to first unread message

Tim De Pauw

unread,
Jun 26, 2014, 1:10:18 PM6/26/14
to haxe...@googlegroups.com
Hi guys,

I'm trying to port the instructions at http://old.haxe.org/doc/flash/preloader to our (pretty extensive) Haxe project. I got the preloader frame working, but for some reason, I need to turn dead code elimination off in the final step, where the preloader class and the SWC get compiled into a single SWF. Without the '-dce no' flag, I get runtime exceptions on Type.getClass and Type.createInstance not existing, but also some of our own functions. The classes themselves don't seem to be missing. This means that even the standard DCE implementation (and not even the full kind) breaks the SWF.

I'm still able to enable full DCE when creating the SWC, so the loss isn't huge. Even so, with a minimal preloader class, the SWF is still about 20 KB larger than the SWC. Because we are dealing with load time requirements, every kilobyte counts for us. This makes Haxe's preloader implementation unsuitable at this point.

I should note that we already compile a few SWCs into the SWC that eventually gets compiled into the preloading SWF. However, Type.getClass is used several times in the main Haxe codebase that makes up the final SWC, so it really doesn't make sense to me that it would be eliminated.

Does anyone have an idea what could be going on? Can I get more feedback from the DCE somehow?

Thanks,

Tim

Joshua Granick

unread,
Jun 26, 2014, 5:57:00 PM6/26/14
to haxe...@googlegroups.com
Have you tried using @:keep? You can flag a class you don't want to be collected, using this meta-tag. We use it in the OpenFL preloader
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.



--
Using Opera's mail client: http://www.opera.com/mail/

Tim De Pauw

unread,
Jun 27, 2014, 3:18:49 AM6/27/14
to haxe...@googlegroups.com
Yeah, we use @:keep all the time. Without the preloader, everything was working fine. The codebase hasn't changed apart from the preloader class.

Also, as soon as one of our functions references Haxe's Type.getClass function, there's no reason to eliminate it, so I don't see how @:keep would solve this issue.



You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.

For more options, visit https://groups.google.com/d/optout.



--
Tim De Pauw
Player Engineer
+32 496 28 22 06

www.zentrick.com
Axxes Business Park, Guldensporenpark 2 building A
9820 Merelbeke, Belgium
Twitter • LinkedIn • Facebook • Google+
Reply all
Reply to author
Forward
0 new messages