Sweet! Thanks for the info.

Kevin N.


Nicolas Cannasse wrote:
Here are some things I've been wondering about Actionscript 3.0s compiler and runtime engines:

I'm assuming AS 3.0 compiles to a bytecode. What kind of bytecode does it compile to? Is it more like Java/.NET CLR, or more like Mozilla's Spidermonkey compiler?

I don't know about SpiderMonkey, but AS3 bytecode is similar to Java one. It's actually more complicated since there is several way to access the properties (using prototype, traits or "slots").

Does the compiled code get recompiled during runtime to machine code (like a JIT compiler) or does it get interpreted?

Some Adobe presentation on the subjet was saying that all the code get JIT'ed, except the $iinit and $cinit functions which are the one defining the classes and initializing their static variables.

Also, how does the compiler deal with typing? Statically typed, compiled languages usually have the type set in stone at compile time whereas dynamically typed, interpreted languages like javascript and php can do type coercion at runtime on the fly. Which one does the Actionscript 3.0 runtime do? Does it do both depending on whether the type is static or dynamic?

The complete class structure with type is stored into the Flash9 SWF. Then local (per-function) type-inference is performed to check the types coherency. There is some bytecode options that perform type-casting. For instance everytime a value is stored into an untyped variable, the opcode 0x82 is "forgetting" about the original value type.

This makes things actually pretty difficult for other languages with different type system to be compiled to Flash9 bytecode, but I could succeed in doing it for haXe (http://haxe.org).

I started documenting the Flash9 file format on http://osflash.org/flash9, you can start reading there, but only the haXe swf library sources are containing the complete specification :

http://cvs.motion-twin.com/horde/chora/browse.php?rt=ocaml&f=swflib

Nicolas


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to