/* Functions related to the Boehm garbage collector.
- Copyright (C) 2000, 2003, 2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2003, 2004, 2006, 2009 Free Software Foundation, Inc.
This file is part of GCC.
#include "system.h"
#include "coretypes.h"
+#include "double-int.h"
#include "tm.h"
#include "tree.h"
#include "java-tree.h"
#include "parse.h"
+#include "diagnostic-core.h"
#include "toplev.h"
-static void mark_reference_fields (tree, unsigned HOST_WIDE_INT *,
- unsigned HOST_WIDE_INT *, unsigned int,
+static void mark_reference_fields (tree, double_int *, unsigned int,
int *, int *, int *, HOST_WIDE_INT *);
-static void set_bit (unsigned HOST_WIDE_INT *, unsigned HOST_WIDE_INT *,
- unsigned int);
/* A procedure-based object descriptor. We know that our
`kind' is 0, and `env' is likewise 0, so we have a simple
Here DS_PROC == 2. */
#define PROCEDURE_OBJECT_DESCRIPTOR 2
-/* Treat two HOST_WIDE_INT's as a contiguous bitmap, with bit 0 being
- the least significant. This function sets bit N in the bitmap. */
-static void
-set_bit (unsigned HOST_WIDE_INT *low, unsigned HOST_WIDE_INT *high,
- unsigned int n)
-{
- unsigned HOST_WIDE_INT *which;
-
- if (n >= HOST_BITS_PER_WIDE_INT)
- {
- n -= HOST_BITS_PER_WIDE_INT;
- which = high;
- }
- else
- which = low;
-
- *which |= (unsigned HOST_WIDE_INT) 1 << n;
-}
-
/* Recursively mark reference fields. */
static void
mark_reference_fields (tree field,
- unsigned HOST_WIDE_INT *low,
- unsigned HOST_WIDE_INT *high,
+ double_int *mask,
unsigned int ubit,
int *pointer_after_end,
int *all_bits_set,
if (DECL_NAME (field) == NULL_TREE)
{
mark_reference_fields (TYPE_FIELDS (TREE_TYPE (field)),
- low, high, ubit,
+ mask, ubit,
pointer_after_end, all_bits_set,
last_set_index, last_view_index);
- field = TREE_CHAIN (field);
+ field = DECL_CHAIN (field);
}
- for (; field != NULL_TREE; field = TREE_CHAIN (field))
+ for (; field != NULL_TREE; field = DECL_CHAIN (field))
{
HOST_WIDE_INT offset;
HOST_WIDE_INT size_bytes;
offset = int_byte_position (field);
size_bytes = int_size_in_bytes (TREE_TYPE (field));
+
if (JREFERENCE_TYPE_P (TREE_TYPE (field))
/* An `object' of type gnu.gcj.RawData is actually non-Java
data. */
we already covered, then we are doomed. */
gcc_assert (offset > *last_view_index);
+ if (offset % (HOST_WIDE_INT) (POINTER_SIZE / BITS_PER_UNIT))
+ {
+ *all_bits_set = -1;
+ *pointer_after_end = 1;
+ break;
+ }
+
count = offset * BITS_PER_UNIT / POINTER_SIZE;
size_words = size_bytes * BITS_PER_UNIT / POINTER_SIZE;
bits for all words in the record. This is conservative, but the
size_words != 1 case is impossible in regular java code. */
for (i = 0; i < size_words; ++i)
- set_bit (low, high, ubit - count - i - 1);
+ *mask = double_int_setbit (*mask, ubit - count - i - 1);
if (count >= ubit - 2)
*pointer_after_end = 1;
int last_set_index = 0;
HOST_WIDE_INT last_view_index = -1;
int pointer_after_end = 0;
- unsigned HOST_WIDE_INT low = 0, high = 0;
+ double_int mask;
tree field, value, value_type;
+ mask = double_int_zero;
+
/* If the GC wasn't requested, just use a null pointer. */
if (! flag_use_boehm_gc)
return null_pointer_node;
goto procedure_object_descriptor;
field = TYPE_FIELDS (type);
- mark_reference_fields (field, &low, &high, ubit,
+ mark_reference_fields (field, &mask, ubit,
&pointer_after_end, &all_bits_set,
&last_set_index, &last_view_index);
that we don't have to emit reflection data for run time
marking. */
count = 0;
- low = 0;
- high = 0;
+ mask = double_int_zero;
++last_set_index;
while (last_set_index)
{
if ((last_set_index & 1))
- set_bit (&low, &high, log2_size + count);
+ mask = double_int_setbit (mask, log2_size + count);
last_set_index >>= 1;
++count;
}
- value = build_int_cst_wide (value_type, low, high);
+ value = double_int_to_tree (value_type, mask);
}
else if (! pointer_after_end)
{
/* Bottom two bits for bitmap mark type are 01. */
- set_bit (&low, &high, 0);
- value = build_int_cst_wide (value_type, low, high);
+ mask = double_int_setbit (mask, 0);
+ value = double_int_to_tree (value_type, mask);
}
else
{