Sunday, February 21, 2010

Open Source Compiler for Actionscript 2. The MTASC Actionscript Compliler

MTASC is an Open Source Compiler for Actionscript 2. The MTASC Actionscript Compliler not only could compile large number fo .as class files in a very short time but also generate directly the SWF bytecode without relying on Macromedia Flash or other tools. Then could be used alone or with other tools like swfmill to produce SWF files. It improve the speed on the Macromedia Compiler and corrects several safety problems when using MMC.

2 comments:

  1. Hello fellow MTASC users and developers,

    I work in a team at Google on one of our Flash-based products, and we use MTASC for building it. Occasionally though we run up against the infamous 32 KiB limit on class bytecode. Recently I took it upon myself to fix it. The patch is attached.

    As many of you probably know, the 32 KiB limit stems from the fact that jump offsets in the AS2 bytecode format are only 16-bit, which means that a jump instruction and its destination cannot be separated by more than about 32 KiB of bytecode. Since every class definition requires a jump that crosses the entire class's code, no class can currently be larger than 32 KiB.

    Our solution is to repeatedly split any overlength jumps by inserting "jump islands" between them. A "jump island" consists of two unconditional jump instructions; one that jumps the rest of the way and one right before it that jumps over that one. All locations are considered viable candidates for a jump island (which testing thus far shows to be safe), but we avoid placing jump islands inside nested functions whenever possible (because that would be slightly less efficient); if we were forced to, we note that in the output.

    The changes are highly self-contained and very well-commented. There is also a new "-32k-limit" option to force the old behaviour. The patch was created against yesterday's CVS snapshot. You apply it the usual way (patch -p1 < FILE).

    Example compiler output:

    Warning: Class has 32 KiB or more of bytecode, which is not supported by older MTASC versions.
    Note: Bytecode sequence contains one or more overlength jumps; attempting jump island insertion.
    Note: Jump island insertion successful with 1 island(s) created.

    If you find the patch acceptable, we would be happy if you would accept it into the official MTASC codebase.

    Regards,

    Tristan Schmelcher

    [mtasc-no32klimit.patch]
    ...

    MTASC : no more coffee break while compiling

    Main thread:
    http://old.nabble.com/Patch:-eliminate-32-KiB-bytecode-limit-from-MTASC-td14696204.html

    ReplyDelete
  2. I would like to share some interesting and worst experience about ActionScript 2.0.
    While creating a local member variable myArr which is initialized during class instantiation:

    class Test
    {
    public var myArr:Array = new Array();
    public function Test()
    {
    --- Do some thing ---
    }
    }

    Unfortunately, this is seems to be a member variable but actually its reacting like a static class variable here without using the static keyword.


    So The only correct way is to do it in the function:

    class Test
    {
    public var MyArr:Array;
    public function Test()
    {
    MyArr = new Array();
    }
    }

    ReplyDelete