Introducing ASC 2.0 by Thibault Imbert

ASC 2.0A few minutes ago we just posted a preview on Adobe Labs of the new ActionScript Compiler (ASC 2.0) as part of the AIR 3.4/FP 11.4 SDK. You can find the complete release notes here. To fully utilize this new AIR 3.4 preview SDK, make sure you use Flash Builder 4.7 Preview also available here, which includes all this, plus things like Concurrency (ActionScript Workers) support for debugging and more.

Here are below the main improvements added to the ActionScript compiler:

  • Flash Builder 4.7 and the ASC 2.0 command-line compiler now share the same code model. This avoids duplicate representations of a program and means the IDE has an accurate representation of the language - matching the compiler.
  • A new multi-threaded architecture allows multiple files to be compiled at once, improving compilation time.
  • Better constant-folding and constant-propagation results in better performing code at runtime.
  • Reduces function overhead by removing unnecessary activation records.
  • Contains some demonstration byte-code optimizations for in-lining and dead code elimination.
  • Non-linear control flow added to AS3 through a new 'goto' keyword.
  • SWF 13 with LZMA compression is now supported.
  • A new symbol management system means Flash Builder 4.7 ActionScript workspaces that mix Flash and AIR projects should incrementally compile much faster.
  • ASC 2.0 based versions of fontswf, optimizer, swfdump and swcdepends command-line tools are available.
  • Legacy versions of asdoc and fdb command-line tools are also still included.
  • Font transcoding has been removed from [Embed] syntax. Fonts should be pre-transcoded and embedded as a SWF, which can be performed using a tool like fontswf or Flash Professional CS6.
  • Relative paths in source code ([Embed] assets, includes, etc...) resolve relatively from the including file. To specify a path relative from a source root, prefix your path with a forward slash '/'.
  • US English compiler error messages have been translated into French, Japanese, and Simplified Chinese. The locale is determined by the JVM and can be overridden using the -tools-locale configuration option.

We also added support for inlining. When the inlining feature is enabled, the compiler will attempt to inline getters, setters and any functions which are decorated with [Inline] metadata. Make sure you also add the -inline compiler argument.

A function can be inlined when the following constraints are met:

  • The function is final, static or the containing scope is file or package
  • The function does not contain any activations
  • The function does not contain any try or with statements
  • The function does not contain any function closures
  • The function body contains less than 50 expressions

Below are some basic examples of functions which the compiler will and won't be able to inline.

package
{
    public interface IA
    {
        function get m():int;
        function f0(p:int):int
    }

    public class A implements IA
    {
        private var _m:int = 0;
        private static var _s:int = 0;

        // inlineable as final getter
        [Inline]
        final public function get m():int
        {
            return _m;
        }

        // inlineable as final setter
        [Inline]
        final public function set m(m:int):void
        {
            if (m > 0)
                _m = m;
            else
                _m = 0;
        }

        // inlineable as static getter
        [Inline]
        static public function get s():int
        {
            return _s;
        }

        // inlineable as static setter
        [Inline]
        static public function set s(s:int):void
        {
            _s = s;
        }

        // inlineable as decorated with inline metadata and final
        [Inline]
        final public function f0(p:int):int
        {
            var v:int = p + _m;
            return v;
        }

        // not inlineable as decorated with inline metadata and final, but
        // contains try stmt
        final public function f1(p:int):int
        {
            try
            {
                return p + _m;
            }
            finally
            {
                return 0;
            }
        }
    }
}

var a:A = new A();
a.m = 5; //inlined
A.s = 7; //inlined
a.f0(0); //inlined
a.f1(0); // not-inlined, as f1 contains a try stmt

var ia:IA = a;
ia.f0(0); // not-inlined as f0 access through an interface

If you want to know more about the backward compatibility for ASC 2.0, check the following link.

Please test ASC 2.0 and provide your feedback on performance or any potential bugs you may find. Thanks guys!

Comments (91)

  1. seb wrote::

    nice thanks

    Tuesday, August 28, 2012 at 8:08 am #
  2. Wow, that sounds AWESOME! Inlining alone is a killer feature for me. No more copy-pasting performance critical code!! You have made a red bird and its servant very very happy! =)

    Tuesday, August 28, 2012 at 8:48 am #
  3. ben w wrote::

    woooooooooo Inlining! Well done guys, codebases everywhere are about to shrink :)

    Tuesday, August 28, 2012 at 9:10 am #
  4. Will this compiler as part of mxmlc (Flex SDK or Apache Flex) to compiling for web (FlashPlayer), or exclusively for AIR SDK ?

    Tuesday, August 28, 2012 at 9:12 am #
  5. Szymon Brych wrote::

    Hi, I have question about inlining. Namely, why this cannot be done automatically? Are there any scenerios when it is possible to inline a function, however we may not want to do it?

    Tuesday, August 28, 2012 at 9:15 am #
  6. Thibault Imbert wrote::

    Hi VirtualMaestro,

    It will be for both Flash Player and AIR, but not part of MXMLC. So in other words, ASC 2.0 compiles can target Flash Player and AIR.

    Thibault

    Tuesday, August 28, 2012 at 9:19 am #
  7. Mark wrote::

    Hi Thibault,

    This sounds great, I’m looking forward for that compile speed but the optimizations like in-lining sounds very good!! Big props for the team!

    Are there plans for the compiler to be updated more frequently?

    Question: You’ve stated in the post it is “part of the AIR 3.4 SDK.”. Does this mean it is not part of the Flex SDK? Will the compiler be available for non-AIR compilation? I don’t understand how I have to see this?

    Tuesday, August 28, 2012 at 9:26 am #
  8. Thibault Imbert wrote::

    Hi Szymon,

    Inlining will make your final SWF bigger if used a lot, given that the body of the function called will be moved into the control flow. Inlining essentially reduces the cost of function calls.

    So, you don’t want inlining to happen on all functions. You want to use inlining only on expensive and highly frequently called functions.

    Thibault

    Tuesday, August 28, 2012 at 9:31 am #
  9. Thibault Imbert wrote::

    Hi Mark,

    No, no worries! ASC 2.0 of course can also target Flash Player, not AIR only. Sorry for the confusion!

    Thibault

    Tuesday, August 28, 2012 at 9:33 am #
  10. Martin wrote::

    Wow. Is this Falcon? And a 64bit version of Flash Builder at last! :D

    Tuesday, August 28, 2012 at 9:39 am #
  11. Thibault Imbert wrote::

    Hi Martin,

    Yes this project was previously called Falcon. Though Falcon has been donated to Apache and was a slightly different source code with partial support for MXML. ASC 2.0 is ActionScript 3 only.

    Thibault

    Tuesday, August 28, 2012 at 9:54 am #
  12. RetroModular wrote::

    In a word, awesome! I wasn’t expecting to see this until the middle of next year. Great work guys :)

    Has the sound API also been been fixed now?

    Tuesday, August 28, 2012 at 10:20 am #
  13. mth4 wrote::

    Hi Thibault,

    I would like to use that new compiler in my project, but I use a lot of MXML to draw the UI.

    Can I just divide the project into two modules – one with MXML compiled with mxmlc and second pure AS3 compiled with ASC 2.0?

    Tuesday, August 28, 2012 at 10:21 am #
  14. goshki wrote::

    Very nice but:

    “Font transcoding has been removed from [Embed] syntax.”

    Why so?

    Tuesday, August 28, 2012 at 12:22 pm #
  15. Why we need ‘goto’?

    Tuesday, August 28, 2012 at 1:36 pm #
  16. ali_o_kan wrote::

    ASC2 == the arrival of Monocle ?

    Tuesday, August 28, 2012 at 1:40 pm #
  17. Pedro Fernandez wrote::

    Hi Thibault,

    What about the flash professional CSx compiler?. Its “slow” compiling complex projects. Will be updated with this compiler?

    Thanks!

    Tuesday, August 28, 2012 at 1:43 pm #
  18. archont wrote::

    Finally, inlining made it to AS3. Now all I need is pure virtual functions and we’re all set.

    And yes, I know we have interfaces and overrides. Interfaces are only good for external classes loaded at runtime and overriding is messy and has no good IDE support.

    Tuesday, August 28, 2012 at 2:15 pm #
  19. zeh wrote::

    Wait, no more font transcoding? Does this mean we can’t do font [Embed]s anymore?

    Does this still work?

    [Embed(source="./../embed/fonts/something_bold.ttf", fontFamily="Something Bold", mimeType="application/x-font", embedAsCFF="true")]
    protected static const fontSB:Class;

    Tuesday, August 28, 2012 at 4:22 pm #
  20. Daniel Bunte wrote::

    this sounds fantastic! especially the inlining feature, which i already tried to accomplish using yogda. can’t wait to try that on our game Xatrium.
    the reduced function overhead will be inspected ;) i’ll also try ‘goto’

    Tuesday, August 28, 2012 at 5:03 pm #
  21. David Q Hogan wrote::

    Just read through the compiler changes, the tightening up of the language looks great. Migrating to ASC 2.0 should expose a bug or too in my 5-years-old-and-counting codebase!

    Tuesday, August 28, 2012 at 6:23 pm #
  22. Daniel Bunte wrote::

    i’d really like to contribute and report some bugs, but i don’t know where to do that ^^

    Tuesday, August 28, 2012 at 7:24 pm #
  23. HB wrote::

    Really nice. Is there any benchmark comparing projects compiled with ASC 2.0 and the previous version?

    Would be nice to see performance comparisons between the results, even better if Apparat would be brought into the contest.

    I would also like to vote so fonts can be compiled through the embed tag again. Even if there are workarounds or other tools, it would be nice to have a single tool for it. If ASC 2.0 would call fontswf below would be nice either way.

    Tuesday, August 28, 2012 at 7:35 pm #
  24. David Roth wrote::

    I am the developer who implemented inlining and would love to hear of any feedback or problems you have with this feature. You can provide feedback at http://forums.adobe.com/community/labs/flashplatformruntimes/air3-4/

    Also, I’d like to add one more current limitation which wasn’t mentioned above. Functions will only be inlined within a SWC or a SWF, and not across SWC boundaries. This means that an inline eligible function defined in a SWC will be inlined when called from within the SWC, but when the function is called from a different SWC or SWF, the function will not be inlined.

    Tuesday, August 28, 2012 at 8:03 pm #
  25. marcaia wrote::

    Hi everyones,
    I started to develop my last project with AIR 3.2, so I did not care about “final” statement.
    Now I upgraded to SDK 3.4 and ASC 2.0.
    But to have some benefits by in-lining, I have to add “final” statement to my functions.
    My functions are hundreds. Can I add “final” statement directly to the class?

    E.S.
    package{
    final public class MyClass {
    function MyClass(){}
    function method0(){}
    }
    }

    in compiler arguments, what is the syntax?
    is -inline enough?

    “Font transcoding has been removed from [Embed] syntax…”
    First I used this approach, but I had to refactor my code and now I use an SWC with Fonts.

    Wednesday, August 29, 2012 at 2:23 am #
  26. Bob wrote::

    When talking about the requirements for inlining a function, one of the rules is that “The function does not contain any activations”. What additional constraints does this add other than the ones mentioned in the other bullet points?

    Wednesday, August 29, 2012 at 2:38 am #
  27. Woh! Great job, core Flash team. I’ve wished for these features for SUCH a long time, but I’m happy that we got it eventually. Why was ‘goto’ added to the language… it can introduce so many anti-pasterns.

    Wednesday, August 29, 2012 at 2:57 am #
  28. virtualtoy wrote::

    Do you have any plans on improving preprocessor? And GOTO? Are you serious?

    Wednesday, August 29, 2012 at 3:01 am #
  29. scalvert wrote::

    GOTO?!?! In 2012?! Wow…

    Wednesday, August 29, 2012 at 5:30 am #
  30. Thibault Imbert wrote::

    Hi guys,

    GOTO was added for the Flascc team (nee Alchemy). They needed it so we added it.

    Thibault

    Wednesday, August 29, 2012 at 6:44 am #
  31. HB wrote::

    Also, goto is supported in most languages and used by compiled code behind the curtains most times. For example, a lot of compiled .Net code uses it.

    Wednesday, August 29, 2012 at 11:22 am #
  32. Martin wrote::

    Is Flash Builder 4.7 free for 4.6 users ?

    Wednesday, August 29, 2012 at 12:46 pm #
  33. Michael wrote::

    Are there plans for releasing ASC 2 for Linux?

    Wednesday, August 29, 2012 at 1:38 pm #
  34. RetroModular wrote::

    Guys, the new GOTO statement is fine, it doesn’t need to be used if you are anti-pattern anal. Speaking of which, the most optimised game engines are generally full of anti-pattern code for performance reasons, you will rarely see anything like MVC in good game engines. Take a look at the original source code for games such as Quake and Doom (available at GitHub) and you will see what I mean :)

    Wednesday, August 29, 2012 at 2:45 pm #
  35. zeh wrote::

    Again, can someone clarify whether Font [Embed]s are completely gone? And if so, what’s the reasoning behind it? Sounds like a big feature loss.

    Wednesday, August 29, 2012 at 3:48 pm #
  36. Thibault Imbert wrote::

    Hi zeh,

    Yes, we had to remove this because of some dependencies we wanted to get rid of. But agreed, it is unfortunate cause this feature was really useful. We are considering adding it back.

    Thibault

    Wednesday, August 29, 2012 at 7:24 pm #
  37. Peter Farland wrote::

    With respect to transcoding assets at source compile time, this can be an expensive operation, especially fonts. One would pay this cost every time you clean compile.

    Are the workflow costs of pre-transcoding vs. compilation performance worth the trade-off?

    Wednesday, August 29, 2012 at 9:07 pm #
  38. mbolt wrote::

    >> “Relative paths in source code ([Embed] assets, includes, etc…) resolve relatively from the including file. To specify a path relative from a source root, prefix your path with a forward slash ‘/’.”

    I’ve used this method of relative asset resolution in my Embed tags for quite some time now. I’m probably missing a subtle difference. Let’s say I have two directories in my root:

    src/
    assets/

    Let’s say my package is “bolt.example” and my document class is: Main.as

    src/bolt/example/Main.as

    Let’s say I have an image in my assets/ directory named: image.png

    In my Main class, I could Embed the image.png asset as follows:

    [Embed(source="/../assets/image.png", mimeType="image/png")]
    private static const ImageAsset:Class;

    Is there a change to this?

    Wednesday, August 29, 2012 at 9:11 pm #
  39. zeh wrote::

    Thibault/Peter: I guess I understand the compilation’s point of view. However, in all honesty, I think not having the [Embed] anymore is a real deal-breaker. I’m astonished this was done.

    Think about it this way – workflow-wise, it’s much better to have a single [Embed] and a native font file (ttf, otf) somewhere in my project. It’s much cleaner and direct. The alternative – having a middle-ware SWF! – would be just a pain in back to maintain, as I’d have to edit and compile a new SWF on every font change instead of just copy files or change the referenced name on a class.

    What if we had the [Embed] back – even with the ‘disadvantage’ of transcoding, isn’t it up to the developer do decide whether he’ll have to deal with it or not? Better to give them the ability to use SWFs if they want to, but leave the [Embed] there in case they prefer it (which, honestly, I do – 100% of my AIR/SWF projects use a separate class for fonts).

    Just removing the [Embed] altogether seems like a very radical solution. Not a real solution even, just a way to force the developer to make something faster but breaking a flexible workflow in retaliation.

    Wednesday, August 29, 2012 at 11:03 pm #
  40. David Roth wrote::

    Hi marcaia,

    With the version of ASC2 on labs, you will be required to mark each method as final for it to be inlined. However, I have just updated the compiler to also inline non-final methods on a class, if the class is final. This change will be available in the next drop.

    Dave

    Thursday, August 30, 2012 at 1:11 am #
  41. wjordan wrote::

    Spent a few hours today trying to compile a rather complex AS3 project with this new compiler. Here is my current list of issues, mostly minor, that reflect some inconsistencies between the old and the new compiler:

    - Metadata tags with property values set from expressions not enclosed in literal quotes (e.g. boolean values) are not parsed as they were in the old compiler. For example, [Inject(required=true)] will not parse properly, and the metadata parameter will not be accessible via reflection. However, [Inject(required='true')] does work.

    - I was having some issues passing typed objects into a function with untyped function parameters in its signature, which were always received by the called function as ‘undefined’. I didn’t track down what the issue was exactly, but changing all untyped objects to “Object” and doing explicit casting when necessary was a workaround for now.

    - Possibly related, but I had issues in the new compiler with a function with the syntax ‘return foo ||= new Foo();’, where the return value was of type IFoo (where Foo implements IFoo). Splitting this up into a more verbose ‘if’ statement was a workaround.

    - Seems that the ‘arguments’ function property is no longer available? This kills any code that depends on ‘arguments.callee’.

    - There were various issues related to function closures. One had to do with an anonymous function declared in a static function calling a different static function within the same class (produced a method not found error in the new compiler). Another had to do with an anonymous function defined with a (…args) parameter invoked with zero arguments (produced a ‘verify error’ runtime exception in the new compiler). Another (this one only appeared with my IDE connected to the debug player) had to do with a local variable declared with the same name as an existing getter method where the local variable was being referenced from the anonymous function.

    - Very minor- comments between a multi-variable declaration choke on the new compiler but works on the old one, eg:
    /** comment 1*/
    public static var foo:* = 10,
    /** comment 2*/
    bar:* = 20;

    - XML elements declared with periods in the element name (e.g. value) choke on the new compiler and produce a slew of syntax errors.

    Thursday, August 30, 2012 at 3:21 am #
  42. ooxxchina wrote::

    how we kwone the inline if succeed?will warning?

    [Inline]
    static public function get s():int
    {
    return _s;
    }

    static public function get s():int
    {
    return _s;
    }

    the inlineable function i not add [Inline] it will inline or not?

    private function not final or static inlieable or not?

    Thursday, August 30, 2012 at 4:51 am #
  43. Somebody wrote::

    I love how you’re willing to add goto for flascc, even though there are ways to work without it, and even though it does radical damage to the language, but you won’t add basic things like joystick support or constructive audio for the community for 15 years.

    “But we added joystick support a year ago!”

    Yeah. Much too little, much too late.

    Enjoy trying to turn molehill into a mountain. Flash died years ago when you wasted time building out ridiculous platform libraries instead of doing what your developers needed.

    You could have owned video games. :/

    Thursday, August 30, 2012 at 2:42 pm #
  44. crankshaft wrote::

    If I have a pure-AS3 project as a Flex Library Project in FB 4.7, will it compile it with the new ASC 2.0 compiler? Or not?

    Thursday, August 30, 2012 at 4:14 pm #
  45. Peter wrote::

    The inlining doesn’t seem to work I mean even something as simple as this:

    class A {
    private var _a:int = 0;
    final public function get a():int {return _a};
    }

    class B {
    var a:A = new A();
    var test:int = a.a;
    }

    Will throw an error:
    Property A::_a not found on A and there is no default value.

    Thursday, August 30, 2012 at 9:13 pm #
  46. Lee Burrows wrote::

    Hi Thibault,

    Are there plans to extend ASC2.0 to include MXML in the future?

    How about AS3 generated from MXML? Is it possible/easy to compile that with ASC2.0 now?

    PS: Monocle, concurrency, ASC2.0 – nice to see some positives in the Flash universe for a change. Keep up the good work ;)

    Thursday, August 30, 2012 at 11:50 pm #
  47. Hi Thibault and Everyone,

    To try ASC 2.0 in FlashDevelop 4.x, follow this:
    http://www.pureas3.org/fr/le-nouveau-compilateur-as3-asc-2-0-sous-flashdevelop

    Sorry for French, but it’s easy :-)

    Friday, August 31, 2012 at 9:55 am #
  48. Makaroshka wrote::

    Hi, regarding the fontswf tool. How am I suppose to use it? It produces an swf file, which I do not how to use. If I just load it into my application, I still don’t have access to this font.

    There are tons of tutorials of how to produce an swf from ttf, but nobody says what to do with that resulting swf.

    Friday, August 31, 2012 at 10:25 am #
  49. Peter Farland wrote::

    To use the fontswf tool, the trick is in generating the right kind of font for the target text engine (TextField vs FTE), getting the right kind of face (plain, bold, italic, or bold+italic), and getting a predictable font symbol alias (aka font name) to refer to at runtime.

    Example: Embedding a bold font face to be used with an old-school flash.text.TextField based text.

    a). Transcode TTF to SWF:
    fontswf -3 -a “MyBoldFont” -bold -o path/to/someboldfont.swf path/to/someboldfont.ttf

    This would create a suitable DefineFont3 with the alias (symbol name) “MyBoldFont” and set the bold flag. It would embed all of the glyphs available in the TTF for the given font face.

    You can copy this SWF to your application, usually in some assets folder.

    b). Embed Font SWF into Application:
    You would then embed your font symbol from the SWF in your application. Here’s a snippet below, but this will be included in the next step too.

    [Embed(source="/assets/fonts/someboldfont.swf", symbol="MyBoldFont")]
    private static var myFont:Class;

    The forward slash means to search from the source root. You can also use relative paths from the source file doing the embedding.

    c). Then apply the embedded font when formatting a TextField. Here’s an example:

    // FontTest.as
    package
    {

    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;

    public class FontTest extends Sprite
    {
    [Embed(source="/assets/fonts/myboldfont.swf", symbol="MyBoldFont")]
    private static var myFont:Class;

    private var tf:TextField;

    public function FontTest()
    {
    var format:TextFormat = new TextFormat(“MyBoldFont”, 28, 0×666666, true);
    tf = new TextField();
    tf.x = 50;
    tf.y = 50;
    tf.width = 200;
    tf.height = 100;
    tf.multiline = true;
    tf.defaultTextFormat = format;
    tf.embedFonts = true;
    tf.text = “Hello, World!”;
    addChild(tf);
    }
    }

    }

    Friday, August 31, 2012 at 11:09 pm #
  50. The best way ins’t use direct registered Font Class in a SWC? Personally, I like that :)

    Saturday, September 1, 2012 at 1:12 pm #
  51. Hello Thibault, Can you give us some explanations about “goto”, I have found that it was for the Alchemy team, but what else?

    What you meant by “activation” for inline? Is it possible to have a sample of “activation” statement?

    Thanks ;-)
    Alain

    Saturday, September 1, 2012 at 8:22 pm #
  52. Thibault, We really need detailed explanations + “inline” because then I can not understand ..

    Test in Main Class:

    var result:Number = math01(12345);

    [Inline]
    final public function math01(data:Number):Number
    {
    var i:int;
    for (i = 1000000; i > 0; i– )
    {
    data = Math.sqrt(Math.sqrt(data * data) * Math.sqrt(data * data)) ;
    }
    return data;
    }

    I have this warning/error and inline don’t work

    Avertissement : Définition de variable en double : i.
    var i:int;
    ^

    The same Fucntion in Satic in the other class don’t give error, but is not faster than without inline

    public class InlinedTest
    {

    [inline]
    static public function math01(data:Number):Number
    {
    var i:int;
    for (i = 1000000; i > 0; i– )
    {
    data = Math.sqrt(Math.sqrt(data * data) * Math.sqrt(data * data)) ;
    }
    return data;
    }

    }

    For cons, this function placed in Main (not other class) work fine and speed increase by +/- 25-30% with [inline] directive.

    [Inline]
    final private function bar(a:Number):Number
    {
    return Math.sqrt(Math.sqrt(a * a) * Math.sqrt(a * a));
    }

    Why ?? please D.R. :)

    Saturday, September 1, 2012 at 8:45 pm #
  53. HB wrote::

    I’ve been thinking that would be nice to see tail recursion in AS Next as well. In the past I made a project with some big calculations that often surpassed the max number of recursions, even although it could take serious advantage of tail recursion. Rewrote it so recursion was not a problem, but recursion made it look a bit better.

    At the end I completely removed the AS code as anyway it could sometimes give timeouts, and moved all the logic to server side code.

    Monday, September 3, 2012 at 2:12 am #
  54. Jozef Chutka wrote::

    according to: Adobe ActionScript Compiler 2.0 Release Notes
    ASC 2.0 versions of the Flex ant tasks and are in ant/lib/flexTasks.jar
    Ant tasks are defined as:
    mxmlc=com.adobe.flash.compiler.ant.MXMLCTask
    compc=com.adobe.flash.compiler.ant.COMPCTask

    but if you open flexTasks.jar (available )
    mxmlc=flex.ant.MxmlcTask
    compc=flex.ant.CompcTask

    Other than that FB4.7 and its sdk seems to be real mess, why it is marked as 4.6.0 when the content is far distatnt from the one I can find in sdk download site?

    Monday, September 3, 2012 at 6:09 pm #
  55. Kevin Newman wrote::

    Does the inline keyword work with AS3 Proxy class’s callProperty? That would be pretty sweet. :-)

    Tuesday, September 4, 2012 at 6:32 pm #
  56. HB wrote::

    Could we get some examples of functions that contain 50 expressions? Which do you consider an expression?

    Also, I guess that if a function marked with [Inline] calls another inlined function, the number of expressions from the second sum to the number of the first, doesn’t it?

    Was thinking of using this for a couple of functions, but I think that I surpass this limit.

    Tuesday, September 4, 2012 at 7:29 pm #
  57. Peter Farland wrote::

    @Jozef, Note that overlaying the preview “AIR 3.4 SDK with ASC 2.0″ on top of a legacy Flex SDK is not supported.

    ASC 2.0 replaces the old compiler. It is for pure-AS3 development and cannot be mixed with the legacy Flex SDK compiler.

    Flash Builder 4.7 ships with two legacy Flex SDKs (3.6.0 and 4.6.0). These are only for Flex projects and cannot be overridden with the new ASC 2.0 compiler.

    Flash Builder 4.7 preview additionally ships with a captive version of the preview “AIR 3.4 SDK with ASC 2.0″ for ActionScript projects. This is in a separate plugin location. (In the preview, it is at \eclipse\plugins\com.adobe.flash.compiler_4.7.0.345990).

    Wednesday, September 5, 2012 at 12:42 am #
  58. David Roth wrote::

    Hi Alain,

    thank you – you found an inlining bug! If you declare a member variable, and initialize that variable with a function call which is inlined, when that inlined function contains a local variable declaration, you will see the problem you ran into. I will file a bug and fix this problem. In the meantime, as a work around, you can declare the member var, but don’t initialize is where it’s declared. Instead, initialize the member variable in the constructor of the class, such as:

    public class Main
    {
    private var result:Number; // = math01(12345); – don’t initialize here

    public function Main()
    {
    result = math01(12345);//initialize here instead
    }
    }

    With regard to the benchmarking question, I want the clarify that when a function is decorated with Inline metadata, that means that the function can be inlined when it is called, _not_ that function calls inside that function should be inlined. So in your example, I wouldn’t expect to see any performance improvements, as there is only one function call being removed.

    To see the effects of inlining, a better test would be something along the lines of:

    public function math01(data:Number):Number
    {
    var i:int;
    for (i = 1000000; i > 0; i–)
    {
    data = mathInner(data);
    }

    return data;
    }

    [Inline]
    final public function mathInner(data:Number):Number
    {
    return Math.sqrt(Math.sqrt(data * data) * Math.sqrt(data * data));
    }

    This way 1000000 function calls will be removed, as the body of mathInner() and moved into the for loop.

    Hopefully this clears things up.

    Dave

    Thursday, September 6, 2012 at 2:02 am #
  59. David Roth wrote::

    Hi Alain,

    Sorry, activations are a bytecode term, and not directly related to ActionScript. If an ActionScript function contains a with statement, or another function declaration, the compiler will generate an activation record. So basically as long as neither of these constructs are you, there shouldn’t be an activation.

    Thursday, September 6, 2012 at 2:07 am #
  60. Workaround for embedding font with embed metadata, is to make an Ant Task using the old compiler just for this part.

    Thursday, September 6, 2012 at 1:15 pm #
  61. subb wrote::

    Hi Thibault,

    Where should we submit bug reports for the compiler?

    Thanks

    Thursday, September 6, 2012 at 4:53 pm #
  62. Russell Lowke wrote::

    About fonts being removed from the embed tag –> With the new system how can I rename the fontFamily? We used to do this with embed but I can’t see a new way to do this. Am I stuck using the old compiler then? That would be a shame. What do you advise? Thanks!

    Thursday, September 6, 2012 at 8:40 pm #
  63. EMebane wrote::

    I updated MinimalComps to use the new font SWF embedding. It’s on GitHub here: https://github.com/ElliotMebane/minimalcomps
    and more details about using fontswf and embedding the font are here: http://www.roguish.com/blog/?p=550

    Saturday, September 8, 2012 at 7:52 pm #
  64. Thibault Imbert wrote::

    Hi guys,

    For info. We are going to reintroduce font support for embed in the next drop of ASC 2.0. I am sure you guys will appreciate.

    Thibault

    Sunday, September 9, 2012 at 6:04 am #
  65. Peter wrote::

    Just wondering why the limit of 50 expressions? This limits the usability quite a lot, I know inline is supposed for small functions that are used a lot but there is also a need for inline for a larger function that is inlined 1 or 2 times in the whole framework. Especially useful in 2D/3D engines.

    Tuesday, September 11, 2012 at 12:40 pm #
  66. Pavel wrote::

    Thibault Imbert,

    looks like new compiler (well I was reported about the issue with FB 4.7) doesn’t work properly with lazy statement ||=

    And also something else I cannot find out yet.

    Tuesday, September 11, 2012 at 4:58 pm #
  67. khaled wrote::

    Nice Features but guys why did you remove the design view from Adobe Dlash builder 4.7 you really broke my heart !

    Tuesday, September 11, 2012 at 6:25 pm #
  68. khaled wrote::

    Flash Builder 4.7 *

    Tuesday, September 11, 2012 at 6:25 pm #
  69. Szymon Brych wrote::

    @khaled
    From Adobe Labs:
    “Although this beta release is not yet feature complete, we are excited for you to begin to experience the next generation of Flash Builder.”

    So, as far as I am concerned, lack of the visual preview doesn’t necessarily mean that it won’t be present in final version.

    Saturday, September 15, 2012 at 12:02 pm #
  70. Hi Dave! Very thanks for your explanations :-)

    I understood ! :-)

    The warning appaer just if i declare un new var in inlined Function Only if this inlined function is used several times (like in for loop) :-)

    It’s normal :)

    Directive [inline] Works moderately well.

    The big advantage of inlining is calling in the loop.

    But the time is relative well.

    If I do this

    for (i = 1000000; i > 0; i–)
    {
    data = Math.sqrt(Math.sqrt(data * data) * Math.sqrt(data * data));
    }

    execution time is: 175 ms

    But if i do this:

    for (i = 1000000; i > 0; i–)
    {
    data = inlinedFunction(data);
    }

    [Inline]
    final private function inlinedFunction(data:Number):Number
    {
    return Math.sqrt(Math.sqrt(data * data) * Math.sqrt(data * data));
    }

    Execution time is : 205 ms

    Dave thank you again for taking the time to answer me ;-)

    Saturday, September 15, 2012 at 5:54 pm #
  71. Dave, i forgot to say !!

    if a suppress the {} embrace and if i place all loop in the same line.. it’s pulverise the inline directive.. :)

    for (i = 1000000; i > 0; i–) data = Math.sqrt(Math.sqrt(data * data) * Math.sqrt(data * data));

    Execution time is: 130 ms

    this is also true for most loops !!

    Evidence that the ASC compiler can still improved .. :)

    Saturday, September 15, 2012 at 6:08 pm #
  72. Evidence that the ASC compiler can be improved .. :) (sorry)

    Saturday, September 15, 2012 at 6:14 pm #
  73. Hi guys, for french speaking visitors, I made a small article which explains [inline]

    http://www.pureas3.org/fr/la-nouvelle-directive-inline-du-compilateur-asc2-0

    :-)

    Sunday, September 16, 2012 at 12:49 pm #
  74. HB wrote::

    ASC 2.0 Preview 2 was released yesterday:

    http://labsdownload.adobe.com/pub/labs/flashplatformruntimes/air3-4/air3-4_p2_sdk_asc2_releasenotes.pdf

    Tuesday, September 18, 2012 at 1:14 pm #
  75. John wrote::

    Hi.
    I’m very interesting about how you guys count a “50 expressions” in function body.
    Just look at that very simple example and please explain me how I should get a 50+ expressions here (I’ve counted 40 with get and set vars):

    internal static function __lineLineV( aposX:Number, aposY:Number, avecX:Number, avecY:Number,
    bposX:Number, bposY:Number, bvecX:Number, bvecY:Number,
    dst:Vec2 ) : void
    {
    var t00:Number = aposX * aposY;
    var t01:Number = aposX – aposY;
    var t02:Number = aposX + aposY;
    var t03:Number = aposX / aposY;
    var t04:Number = bposX % aposY;
    var t05:Number = aposX | bvecY;
    var t06:Number = aposX & aposY;
    var t07:Number = aposX ^ aposY;
    var t08:Number = aposX ^ aposY;

    dst.x = t00;
    dst.y = t01;
    }

    In any case 50 expr. is not enough. Please increase it at least to 100.

    Thanks for watching.

    Saturday, September 22, 2012 at 7:49 am #
  76. HB wrote::

    I also think the limit of expressions should be raised. If inlining would be set automatically, I’d understand to have a low limit, but since the feature must be enabled explicitly, I’d say the constraint should be relaxed.

    Sometimes we are forced to make separate functions for readability while we’d prefer to inline them.

    Sunday, September 23, 2012 at 11:57 pm #
  77. lite3 wrote::

    package
    {
    public class Test
    {
    public function Test()
    {
    var a:int = 10;
    // In ASC2.0 not Erorr
    // In legacy compiler is Error
    a();
    }
    private function a():void { }
    }
    }

    Friday, September 28, 2012 at 12:51 pm #
  78. Tufik wrote::

    Why the last 2 Chrome updates, no was updated Adobe Flash Player? Flash Player will not support more?

    Friday, September 28, 2012 at 5:15 pm #
  79. HB wrote::

    @Tufik:
    I guess it’s because the new PPAPI interface used. Maybe it’s not yet well integrated into the build process, or there other issues being worked on.
    The classic interface NPAPI based Flash is still automatically updated as well, although the new one must be disabled first, something most users ignore or won’t care doing.

    Friday, September 28, 2012 at 10:25 pm #
  80. hey guys, first all I want to say great job and thanks.
    but I have got a problem with compiling my old project with new ASC2.0 . There is no errors or something when I exports release build but it never completes, I waited around hour but compilation didn’t end. I also looked into a task manager processes and saw that at first java takes around 25% of CPU but after few mins java stopped making any job and it is like that until I press cancel in Flash Builder from hour. I’m using Flash Builder 4.7 64-bit.
    is there any ideas why it could be happen ?

    Thanks,
    Georgi.

    Saturday, September 29, 2012 at 3:24 pm #
  81. Does Adobe has any decisions for use asc2.0 with Maven build system? And is available any Maven Repository with new SDK?

    Monday, October 8, 2012 at 1:37 pm #
  82. Val wrote::

    Hi Sebastien… I have few questions about workers.
    How can i send to an worker complex objects of my own data types…serialization doesn’t work and it is very sad :(
    When Adobe is planing to release workers that are able to exchange any data types, starting from primitive and to very complex objects?
    I also noticed that workers are not able to load external files…Why we can’t use workers for background files loading?

    Tuesday, October 9, 2012 at 9:23 am #
  83. https://github.com/robotlegs/robotlegs-framework/issues/97

    New compiler break down Robotlegs – by breaking down usual behaviour of “||” operator. And now robotlegs doesn’t work in FB4.7.

    Saturday, October 20, 2012 at 7:26 pm #
  84. Shaun wrote::

    Is there an open issue for the Lazy Assignment ( ||= ) thing? I’ve looked, but can’t find anything. As there are already a number of backwards breaking changes I’d like to suggest fixing the behaviour of this operator as the old compiler behaviour was not ideal and this would be a good opportunity to fix it.

    Monday, November 12, 2012 at 12:41 am #
  85. Michael Montoya wrote::

    +1 for fixing ||= lazy assignment, it is breaking all our codebase and refactoring is not an option

    Wednesday, November 28, 2012 at 8:22 am #
  86. can I for example get access to microphone on the worker and record sound from it using your MicRecorder Class

    Monday, December 10, 2012 at 6:26 pm #
  87. Rodrigo wrote::

    Hi Thibault, I don’t know if this is a known bug:
    I just tested AIR 3.5 and 3.6 with ASC2.0 in both cases when i instantiate a bitmapData from a swc library directly as the function parameter, nothing is rendered in the bitmap (the bitmap is already added on the stage).
    But if I create a variable for the bitmapData and then pass it to the function, works fine…

    Sunday, December 30, 2012 at 2:52 am #
  88. rohit.khandare wrote::

    How to use Font Embedding in Flash builder 4.7

    Friday, January 11, 2013 at 8:44 pm #
  89. hexagon wrote::

    What happened to the ASDoc Ant task in the new AIR 3.6 SDK? Removed?

    Wednesday, March 13, 2013 at 7:54 am #
  90. Jahiro wrote::

    When will SWC support for inlining be added? I keep getting this warning: The function lookupComponentByType could not be inlined, as no source could be found. Inlining func
    tions defined in a SWC is not supported.

    Wednesday, June 26, 2013 at 4:38 am #
  91. dimas_art wrote::

    So, what’s about maven builds based on new Action Script Compiler (ASC 2.0)?

    Sunday, July 7, 2013 at 6:15 pm #

Trackbacks/Pingbacks (8)

  1. [...] Нас же больше всего интересует ActionScript Compiler (ASC 2.0) почитать на английском о нем можно перейдя по этой ссылке. [...]

     
  2. It has been fun, while it lasted… - nulldesign // lars gerckens on Wednesday, September 19, 2012 at 10:31 pm

    [...] projects, it’s pretty hard to keep yourself up to date with all the new stuff that has been added to the platform and really bring the engine to a next level. And it’s a bit pointless as well. So I had to [...]

     
  3. Notes de lectures AS3 – Automne 2012 | antoine fricker on Friday, September 21, 2012 at 2:03 am

    [...] : Inlining Functions with ASC 2.0 ActionScript Compiler (ASC 2.0) [...]

     
  4. @renaun posts: Using the New Inline Metadata in ASC2 on Saturday, September 29, 2012 at 12:25 am

    [...] in the labs.adobe.com release of Flash Builder 4.7. Its the new ActionScript compiler, aka ASC2. Thibault does a great introduction blog post on the new [...]

     
  5. [...] Introducing ASC 2.0 – ByteArray.org [...]

     
  6. Randy Troppmann » A new Flash Builder on Thursday, December 13, 2012 at 9:08 pm

    [...] The shift away from Flex means a shift towards “actionscript only” project workflow. Also known as “pure AS3″, these are software projects that are made without Flex and without Flash Pro. It is a coder-centric approach where visual and audio assets are added at develop-time (using embed code) or loaded at run-time. Actionscript projects now use the new ASC 2.0 compiler. [...]

     
  7. [...] or AI it still isn’t a viable platform, at least on mobile. Recent developments like the new Falcon compiler and AS workers are nice but Adobe is going to have to make more radical changes to the language [...]

     
  8. [...] is a good post about ASC 2.0 : Introducing ASC 2.0 This entry was posted in AIR, Flex and tagged Adobe, AIR, ASC2.0, Flash Player. Bookmark the [...]