From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28789 invoked by alias); 28 Oct 2009 15:56:39 -0000 Received: (qmail 28779 invoked by uid 22791); 28 Oct 2009 15:56:38 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Oct 2009 15:56:33 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9SFuW1c005546; Wed, 28 Oct 2009 11:56:32 -0400 Received: from zebedee.pink (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9SFuVQV002409; Wed, 28 Oct 2009 11:56:31 -0400 Message-ID: <4AE869AE.1070302@redhat.com> Date: Wed, 28 Oct 2009 15:56:00 -0000 From: Andrew Haley User-Agent: Thunderbird 2.0.0.23 (X11/20090825) MIME-Version: 1.0 To: isuru herath CC: java@gcc.gnu.org Subject: Re: Create binary from GCJ generated assembly References: <276268.36412.qm@web56002.mail.re3.yahoo.com> In-Reply-To: <276268.36412.qm@web56002.mail.re3.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-10/txt/msg00072.txt.bz2 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.