Fw: Re: java memory allocation with gcj

View: New views
1 Messages — Rating Filter:   Alert me  

Fw: Re: java memory allocation with gcj

by isuru herath :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Andrew,

Thanks for the reply. So I was thinking soon after the call to
_Jv_NewPrimArray the eax register should have the starting location of the
the memory allocated by the mmap. But the value at the eax register was
166816.
When I tried this with C, the value at the eax register after the
malloc call was 155648008. I also put a printf(&name) in the C code and it
prints the same address.
Then I tried store a value in the Java array and then tried to read the
memory address 166816 and it wasnot giving me the value that I stored in my
program.
Even the memory addresses given from C and java are different in sizes as well.

Am I missing something here. I just need to know how to find the address of
the block allocated by the "new" when running as native binary.

any help/advice on this regard is greatly appreciated.

regards,
Isuru
 
--- On Thu, 11/5/09, Andrew Haley <aph@...>
wrote:

> From: Andrew Haley <aph@...>
> Subject: Re: java memory allocation with gcj
> To: "isuru herath" <isuru81@...>
> Cc: java@...
> Date: Thursday, November 5, 2009, 1:23 AM
> isuru herath wrote:
>
> > I am interested in studying how "new" allocates memory when running
> > as native binary. For this I wrote a simple Java class which just
> > create an int array. Then I generate the assembly with gcj -S
> > option. There I spotted the call to _Jv_NewPrimArray. Since the
> > result of the call is stored in eax register I check the value of
> > the eax register after this call. But it is giving a small number. I
> > tried the same thing with C. There I spotted the call to malloc and
> > check the eax after the malloc call and it has the same value as the
> > &variable_name has.
 
> _Jv_NewPrimArray calls the memory allocator (actually part of the Boehm
> garbage collector) which calls
> mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE, ..) to map the
memory.
 
> Andrew.
>
>