Re: Create binary from GCJ generated assembly
isuru herath <[email protected]>
| Newsgroups | gmane.comp.gcc.java.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Bryce, Thanks for the quick reply. I followed your steps. But got the following error. shared_counter.s: Assembler messages: shared_counter.s:1023: Error: file number 1 already allocated steps I followed. 1. shared counter program with no calls to other classes. 2. generate assembly.(gcj -S shared_counter.java) 3. edit .s file and add instructions. 4. create binary. (gcj shared_counter.s --main=shared_counter) is there something wrong here or do i need to do another setting. I googled for this error and found lot of bug reports which I couldnot understand. any advice/help is greatly appreciated. regards, Isuru --- On Wed, 10/28/09, Bryce McKinlay <[email protected]> wrote: > From: Bryce McKinlay <[email protected]> > Subject: Re: Create binary from GCJ generated assembly > To: "isuru herath" <[email protected]> > Cc: "Andrew Haley" <[email protected]>, [email protected] > Date: Wednesday, October 28, 2009, 8:22 AM > On Wed, Oct 28, 2009 at 11:05 AM, > isuru herath <[email protected]> > 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. > > > > 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 > > This is because you are making calls into native code from > Java. GCJ > cannot inline native code into your Java code. Calls are > not free - > you are measuring the overhead of returning back from > native code into > Java code and vice-versa. > > If you need to add asm instructions to GCJ compiled code, > you can > generate assembler using something like: > > gcj -S MyClass.java > > Then, edit the resulting assembler .s file to add the > instructions. > Finally, link it with something like: > > gcj MyClass.s --main=MyClass > > Bryce >