Re: location of static data

"Chris Pickett" <[email protected]> Mon, 17 Apr 2006 01:19:33 -0400 (EDT)
Newsgroups gmane.comp.java.vm.sablevm.devel
Message-ID <[email protected]>
On Mon, April 17, 2006 12:09 am, Etienne Gagnon wrote:
> Chris Pickett wrote:
>> _svmt_object_instance *instance =3D
>> *(method->class_info->class_instance);

> In other words:
> class_instance -points-to-> native_reference -points-to-> instance (cl
> memory)                 (malloc memory)               (heap)

Ok, this makes sense.  It means you must include global native references
as part of your root set in GC.

>> When PUTSTATIC_<X> is executed, where does that write?  Previously, I
>> thought it wrote to a class field that was outside of the heap.
>
> Yes, for primitive types.

Ok, I can see that now.  It writes to some element of _svmt_field_info
*fields in _svmt_class_info.

> For reference types, it writes to a global native reference.  It's the
> address of the global native reference that is stored in the class_info
> structure.  This class_instance field is initialized once at class load=
ing
> time.

I'm a little confused here by the last sentence above.  I meant when you
write to any static reference:

static Object o;

static void m() {
    o =3D new Object();
}

I'm guessing this does not actually write to the class_instance field
("This class_instance field is intialized once...", but to a global nativ=
e
reference, as follows:

  jvalue *pvalue =3D (pc++)->pvalue;
  *(pvalue->l) =3D stack[--stack_size].reference;

from PUTSTATIC_REFERENCE.  The address of the global native reference is
stored in fields[] like the primitive type fields.  In the code above thi=
s
address is pvalue->l.  The global native ref is *(pvalue->l).

> Hoping this clarifies things for you. :-)

Yes, quite a bit.  Thank-you.  I hope you can correct what is still wrong
above, if anything :)

Cheers,
Chris