From 2c6c322a97713bff059648c8d2bbe87c16cd6b77 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 16 Mar 2000 01:32:12 +0000 Subject: [PATCH] decl.c (init_decl_processing): Set type of `sync_info' to be pointer to Object. * decl.c (init_decl_processing): Set type of `sync_info' to be pointer to Object. * boehm.c (get_boehm_type_descriptor): Correctly compute `bits'. Correctly compute bit number for current slot. Zero `high' and `low' in DS_LENGTH case. Don't skip inherited fields. Use mark_reference_fields. (mark_reference_fields): New function. From-SVN: r32572 --- gcc/java/ChangeLog | 11 +++++++ gcc/java/boehm.c | 72 ++++++++++++++++++++++++++++++++-------------- gcc/java/decl.c | 6 +++- 3 files changed, 66 insertions(+), 23 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index ecda52703ae..685972e1f76 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,14 @@ +2000-03-15 Tom Tromey + + * decl.c (init_decl_processing): Set type of `sync_info' to be + pointer to Object. + + * boehm.c (get_boehm_type_descriptor): Correctly compute `bits'. + Correctly compute bit number for current slot. Zero `high' and + `low' in DS_LENGTH case. Don't skip inherited fields. Use + mark_reference_fields. + (mark_reference_fields): New function. + Tue Mar 14 17:15:41 2000 Alexandre Petit-Bianco * parse.y (register_incomplete_type): Fixed initialization of diff --git a/gcc/java/boehm.c b/gcc/java/boehm.c index 370ff972e29..504637e5fd9 100644 --- a/gcc/java/boehm.c +++ b/gcc/java/boehm.c @@ -58,6 +58,50 @@ set_bit (unsigned HOST_WIDE_INT *low, unsigned HOST_WIDE_INT *high, *which |= (HOST_WIDE_INT) 1 << n; } +/* Recursively mark reference fields. */ +static unsigned int +mark_reference_fields (field, low, high, ubit, + pointer_after_end, all_bits_set, last_set_index) + tree field; + unsigned HOST_WIDE_INT *low, *high; + unsigned int ubit; + int *pointer_after_end, *all_bits_set, *last_set_index; +{ + unsigned int count = 0; + + /* See if we have fields from our superclass. */ + if (DECL_NAME (field) == NULL_TREE) + { + count += mark_reference_fields (TYPE_FIELDS (TREE_TYPE (field)), + low, high, ubit, + pointer_after_end, all_bits_set, + last_set_index); + field = TREE_CHAIN (field); + } + + for (; field != NULL_TREE; field = TREE_CHAIN (field)) + { + if (FIELD_STATIC (field)) + continue; + + if (JREFERENCE_TYPE_P (TREE_TYPE (field))) + { + *last_set_index = count; + /* First word in object corresponds to most significant byte + of bitmap. */ + set_bit (low, high, ubit - count - 1); + if (count > ubit - 2) + *pointer_after_end = 1; + } + else + *all_bits_set = 0; + + ++count; + } + + return count; +} + /* Return the marking bitmap for the class TYPE. For now this is a single word describing the type. */ tree @@ -79,7 +123,7 @@ get_boehm_type_descriptor (tree type) if (int_size_in_bytes (type) == -1) return PROCEDURE_OBJECT_DESCRIPTOR; - bit = POINTER_SIZE; + bit = POINTER_SIZE / BITS_PER_UNIT; /* The size of this node has to be known. And, we only support 32 and 64 bit targets, so we need to know that the log2 is one of our values. */ @@ -97,27 +141,9 @@ get_boehm_type_descriptor (tree type) ubit = (unsigned int) bit; field = TYPE_FIELDS (type); - if (DECL_NAME (field) == NULL_TREE) - field = TREE_CHAIN (field); /* Skip dummy field for inherited data. */ - for (count = 0; field != NULL_TREE; field = TREE_CHAIN (field)) - { - if (FIELD_STATIC (field)) - continue; - - if (JREFERENCE_TYPE_P (TREE_TYPE (field))) - { - last_set_index = count; - /* First word in object corresponds to most significant byte - of bitmap. */ - set_bit (&low, &high, ubit - count); - if (count > ubit - 2) - pointer_after_end = 1; - } - else - all_bits_set = 0; - - ++count; - } + count = mark_reference_fields (field, &low, &high, ubit, + &pointer_after_end, &all_bits_set, + &last_set_index); /* If the object is all pointers, or if the part with pointers fits in our bitmap, then we are ok. Otherwise we have to allocate it @@ -129,6 +155,8 @@ get_boehm_type_descriptor (tree type) DS_LENGTH is 0. WORDS_TO_BYTES shifts by log2(bytes-per-pointer). */ count = 0; + low = 0; + high = 0; ++last_set_index; while (last_set_index) { diff --git a/gcc/java/decl.c b/gcc/java/decl.c index b4dc28da833..a0c37340b38 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -626,7 +626,11 @@ init_decl_processing () dtable_ptr_type = build_pointer_type (dtable_type); PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type); - PUSH_FIELD (object_type_node, field, "sync_info", ptr_type_node); + /* This isn't exactly true, but it is what we have in the source. + There is an unresolved issue here, which is whether the vtable + should be marked by the GC. */ + PUSH_FIELD (object_type_node, field, "sync_info", + build_pointer_type (object_type_node)); for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t)) FIELD_PRIVATE (t) = 1; FINISH_RECORD (object_type_node);