Create binary from GCJ generated assembly

Andrew Haley aph@redhat.com
Wed Oct 28 18:32:00 GMT 2009


isuru herath wrote:

 > Thanks for the reply. My code is attached.

I'll have a look.

 > My intention of using this xchg instruction is that the
 > simulator[Simics] I am using recognizes them as an special event and
 > I can start counting the memory reference from that point onwards. I
 > am trying this on Java is because we are going to use benchmark
 > programs written Java. Thats why I am trying to use CNI to insert
 > assembly to the binary.
 >
 > I dont understand what you mean by "intrinsic counter". I would
 > greatly appreciate if you could explain it bit more if you have
 > time.

gcj has intrinsics for some functions.  If you want to add an
intrinsic to do your xchg instruction, look at how
sun.misc.Unsafe.compareAndSwapInt() works.  It inserts special
instructions whenever it sees sun.misc.Unsafe.compareAndSwapInt().

 > Aslo I didn get clearly what you mean by
 >
 > Personally speaking, I'd just write the routines that need to access
 > the counter in C++.
 >
 > I am trying to find a way to insert these two assembly instructions
 > to the binary created by gcj so that it will give the same number of
 > memory references as C programs does.

OK.

Andrew.


P.S.  Your mailer is a disaster.  Look at what it did to the layout of
my posting:

 >> I'd rather see your code than guess what you did.
 >>
 >> But yes, you're right.  You'd be calling code to
 >> invoke the inline asm,
 >> rather than executing it directly.  If you can't
 >> tolerate that, your
 >> only recourse is to add an intrinsic counter
 >> increment.  gcj already has
 >> intrinsics for things like
 >> sun.misc.Unsafe.compareAndSwapInt(), so this one
 >> should be easy enough.  Personally speaking, I'd just
 >> write the routines
 >> that need to access the counter in C++.
 >>
 >> Andrew.
 >>
 >>



More information about the Java mailing list