summaryrefslogtreecommitdiff
path: root/libjava/link.cc
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2006-04-24 15:33:16 +0000
committerAndrew Haley <aph@gcc.gnu.org>2006-04-24 15:33:16 +0000
commit621ae65dcd01b01cbf1b4723d55653c8c1c7855b (patch)
tree843ad6f8c55847b78d8168eb919c303e362e94d6 /libjava/link.cc
parent5204d06d82d16eb89d871797cf4ff082f4fa9526 (diff)
downloadgcc-621ae65dcd01b01cbf1b4723d55653c8c1c7855b.tar.gz
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
Diffstat (limited to 'libjava/link.cc')
-rw-r--r--libjava/link.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/libjava/link.cc b/libjava/link.cc
index 827d3185059..e107316d047 100644
--- a/libjava/link.cc
+++ b/libjava/link.cc
@@ -21,6 +21,12 @@ details. */
#include <java-interp.h>
+// Set GC_DEBUG before including gc.h!
+#ifdef LIBGCJ_GC_DEBUG
+# define GC_DEBUG
+#endif
+#include <gc.h>
+
#include <jvm.h>
#include <gcj/cni.h>
#include <string.h>
@@ -265,6 +271,21 @@ _Jv_Linker::resolve_pool_entry (jclass klass, int index, bool lazy)
{
using namespace java::lang::reflect;
+ if (GC_base (klass) && klass->constants.data
+ && ! GC_base (klass->constants.data))
+ {
+ jsize count = klass->constants.size;
+ if (count)
+ {
+ _Jv_word* constants
+ = (_Jv_word*) _Jv_AllocRawObj (count * sizeof (_Jv_word));
+ memcpy ((void*)constants,
+ (void*)klass->constants.data,
+ count * sizeof (_Jv_word));
+ klass->constants.data = constants;
+ }
+ }
+
_Jv_Constants *pool = &klass->constants;
if ((pool->tags[index] & JV_CONSTANT_ResolvedFlag) != 0)
@@ -1893,6 +1914,21 @@ _Jv_Linker::wait_for_state (jclass klass, int state)
java::lang::Thread *save = klass->thread;
klass->thread = self;
+ // Allocate memory for static fields and constants.
+ if (GC_base (klass) && klass->fields && ! GC_base (klass->fields))
+ {
+ jsize count = klass->field_count;
+ if (count)
+ {
+ _Jv_Field* fields
+ = (_Jv_Field*) _Jv_AllocRawObj (count * sizeof (_Jv_Field));
+ memcpy ((void*)fields,
+ (void*)klass->fields,
+ count * sizeof (_Jv_Field));
+ klass->fields = fields;
+ }
+ }
+
// Print some debugging info if requested. Interpreted classes are
// handled in defineclass, so we only need to handle the two
// pre-compiled cases here.