public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Haley <aph@redhat.com>
To: isuru herath <isuru81@yahoo.com>
Cc: java@gcc.gnu.org
Subject: Re: Create binary from GCJ generated assembly
Date: Tue, 27 Oct 2009 09:42:00 -0000	[thread overview]
Message-ID: <4AE6C089.3070302@redhat.com> (raw)
In-Reply-To: <427148.24689.qm@web56004.mail.re3.yahoo.com>

isuru herath wrote:

 > I want to add two assembly instructions to my Java program. Earlier
 > I was doing it in C with "asm volatile". To get the same behavior in
 > Java I used JNI. I used GCJ with -fjni flat to crate the binary. It
 > executed and gave the correct output. But when I checked the memory
 > references between two assembly instructions it is very high
 > compared to the C program.  Thereafter I got the assembly version of
 > both C and Java codes with -S option. In C version, assembly
 > instructions are directly inserted in the proper places. But in Java
 > version library calls are placed in the places where assembly should
 > be inserted. I doubt this may be the case for larger memory
 > references. So my question is is there a way to edit the gcj
 > generated assembly and insert assembly instructions and compile it
 > to a binary. I tried two different ways(trial and error). Nothing
 > worked.
 >
 > [1]
 > gcj --main=new_shared_counter -o new_shared_counter new_shared_counter.s
 >
 > [2]
 > gcc shared_counter.s
 >

gcj can't handle inline asm.

There are a few ways to do this:

* Write the code with the asm in C++ using CNI.  This is the easiest
   way, and gives you results identical to using asm volatile in C.

* Add a compiler intrinsic.  This requires specialist knowledge.

* Post-process the assembler output from gcj to replace a call with
   some assembly instructions.  Nasty, but it'd work.  Again, this
   requires specialist knowledge.

 > Any help on how to compile a gcj generated assembly to binary would
 > be greatly appreciated.

Use the assembler, "as".

Andrew.

  reply	other threads:[~2009-10-27  9:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27  8:22 isuru herath
2009-10-27  9:42 ` Andrew Haley [this message]
2009-10-28 15:05   ` isuru herath
2009-10-28 15:22     ` Bryce McKinlay
2009-10-28 15:43       ` isuru herath
2009-10-28 15:56     ` Andrew Haley
2009-10-28 18:12 isuru herath
2009-10-28 18:32 ` Andrew Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AE6C089.3070302@redhat.com \
    --to=aph@redhat.com \
    --cc=isuru81@yahoo.com \
    --cc=java@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).