This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: java memory allocation with gcj


isuru herath wrote:

> Thanks for the reply. I tried in x $eax gdb after the new being executed an
> it was giving me the following.
> 0x804a0e0 <_ZN13test_java_new6class$E>: 0xb7a4afe8
>
> When converted to decimal it was 134521056 which seems close to that of C.
> Could you please tell me what the other value represents here.
>
> Seems like the way I was doing is wrong. But I couldn't find another way.
>
> This is my Java class.
>
> class test_java_new
> {
>         public static void main(String[]args)
>         {
>                 int isuru[]=new int[2];
>                 isuru[0] = 12345;
>         }
> }
>
> Then I compiled this with gcj -S. Then I open the test_java_new.s file.
> There I add following lines after the
> call    _Jv_NewPrimArray line.
>
> The lines I am adding are
>         pushl   %ecx            #;for start location
>         movl    %eax, %ecx      #;copy value in eax to ecx
>         push    %eax            #;the memory tag
>         movl    $5, %eax        #;set eax to HEAP tag
>         xchg    %bx, %bx        #;magic instruction
>         popl    %eax
>         popl    %ecx

This looks right.

> Why I am doing this is, when the xchg %bx, %bx is executed my
> simulator (Simics) triggers an event and my hardware module can get
> the control of the system. So that I can pass information from the
> user program to my hardware module. But when I check the eax
> register at my hardware module after xchg %bx, %bx , I got that
> small number which is 166816. But when I add the same assembly code
> soon after the call malloc in a gcc generated assembly of a C
> program, my hardware module gets the correct address. Therefore I
> was thinking it should be the same here.

It certainly should be.  We know that when you print out $eax in gdb,
you get the correct value.

> Some other thing I noticed is that when I invoke x $eax after the
> isuru[0] = 12345; I got 0X28bc0 which is quite similar to 166848. I
> don't know this helps you to help me to clarify my problem.

Let's see the assembly code of the whole function, before and after
your changes.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]