Create binary from GCJ generated assembly
isuru herath
isuru81@yahoo.com
Wed Oct 28 18:12:00 GMT 2009
Hi Andrew,
Thanks for the reply. My code is attached.
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.
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.
thanks a lot for your help. further help is greatly appreciated.
regards,
isuru
--- On Wed, 10/28/09, Andrew Haley <aph@redhat.com> wrote:
> From: Andrew Haley <aph@redhat.com>
> Subject: Re: Create binary from GCJ generated assembly
> To: "isuru herath" <isuru81@yahoo.com>
> Cc: java@gcc.gnu.org
> Date: Wednesday, October 28, 2009, 8:56 AM
> isuru herath wrote:
>> > Thanks a lot for the quick reply. I did accordingly.
> But results were not the same. My program is a multi
> threaded shared counter.
> > so in my Java code I have
> > counter++
> >
> > I need to surround this with two xchg instructions.
> like
> >
> > xchg
> > counter++
> > xchg
> >
> > so that I can count number of read and write
> operations between two xchg instructions.
>> OK.
>> > with gcc I got both as 1 which is correct.
> > with gcj and JNI I got 47 read operations and 29 write
> operations
> > with gcj and CNI I got 6 read operations and 6 write
> operations
> >
> > the way I am doing with CNI is follows.
> > 1. a java class with native method.(custom.java)
> > 2. c++ implementation of it to insert
> assembly.(custom.cc)
> > 3. compile custom.java (gcj -C custom.java)
> > 4. create the header file (gcjh custom -o custom.h)
> > 5. write multi threaded shared counter program. it has
> calls to native method to insert
> assembly(shared_counter.java)
> > 6. compile all java classes (gcj -C *.java)
> > 7. compile the custom.cc (g++ -c custom.cc -o
> custom.o)
> > 8. create the executable. (gcj do_options.class
> custom.class shared_counter.class custom.o -lstdc++
> --main=shared_counter -o shared_conter)
> >
> > do_options is an interface with final variables. is
> there something that is wrong. or should I need do some
> additional thing. any help/ advice is greatly appreciated.
>> 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.
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: custom.cc
Type: text/x-c++src
Size: 670 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20091028/e6f0cb38/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: custom.h
Type: text/x-chdr
Size: 434 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20091028/e6f0cb38/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: custom.java
Type: text/x-java
Size: 124 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20091028/e6f0cb38/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: do_options.java
Type: text/x-java
Size: 313 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20091028/e6f0cb38/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shared_counter.java
Type: text/x-java
Size: 802 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20091028/e6f0cb38/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: java_magic_c.h
Type: text/x-chdr
Size: 495 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20091028/e6f0cb38/attachment-0005.bin>
More information about the Java
mailing list