Commit e046c56e by Andrew Haley Committed by Andrew Haley

class.c (make_class_data): When using flag_indirect_classes, don't initialize…

class.c (make_class_data): When using flag_indirect_classes, don't initialize the vtable of Class instances.

2006-06-16  Andrew Haley  <aph@redhat.com>

        * class.c (make_class_data): When using flag_indirect_classes,
        don't initialize the vtable of Class instances.

2006-06-16  Andrew Haley  <aph@redhat.com>

        * java/lang/natClassLoader.cc (_Jv_NewClassFromInitializer): Don't
        copy the whole Class instance from the initializer: instead, copy
        everything but the first word (the vtable pointer).
        Change prototype to (const char* class_initializer).
        (_Jv_RegisterNewClasses): Change prototype to (const char**).
        * java/lang/Class.h (_Jv_RegisterNewClasses): Change prototype to
        (const char**).

From-SVN: r114714
parent 47392a21
2006-06-16 Andrew Haley <aph@redhat.com>
* class.c (make_class_data): When using flag_indirect_classes,
don't initialize the vtable of Class instances.
2006-06-09 Andrew Haley <aph@redhat.com> 2006-06-09 Andrew Haley <aph@redhat.com>
PR java/1305 PR java/1305
......
...@@ -1863,10 +1863,12 @@ make_class_data (tree type) ...@@ -1863,10 +1863,12 @@ make_class_data (tree type)
START_RECORD_CONSTRUCTOR (temp, object_type_node); START_RECORD_CONSTRUCTOR (temp, object_type_node);
PUSH_FIELD_VALUE (temp, "vtable", PUSH_FIELD_VALUE (temp, "vtable",
build2 (PLUS_EXPR, dtable_ptr_type, (flag_indirect_classes
build1 (ADDR_EXPR, dtable_ptr_type, ? null_pointer_node
class_dtable_decl), : build2 (PLUS_EXPR, dtable_ptr_type,
dtable_start_offset)); build1 (ADDR_EXPR, dtable_ptr_type,
class_dtable_decl),
dtable_start_offset)));
if (! flag_hash_synchronization) if (! flag_hash_synchronization)
PUSH_FIELD_VALUE (temp, "sync_info", null_pointer_node); PUSH_FIELD_VALUE (temp, "sync_info", null_pointer_node);
FINISH_RECORD_CONSTRUCTOR (temp); FINISH_RECORD_CONSTRUCTOR (temp);
......
2006-06-16 Andrew Haley <aph@redhat.com>
* java/lang/natClassLoader.cc (_Jv_NewClassFromInitializer): Don't
copy the whole Class instance from the initializer: instead, copy
everything but the first word (the vtable pointer).
Change prototype to (const char* class_initializer).
(_Jv_RegisterNewClasses): Change prototype to (const char**).
* java/lang/Class.h (_Jv_RegisterNewClasses): Change prototype to
(const char**).
2006-06-15 Thomas Fitzsimmons <fitzsim@redhat.com> 2006-06-15 Thomas Fitzsimmons <fitzsim@redhat.com>
* classpath/Makefile.am: Do not recurse into tools directory. * classpath/Makefile.am: Do not recurse into tools directory.
......
...@@ -40,8 +40,8 @@ extern "Java" ...@@ -40,8 +40,8 @@ extern "Java"
// We declare these here to avoid including gcj/cni.h. // We declare these here to avoid including gcj/cni.h.
extern "C" void _Jv_InitClass (jclass klass); extern "C" void _Jv_InitClass (jclass klass);
extern "C" jclass _Jv_NewClassFromInitializer extern "C" jclass _Jv_NewClassFromInitializer
(const jclass class_initializer); (const char *class_initializer);
extern "C" void _Jv_RegisterNewClasses (void **classes); extern "C" void _Jv_RegisterNewClasses (char **classes);
extern "C" void _Jv_RegisterClasses (const jclass *classes); extern "C" void _Jv_RegisterClasses (const jclass *classes);
extern "C" void _Jv_RegisterClasses_Counted (const jclass *classes, extern "C" void _Jv_RegisterClasses_Counted (const jclass *classes,
size_t count); size_t count);
...@@ -447,7 +447,7 @@ private: ...@@ -447,7 +447,7 @@ private:
int method_idx); int method_idx);
friend void ::_Jv_InitClass (jclass klass); friend void ::_Jv_InitClass (jclass klass);
friend java::lang::Class* ::_Jv_NewClassFromInitializer (const jclass class_initializer); friend java::lang::Class* ::_Jv_NewClassFromInitializer (const char *class_initializer);
friend void _Jv_RegisterNewClasses (void **classes); friend void _Jv_RegisterNewClasses (void **classes);
friend _Jv_Method* ::_Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *, friend _Jv_Method* ::_Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *,
......
...@@ -218,11 +218,20 @@ _Jv_RegisterClasses_Counted (const jclass * classes, size_t count) ...@@ -218,11 +218,20 @@ _Jv_RegisterClasses_Counted (const jclass * classes, size_t count)
// Create a class on the heap from an initializer struct. // Create a class on the heap from an initializer struct.
jclass jclass
_Jv_NewClassFromInitializer (const jclass class_initializer) _Jv_NewClassFromInitializer (const char *class_initializer)
{ {
jclass new_class = (jclass)_Jv_AllocObj (sizeof *new_class, /* We create an instance of java::lang::Class and copy all of its
&java::lang::Class::class$); fields except the first word (the vtable pointer) from
memcpy ((void*)new_class, (void*)class_initializer, sizeof *new_class); CLASS_INITIALIZER. This first word is pre-initialized by
_Jv_AllocObj, and we don't want to overwrite it. */
jclass new_class
= (jclass)_Jv_AllocObj (sizeof (java::lang::Class),
&java::lang::Class::class$);
const char *src = class_initializer + sizeof (void*);
char *dst = (char*)new_class + sizeof (void*);
size_t len = sizeof (*new_class) - sizeof (void*);
memcpy (dst, src, len);
new_class->engine = &_Jv_soleIndirectCompiledEngine; new_class->engine = &_Jv_soleIndirectCompiledEngine;
...@@ -240,13 +249,13 @@ _Jv_NewClassFromInitializer (const jclass class_initializer) ...@@ -240,13 +249,13 @@ _Jv_NewClassFromInitializer (const jclass class_initializer)
// heap) and we write the address of the new class into the address // heap) and we write the address of the new class into the address
// pointed to by the second word. // pointed to by the second word.
void void
_Jv_RegisterNewClasses (void **classes) _Jv_RegisterNewClasses (char **classes)
{ {
_Jv_InitGC (); _Jv_InitGC ();
jclass initializer; const char *initializer;
while ((initializer = (jclass)*classes++)) while ((initializer = *classes++))
{ {
jclass *class_ptr = (jclass *)*classes++; jclass *class_ptr = (jclass *)*classes++;
*class_ptr = _Jv_NewClassFromInitializer (initializer); *class_ptr = _Jv_NewClassFromInitializer (initializer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment