Thursday, March 29, 2012

Released: AS3Commons-Bytecode v1.1!

Just a quick heads-up here: We have just released version 1.1 of AS3Commons-Bytecode:

Download Page

Documentation has been updated a little bit as well:

Proxy docs

Christophe has been getting his hands dirty in this release as well, he's managed to squash some last bugs that paved the way for the v1.1 release. So thanks a lot for his blood, sweat, tears and sanity ;)

We have added some extra speed optimizations in the ByteCodeType parser. This is, of course, an ongoing process, every time we find some new tricks we implement them. The speed improvements are only slight this time, but every millisecond counts :)
I did a simple test where I invoke a ByteCodeType.fromLoader() in an AIR application with all framework libraries included (which results in about a 2MB SWF mainly consisting of class information) which took about 2225 ms to complete in debug mode.

Furthermore, we have improved the proxying of getters, it now works properly actually ;)
In version 1.0 it was impossible to receive a reference to the getter function itself and pass it on to the interceptors. This was due to a technical limitation at the opcode level, where it is also impossible to get a reference to the actual getter function. So, what the proxy factory now does is create a custom namespaced method in the proxy class that basically does this:

Imagine your proxied class has a getter called 'name':

public function get name():String {
  return _name;
}

AS3Commons-Bytecode v1.1 will then generate an extra method on the proxy class that looks like this:

as3commons_bytecode function getter_name():String {
  return super.name;
}

After that, in the overridden getter method the function getName() will be passed into into the interceptors. That way the interceptors themselves can choose to invoke the getter or not, or at least determine at which time the getter will be invoked.

An important note has been added to the proxy documentation as well, concerning the ApplicationDomain reference that needs to be passed in to the defineProxy() method.

ByteCodeType now caches its type info per application domain (when before it only kept one cache). This allows the library to cache different type info for different app domains that potentially could share the same names.

So, it is very important to pass the correct ApplicationDomain reference into defineProxy(), otherwise the ProxyFactory won't be able to find the appropariate ByteCodeType info.
This ApplicationDomain needs to be the same reference as the loaderInfo.applicationDomain property that was passed into ByteCodeType.fromLoader().

It sounds more complicated than it is actually. What you do is simply keep a reference to loaderInfo.applicationDomain, and use that in each invocation of defineProxy().
Existing code that makes use of AS3Commons-bytecode 1.0 probably doesn't do this yet, so if you experience errors after upgrading to version 1.1, this is probably what's going on. The fix is fairly simple, as explained.

At the same time work is very slowly progressing on as3commons-aop as well, we have no idea yet when it'll see an official release, but the website will be up soon, we promise ;)

AS3Commons is busy with some other new project releases as well, projects donated by the likes of Claus Wahler and Brian Riley, so these are exciting times for the project!

That was all, happy coding to everyone!

cheers,

Roland

1 comment:

  1. Hello, very good library, love it.
    Done a correction in as3-commons-lang, class ClassUtils, method getClassParameterFromFullyQualifiedName:
    if (StringUtils.startsWith(fullName, AS3VEC_SUFFIX)) {
    var startIdx:int = fullName.indexOf(LESS_THAN) + 1;
    // var len:int = (fullName.length - startIdx) - 1;
    var len:int = (fullName.length - startIdx); // correction for vector
    var className:String = fullName.substr(startIdx, len);
    return forName(className, applicationDomain);
    I'm not sure how about log this?

    ReplyDelete

About Me

My photo

Co-Owner at Stack & Heap (http://www.stackandheap.com)
Lead developer for the Spring Actionscript (http://www.springactionscript.org) and AS3Commons (http://www.as3commons.org) projects.
I like noise.