writing two different bytecode parts at the same time
Jochen Theodorou <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
I am currently experimenting in Groovy with a special way of compiling
expressions. One way is the classic way, the other is more or less java
style static compilation. Since I want to switch between them at runtime
and express it completely in bytecode I have currently a small problem.
So for example I would compile
void foo(int x) {
x++
}
into something like this
if !fastpath GOTO slowpath
ILAOD 1
IINC
ISTORE
slowpath:
x' = box(x)
x' = x'.next()
x = unbox(x)
I hope you guys forgive me for using some shortcuts here, but it should
give away the idea
Currently I can switch the compiler to do either the one thing or the
other, but I would like to do both at the same time. Ideally I would
like to do that with two method visitors on the same method. Then I
could do (not real API, I know):
mv1.visitInsn(ILOAD, 1)
mv2.visitInsn(ILOAD, 1)
mv2.visitMethodcall(SBA.box(I)Object)
to handle loading x in the fast path (mv1) and loading x in the slow
path (mv2). That means I can handle both ways while handling the x in
x++ and have not to duplicate the my AST, or revisit it.
So basically I would like to be able to define a label and have one
method visitor write after it, while another one can write before it. Or
a way to somehow jump
Is there anything slightly like that in th asm lib I can use?
bye Jochen
--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
message-footer.txt
(text/plain, 238 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws