lang.c (java_init): Handle flag_indirect_classes.

2006-04-21  Andrew Haley  <aph@redhat.com>

        * lang.c (java_init): Handle flag_indirect_classes.
        * jvgenmain.c: Use "class$$" instead of "class$".
        * mangle.c (java_mangle_decl): Accept RECORD_TYPEs sw well as
        DECLs.
        (mangle_class_field): Special case "class$$" as well as "class$".
        * constants.c (build_ref_from_constant_pool): If
        flag_indirect_classes, generate a ref into the heap.
        * decl.c (constants_field_decl_node,
        constants_data_field_decl_node): New.
        * class.c (build_static_class_ref): New.
        (build_classdollar_field): Factor out from build_class_ref().
        (make_field_value): Handle static fields in heap.
        (make_class_data): Make sure we get a static ref to class.
        Make class initializer const if flag_indirect_classes.
        (register_class): Build a class_ref for initialization if
        flag_indirect_classes.
        (emit_indirect_register_classes): New.

2006-04-21  Andrew Haley  <aph@redhat.com>

        * include/execution.h (struct _Jv_CompiledEngine): Define for
        compiled classes.
        * java/lang/natClassLoader.cc (_Jv_RegisterClasses): Call
        _Jv_RegisterLibForGc.
        (_Jv_RegisterClasses_Counted): Likewise.
        (_Jv_NewClassFromInitializer): New.
        (_Jv_RegisterNewClasses): New.
        * sources.am: Regenerate.
        * boehm.cc (_Jv_GC_has_static_roots): new.
        (_Jv_InitGC): Call GC_register_has_static_roots_callback.
        (filename_node, find_file, _Jv_print_gc_store, new_node,
        _Jv_GC_has_static_roots, _Jv_RegisterLibForGc): New.
        * scripts/makemake.tcl: Add -fno-indirect-classes.
        * Makefile.in: Regenerate.
        * link.cc (resolve_pool_entry): Allocate constant pool.
        Allocate fields.

From-SVN: r113224
This commit is contained in:
Andrew Haley 2006-04-24 15:33:16 +00:00 committed by Andrew Haley
parent 5204d06d82
commit 621ae65dcd
19 changed files with 526 additions and 89 deletions

View file

@ -45,14 +45,17 @@ details. */
#include <gnu/gcj/runtime/BootClassLoader.h>
#include <gnu/gcj/runtime/SystemClassLoader.h>
#undef _GNU_SOURCE
#define _GNU_SOURCE
#include <dlfcn.h>
#include <link.h>
// Size of local hash table.
#define HASH_LEN 1013
// Hash function for Utf8Consts.
#define HASH_UTF(Utf) ((Utf)->hash16() % HASH_LEN)
static jclass loaded_classes[HASH_LEN];
// This records classes which will be registered with the system class
// loader when it is initialized.
static jclass system_class_list;
@ -62,6 +65,8 @@ static jclass system_class_list;
// no longer pay attention to the system abi flag.
#define SYSTEM_LOADER_INITIALIZED ((jclass) -1)
static jclass loaded_classes[HASH_LEN];
// This is the root of a linked list of classes
static jclass stack_head;
@ -164,6 +169,8 @@ _Jv_UnregisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
void
_Jv_RegisterClasses (const jclass *classes)
{
_Jv_RegisterLibForGc (classes);
for (; *classes; ++classes)
{
jclass klass = *classes;
@ -178,6 +185,9 @@ void
_Jv_RegisterClasses_Counted (const jclass * classes, size_t count)
{
size_t i;
_Jv_RegisterLibForGc (classes);
for (i = 0; i < count; i++)
{
jclass klass = classes[i];
@ -187,6 +197,41 @@ _Jv_RegisterClasses_Counted (const jclass * classes, size_t count)
}
}
// Create a class on the heap from an initializer struct.
jclass
_Jv_NewClassFromInitializer (const jclass class_initializer)
{
jclass new_class = (jclass)_Jv_AllocObj (sizeof *new_class,
&java::lang::Class::class$);
memcpy ((void*)new_class, (void*)class_initializer, sizeof *new_class);
if (_Jv_CheckABIVersion ((unsigned long) new_class->next_or_version))
(*_Jv_RegisterClassHook) (new_class);
return new_class;
}
// Called by compiler-generated code at DSO initialization. CLASSES
// is an array of pairs: the first item of each pair is a pointer to
// the initialized data that is a class initializer in a DSO, and the
// second is a pointer to a class reference.
// _Jv_NewClassFromInitializer() creates the new class (on the Java
// heap) and we write the address of the new class into the address
// pointed to by the second word.
void
_Jv_RegisterNewClasses (void **classes)
{
_Jv_InitGC ();
jclass initializer;
while ((initializer = (jclass)*classes++))
{
jclass *class_ptr = (jclass *)*classes++;
*class_ptr = _Jv_NewClassFromInitializer (initializer);
}
}
void
_Jv_RegisterClassHookDefault (jclass klass)
{
@ -389,6 +434,12 @@ static _Jv_IDispatchTable *array_idt = NULL;
static jshort array_depth = 0;
static jclass *array_ancestors = NULL;
static jclass interfaces[] =
{
&java::lang::Cloneable::class$,
&java::io::Serializable::class$
};
// Create a class representing an array of ELEMENT and store a pointer to it
// in element->arrayclass. LOADER is the ClassLoader which _initiated_ the
// instantiation of this array. ARRAY_VTABLE is the vtable to use for the new
@ -464,11 +515,6 @@ _Jv_NewArrayClass (jclass element, java::lang::ClassLoader *loader,
array_class->element_type = element;
// Register our interfaces.
static jclass interfaces[] =
{
&java::lang::Cloneable::class$,
&java::io::Serializable::class$
};
array_class->interfaces = interfaces;
array_class->interface_count = sizeof interfaces / sizeof interfaces[0];