Hi all,
I’ve created library that implements support for stack allocation of “value” objects, such as vectors and matrices. It’s evolved version of stack allocation that I’ve used in JBullet, where it uses manual managing of stack state. This library generates this repetitive and cumbersome code with automatical bytecode instrumentation using ANT task and provides nice API.
Requires Java 5 and ASM 3.x library. Licensed under ZLIB license.
More details are available in JavaDoc:
http://jezek2.advel.cz/tmp/jstackalloc/javadoc/
And the latest version of library can be downloaded here:
http://jezek2.advel.cz/tmp/jstackalloc/jstackalloc-20080716.zip
(The original version posted in this thread can be found here)
Example ANT task (for NetBeans):
<target name="instrument-classes">
<taskdef name="instrument-stack"
classname="cz.advel.stack.instrument.InstrumentationTask"
classpath="${run.classpath}">
</taskdef>
<instrument-stack dest="${build.classes.dir}" packageName="your.package.name">
<fileset dir="${build.classes.dir}" includes="**/*.class"/>
</instrument-stack>
</target>
<target name="-post-compile" depends="instrument-classes">
</target>
Possible future enhancements:
- allow selective storing of per-thread stack instance in protected final field and initialize it automatically in constructor (this is the system used in JBullet)
- allow passing parameters to set method when obtaining new instance from Stack.alloc(), this is problematic because it would need to use varargs method which would lose type safety (the heap allocations created by using varargs and autoboxing is not problem, because it would be entirelly replaced with direct call to set method)
- add optional single-thread mode, where stack instance is obtained from public static field instead of using ThreadLocal
EDIT 2008/06/23: updated download to latest version and edited possible enchancements