I'm using ASM exclusively, but usually wrapped behind one of my own shims.
Either this super-trivial shim that just exposes a method-per-opcode:
Or my unreleased Ruby DSL for ASM, "JVMScript":
http://kenai.com/projects/jvmscript
The latter is probably more interesting to you, but obviously has a
dependency on JRuby. Perhaps that's not a problem for your toolchain.
Here's a short sample:
builder = Compiler::FileBuilder.build("somefile.source") do
package "org.awesome", "stuff" do
public_class "MyClass", object do
public_field "list", ArrayList
public_constructor string, ArrayList do
aload 0
invokespecial object, "<init>", [void]
aload 0
aload 1
aload 2
invokevirtual this, "bar", [ArrayList, string, ArrayList]
aload 0
swap
putfield this, "list", ArrayList
returnvoid
end
public_static_method "foo", this, string do
new this
dup
aload 0
new ArrayList
dup
invokespecial ArrayList, "<init>", [void]
invokespecial this, "<init>", [void, string, ArrayList]
areturn
end
public_method "bar", ArrayList, string, ArrayList do
aload 1
invokevirtual(string, "toLowerCase", string)
aload 2
swap
invokevirtual(ArrayList, "add", [boolean, object])
aload 2
areturn
end
public_method("getList", ArrayList) do
aload 0
getfield this, "list", ArrayList
areturn
end
public_static_method("main", void, string[]) do
aload 0
ldc_int 0
aaload
invokestatic this, "foo", [this, string]
invokevirtual this, "getList", ArrayList
aprintln
returnvoid
end
end
end
end
- Charlie
I gave up on Jasmin a long time ago... don't remember why anymore.
ooLong... hear of this the first time. I use ASM very much and I think
many do.
[...]
> If no disassembler goes with the package, I would prefer something that
> is close enough to javap that I can write a small thingy to rearrange
> its output into something that I can assemble - something that ASM can
> but in a very verbose way.
ASM has a bytecode disassembler, you can let it even print the
disassembler in a form that you can almost directly use as code to
create that bytecode. ASM has also a verifier you can use to check your
bytecode and let ASM point to the position where the bytecode is no
longer ok... I wrote a small tool with a gui that is a bit more
comfortable, but it is based on ASM... I really should finish it one day
and release it :( Anyway, ASM can not give you Macros, but since it is a
library you use your Java program that controls ASM becomes the part the
part with the makro if you want to.
bye blackdrag
--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/
It is theoretical thus far. .. but when applied to my code it ideed makes my code over 4 times faster.
Someone give me a sanity check
I have this class layout
LispObject
-> LispProc
-> Dynamically defined classes
-> LispInt
-> LispString
-> LispChar
-> LispFloat
-> LispEtc...
I run code.. and the JIT is caching very well and being smart.
I add a new "-> Dynamically defined classes"Some of the JIT caches get blown away
My code suddenly goes very slow .. but warms up.
I add a new "-> Dynamically defined classes"
Some of the JIT caches get blown away
My code suddenly goes very slow .. but warms up.
I did this for over 700 seconds
So here was what I did:
LispObject
-> LispProc
-> Dynamically defined classes
-> LispJITShim
-> LispInt
-> LispString
-> LispChar
-> LispFloat
-> LispEtc...
I copied the code verbatum from LispObject to LispJITShim and made the existing classes subclass the shim.
Now when a dynamic defined class happens.. it blows out LispObject cached JIT
But the pre-existing classes keep all their JIT intact.. because LispJITShim never calls its 'super'
the work done in 700seconds is now all done in 160seconds!!!!!!