This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
question about gcj -fjni code
- From: Tom Tromey <tromey at redhat dot com>
- To: GCC Hackers <gcc at gcc dot gnu dot org>
- Date: 24 Jan 2002 18:31:15 -0700
- Subject: question about gcj -fjni code
- Reply-to: tromey at redhat dot com
I'm looking into a strange libgcj runtime failure, and I've found I
don't understand some of the code gcj generates. I'm hoping someone
can help me out.
This is on x86 Red Hat Linux 6.2.
I compile a file like so:
gcj -fPIC -fjni -S -g0 gnu/java/awt/peer/gtk/GtkComponentPeer.java
In gcj, with -fjni, native methods are compiled as stubs that make
calls into the runtime. These stubs are generated by
expr.c:build_jni_stub. I suspect my problem lies there.
Here is a small piece of the output that looks ok:
cmpl $0, meth.31@GOTOFF(%ebx)
je .L135
movl meth.31@GOTOFF(%ebx), %eax
movl %eax, -12(%ebp)
[ ... ]
.align 4
.type meth.31,@object
.size meth.31,4
meth.31:
.long 0
In another method, I get very similar code:
cmpl $0, meth.5@GOTOFF(%ebx)
je .L8
movl meth.5@GOTOFF(%ebx), %eax
movl %eax, -16(%ebp)
[ ... ]
However, `meth.5' doesn't appear to be defined in the .s file.
At runtime this manifests as the variable having some random value,
which causes a crash. The value ought to be initialized to 0.
Why doesn't this cause an error from the assembler?
The `meth' variables are constructed like so:
meth_var = build_decl (VAR_DECL, get_identifier ("meth"), ptr_type_node);
TREE_STATIC (meth_var) = 1;
TREE_PUBLIC (meth_var) = 0;
DECL_EXTERNAL (meth_var) = 0;
DECL_CONTEXT (meth_var) = method;
make_decl_rtl (meth_var, NULL);
I tried setting TREE_USED and DECL_INITIAL on the VAR_DECL, but that
didn't have an effect.
I'm hoping I'm missing something obvious.
Tom