public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Fw: Re: java memory allocation with gcj
@ 2009-11-05 11:31 isuru herath
  0 siblings, 0 replies; only message in thread
From: isuru herath @ 2009-11-05 11:31 UTC (permalink / raw)
  To: java

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@redhat.com>
wrote:

> From: Andrew Haley <aph@redhat.com>
> Subject: Re: java memory allocation with gcj
> To: "isuru herath" <isuru81@yahoo.com>
> Cc: java@gcc.gnu.org
> 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.
> 
> 


      

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-11-05 11:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-05 11:31 Fw: Re: java memory allocation with gcj isuru herath

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).