ooo-build r11348 - trunk/patches/test



Author: michael
Date: Mon Jan 21 17:58:22 2008
New Revision: 11348
URL: http://svn.gnome.org/viewvc/ooo-build?rev=11348&view=rev

Log:
better vtable construction (in principle)


Modified:
   trunk/patches/test/gcc-vt-copy-4.diff

Modified: trunk/patches/test/gcc-vt-copy-4.diff
==============================================================================
--- trunk/patches/test/gcc-vt-copy-4.diff	(original)
+++ trunk/patches/test/gcc-vt-copy-4.diff	Mon Jan 21 17:58:22 2008
@@ -12,7 +12,7 @@
  
 diff -u -r -x '*~' -x testsuite -x libjava -x cc-nptl -x build-dir -x '*.orig' -x obj-i586-suse-linux -x texis -x Makeconfig -x version.h -x '*.o' -x '*.1' -x 'Makefile*' -x 'config*' -x libtool -x '*.info' -x '*.tex' pristine-gcc-4.2.1-simple/gcc/cp/class.c gcc-4.2.1-simple/gcc/cp/class.c
 --- pristine-gcc-4.2.1-simple/gcc/cp/class.c	2007-07-05 10:02:39.000000000 +0100
-+++ gcc-4.2.1-simple/gcc/cp/class.c	2008-01-19 21:30:16.000000000 +0000
++++ gcc-4.2.1-simple/gcc/cp/class.c	2008-01-21 18:00:15.000000000 +0000
 @@ -136,7 +136,7 @@
  static tree fixed_type_or_null (tree, int *, int *);
  static tree build_simple_base_path (tree expr, tree binfo);
@@ -41,9 +41,9 @@
        return;
      }
    overrider_target = overrider_fn = TREE_PURPOSE (overrider);
-+  fprintf (stderr, "override %d %d\n",
++  /*  fprintf (stderr, "override %d %d\n",
 +	   TREE_VALUE (overrider) != binfo,
-+	   first_defn != binfo);
++	   first_defn != binfo); */
 +  BV_INHERITED(*virtuals) = first_defn != binfo || TREE_VALUE (overrider) != binfo;
  
    /* Check for adjusting covariant return types.  */
@@ -101,11 +101,11 @@
      fprintf (stream, "\n");
  
 -  if (!(flags & TDF_SLIM))
-+  if (1) // !(flags & TDF_SLIM))
++  if (1) /* !(flags & TDF_SLIM)) */
      {
        int indented = 0;
  
-@@ -6637,33 +6682,240 @@
+@@ -6637,33 +6682,529 @@
    dump_thunk (stderr, 0, fn);
  }
  
@@ -135,26 +135,23 @@
 +/* Pragmatic 1st cut output format: */
 +/* dest_addr, src_addr, <bitmap> */
 +static tree
-+build_vtable_copy_slot (tree dest, int dest_offset,
++build_vtable_copy_slot (tree dest_binfo, int dest_offset,
 +                        tree src_binfo,  int src_offset,
 +                        int bitmap, tree chain)
 +{
 +    tree src_decl, dest_decl;
 +    tree elem = NULL_TREE, init;
-+    tree dest_binfo;
 +
 +    /* Either a padding entry or nothing to do */
-+    if (!dest || !bitmap)
++    if (!dest_binfo || !bitmap)
 +      return chain;
 +
-+    dest_binfo = TYPE_BINFO (dest);
-+    
-+    fprintf (stderr, "Copy %s + %d => ",
++    /*    fprintf (stderr, "Copy %s + %d => ",
 +             type_as_string (src_binfo, TFF_PLAIN_IDENTIFIER),
 +             src_offset);
 +    fprintf (stderr, " %s + %d mask 0x%x\n",
 +             type_as_string (dest_binfo, TFF_PLAIN_IDENTIFIER),
-+             dest_offset, bitmap);
++             dest_offset, bitmap); */
 +
 +    elem = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, bitmap), elem);
 +
@@ -223,15 +220,15 @@
 +	  /* FIXME: this sucks - must be a better way to 
 +	     find target size: 32 or 64 (?) [ assuming elf etc. ] */
 +	  if (i == (sizeof (long) * 8)) { /* FIXME ... arch size etc. */
-+	    inits = build_vtable_copy_slot (
++	    /*	    inits = build_vtable_copy_slot (
 +					    t, dest_offset - i, orig_binfo,
-+					    src_offset - i, bitmap, inits);
++					    src_offset - i, bitmap, inits); */
 +	    i = bitmap = 0;
 +	  }
 +	}
-+      inits = build_vtable_copy_slot (
++      /*      inits = build_vtable_copy_slot (
 +				      t, dest_offset - i, orig_binfo,
-+				      src_offset - i, bitmap, inits);
++				      src_offset - i, bitmap, inits); */
 +    }
 +
 +  if (inits)
@@ -280,8 +277,8 @@
  	continue;
 -      accumulate_vtbl_inits (vbase, vbase, TYPE_BINFO (t), t, list);
 +      accumulate_vtbl_inits (vbase, vbase, TYPE_BINFO (t), t, list, &slot_relocs);
-     }
- 
++    }
++
 +  /* So ... we have a hack here - we append a reference to
 +     the vtable to ourselves, in order to stop us getting GC'd */
 +  if (slot_relocs)
@@ -295,63 +292,355 @@
 +}
 +
 +static void
-+debug_vtable (tree t, tree binfo)
++debug_vtable (tree t, tree binfo, VEC(constructor_elt,gc) *opt_vtable)
 +{
-+  tree vtable = get_vtbl_decl_for_binfo (binfo);
++  tree vtable_tree;
 +  tree value;
 +  unsigned HOST_WIDE_INT ix;
-+  HOST_WIDE_INT elt;
++  VEC(constructor_elt,gc) *vtable;
 +
 +  fprintf (stderr, "VTable for '%s'\n",
 +	   type_as_string (t, TFF_PLAIN_IDENTIFIER));
-+  if (!vtable) 
++  if (opt_vtable)
++    vtable = opt_vtable;
++  else
 +    {
-+      fprintf (stderr, "<none>\n");
-+      return;
++      vtable_tree = get_vtbl_decl_for_binfo (binfo);
++      if (!vtable_tree) 
++	{
++	  fprintf (stderr, "<none>\n");
++	  return;
++	}
++      vtable = CONSTRUCTOR_ELTS (DECL_INITIAL (vtable_tree));
 +    }
 +
-+  elt = (tree_low_cst (TYPE_SIZE (TREE_TYPE (TREE_TYPE (vtable))), 0)
-+	 / BITS_PER_UNIT);
-+  FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (DECL_INITIAL (vtable)),
-+			      ix, value) 
++  FOR_EACH_CONSTRUCTOR_VALUE (vtable, ix, value) 
 +    {
-+      fprintf (stderr, "\t%-4ld  %s\n", (long)(ix * elt),
++      fprintf (stderr, "\t%-4ld  %s\n", (long)ix,
 +	       expr_as_string (value, TFF_PLAIN_IDENTIFIER));
 +    }
 +}
 +
++/* to track a segment of vtable initializer */
++typedef struct vt_fragment_d GTY(()) {
++  tree binfo;
++
++  /* ptr into the vec decl */
++  unsigned int offset;
++  unsigned int size;
++  VEC(constructor_elt,gc) *vec;
++} vt_fragment;
++
++typedef struct vt_copy_record_d GTY(()) {
++  vt_fragment *src;
++  vt_fragment *dest;
++  unsigned int bitmap;
++  unsigned int offset;
++} vt_copy_record;
++
++DEF_VEC_O(vt_fragment);
++DEF_VEC_O(vt_copy_record);
++DEF_VEC_ALLOC_O(vt_fragment, heap);
++DEF_VEC_ALLOC_O(vt_copy_record, heap);
++
++static void
++vtdecompose_frags (tree t_binfo, VEC(constructor_elt,gc) *vtable,
++		   VEC(vt_fragment,heap) **frags)
++{
++  unsigned int seek_fn = 1, i;
++  vt_fragment *frag = NULL;
++
++  for (i = 0; i < VEC_length(constructor_elt,vtable); i++)
++    {
++      tree fn = VEC_index (constructor_elt, vtable, i)->value;
++      int is_fn = TREE_CODE (fn) == ADDR_EXPR
++	&& TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL;
++
++      if (is_fn && seek_fn)
++	{
++	  frag = VEC_safe_push (vt_fragment, heap, *frags, NULL);
++	  frag->binfo = t_binfo;
++	  frag->offset = i;
++	  frag->size = VEC_length (constructor_elt, vtable) - i;
++	  frag->vec = vtable;
++	  seek_fn = 0;
++	}
++      if (!is_fn && !seek_fn)
++	{
++	  frag->size = i - frag->offset;
++	  seek_fn = 1;
++	}
++    }
++}
++
++static void
++debug_fragments (VEC(vt_fragment,heap) *frags)
++{
++  unsigned int i;
++  for (i = 0; i < VEC_length(vt_fragment,frags); i++)
++    {
++      vt_fragment *frag = VEC_index (vt_fragment, frags, i);
++      fprintf (stderr, "fragment %d: '%s' offset %d, size %d\n",
++	       i, type_as_string (BINFO_TYPE (frag->binfo), TFF_PLAIN_IDENTIFIER),
++	       frag->offset, frag->size);
++    }
++}
++
++static void
++push_vtfrag (VEC(vt_copy_record,heap) **vt_copies,
++	     vt_fragment *src, vt_fragment *dest,
++	     unsigned int bitmap, unsigned int offset)
++{
++  vt_copy_record *rec;
++
++  /* FIXME: we need to be able to compare these */
++  /* that is not easy, sadly - so punt for now (?), and hope we don't get too
++   * many duplicate / overlapping hits */
++  rec = VEC_safe_push (vt_copy_record, heap, *vt_copies, NULL);
++  rec->src = src;
++  rec->dest = dest;
++  rec->bitmap = bitmap;
++  rec->offset = offset;
++  fprintf (stderr, "Push frag 0x%x %d\n", bitmap, offset);
++}
++
++static void
++debug_vt_copies (VEC(vt_copy_record,heap) *vt_copies)
++{
++  unsigned int i;
++  fprintf (stderr, "vtcopies: %d records\n", VEC_length(vt_copy_record, vt_copies));
++  for (i = 0; i < VEC_length(vt_copy_record, vt_copies); i++)
++    {
++      vt_copy_record *cpy = VEC_index (vt_copy_record, vt_copies, i);
++      fprintf (stderr, "\tcopy from %s+%d to %s+%d mask 0x%x\n",
++	       type_as_string (BINFO_TYPE (cpy->src->binfo), TFF_PLAIN_IDENTIFIER),
++	       cpy->src->offset + cpy->offset,
++	       type_as_string (BINFO_TYPE (cpy->dest->binfo), TFF_PLAIN_IDENTIFIER),
++	       cpy->dest->offset + cpy->offset,
++	       cpy->bitmap);
++    }
++}
++
++/*
++ * Compare all src & dest fragments for the best match ...
++ */
++static tree
++compare_build_vtrelocs (tree t, VEC(constructor_elt,gc) *vinits,
++			VEC(vt_fragment,heap) *dest_frags,
++			VEC(vt_fragment,heap) *src_frags)
++{
++  unsigned int i;
++  tree cgraph_clobber = NULL_TREE;
++  VEC(vt_copy_record,heap) *vt_copies;
++
++  vt_copies = VEC_alloc(vt_copy_record, heap, VEC_length(vt_fragment, dest_frags));
++
++  for (i = 0; i < VEC_length(vt_fragment, dest_frags); i++)
++    {
++      unsigned int j;
++      vt_fragment *dest = VEC_index (vt_fragment, dest_frags, i);
++      
++      for (j = 0; j < VEC_length(vt_fragment, src_frags); j++)
++	{
++	  unsigned int cmp;
++	  unsigned int k, bits_set;
++	  unsigned int bitmask;
++	  int elide_leading_zeros = 1;
++	  vt_fragment *src = VEC_index (vt_fragment, src_frags, j);
++
++	  /* new virtual methods arrive only in the 1st dest fragment */
++	  if (i > 0 && dest->size != src->size)
++	    continue;
++
++	  cmp = src->size;
++	  if (cmp > dest->size)
++	    cmp = dest->size;
++
++	  /* FIXME: bin elide_leading_zeros until we have better
++	   * comparison logic ? */
++	  for (bitmask = bits_set = k = 0; k < cmp; k++)
++	    {
++	      tree src_fn = VEC_index (constructor_elt, src->vec, src->offset + k)->value;
++	      tree dest_fn = VEC_index (constructor_elt, dest->vec, dest->offset + k)->value;
++	      src_fn = TREE_OPERAND (src_fn, 0);
++	      dest_fn = TREE_OPERAND (dest_fn, 0);
++
++	      if (src_fn == dest_fn)
++		{
++		  bitmask |= (1 << bits_set);
++		  elide_leading_zeros = 0;
++		}
++	      
++	      fprintf (stderr, "compare: %s %s %s (0x%x)\n",
++		       expr_as_string (src_fn, TFF_PLAIN_IDENTIFIER),
++		       src_fn == dest_fn ? "==" : "!=",
++		       expr_as_string (dest_fn, TFF_PLAIN_IDENTIFIER),
++		       bitmask);
++	      
++	      if (!elide_leading_zeros)
++		bits_set++;
++
++	      if (bits_set == (sizeof (long) * 8)) /* FIXME: arch size etc. urgh ... */
++		{
++		  push_vtfrag (&vt_copies, src, dest, bitmask, k - bits_set);
++		  bits_set = bitmask = 0;
++		  elide_leading_zeros = 1;
++		}
++	    }
++	  if (bitmask != 0)
++	    push_vtfrag (&vt_copies, src, dest, bitmask, k - bits_set);
++	}
++    }
++
++  if (VEC_length(vt_copy_record, vt_copies) > 0)
++    {
++      VEC(constructor_elt,gc) *vtable;
++      unsigned int i;
++      tree vtreloc_inits = NULL_TREE;
++
++      debug_vt_copies (vt_copies);
++
++      /*
++       * Re-write the intializers to remove references in the vtable...
++       */
++      vtable = VEC_copy(constructor_elt,gc,vinits);
++
++      /* FIXME: copy & backup the original data before we mangle it
++	 for future reference [!] */
++      
++      fprintf (stderr, "re-writing vtable:\n");
++      for (i = 0; i < VEC_length(vt_copy_record, vt_copies); i++)
++	{
++	  unsigned int j, bitmask;
++	  vt_copy_record *vtc = VEC_index(vt_copy_record, vt_copies, i);
++
++	  /* re-write the existing vtable intializer */
++	  bitmask = vtc->bitmap;
++	  for (j = vtc->dest->offset + vtc->offset; bitmask; j++, (bitmask>>=1))
++	    {
++	      if (bitmask & 1)
++		{
++		  constructor_elt *elt = VEC_index (constructor_elt, vtable, j);
++		  fprintf (stderr, "\tclobber '%s'\n",
++			   expr_as_string (elt->value, TFF_PLAIN_IDENTIFIER));
++		  elt->value = fold_build1 (NOP_EXPR,
++					    vtable_entry_type,
++					    build_int_cst (build_pointer_type (void_type_node),
++							   0xdeadbeef));
++		}
++	    }
++
++	  /* build vtreloc decls */
++	  vtreloc_inits = build_vtable_copy_slot (vtc->dest->binfo, vtc->dest->offset + vtc->offset,
++						  vtc->src->binfo, vtc->src->offset + vtc->offset,
++						  vtc->bitmap, vtreloc_inits);
++	}
++
++      /* re-build as chain for constructor ... hmm */
++      for (i = 0; i < VEC_length(constructor_elt, vtable); i++)
++	{
++	  constructor_elt *elt = VEC_index (constructor_elt, vtable, i);
++	  cgraph_clobber = tree_cons (elt->index, elt->value, cgraph_clobber);
++	}
++
++      /* Append a reference to the parent vtable
++       * to encourage gcc to emit the VTReloc table */
++      cgraph_clobber = tree_cons (NULL_TREE,
++				  build_nop (vfunc_ptr_type_node,
++					     build_address (get_vtreloc_decl (t, vtreloc_inits))),
++				  cgraph_clobber);
++      cgraph_clobber = nreverse (cgraph_clobber);
++    }
++
++  vec_heap_free (vt_copies);
++  return cgraph_clobber;
++}
++
++static VEC(constructor_elt,gc) *
++build_init_vec (tree inits)
++{
++  tree t;
++  VEC(constructor_elt,gc) *v = NULL;
++
++  if (inits)
++    {
++      v = VEC_alloc (constructor_elt, gc, list_length (inits));
++      for (t = inits; t; t = TREE_CHAIN (t))
++	{
++	  constructor_elt *elt = VEC_quick_push (constructor_elt, v, NULL);
++	  elt->index = TREE_PURPOSE (t);
++	  elt->value = TREE_VALUE (t);
++	}
++    }
++
++  return v;
++}
++
 +static void
 +finish_vtbls (tree t)
 +{
 +  tree inits;
-+  /* FIXME: new approach do a straight, 1-off compare here ... */
-+  fprintf (stderr, "vtable init 1\n");
++  VEC(constructor_elt,gc) *vinits = NULL;
 +  
 +  inits = vtbl_get_inits (t);
++  vinits = build_init_vec (inits);
++  /* FIXME: keep these around as our cache ? & heap allocate etc. */
 +
-   if (BINFO_VTABLE (TYPE_BINFO (t)))
--    initialize_vtable (TYPE_BINFO (t), TREE_VALUE (list));
-+    initialize_vtable (TYPE_BINFO (t), inits);
-+
-+  debug_vtable (t, TYPE_BINFO (t));
-+
-+  if (getenv ("INHERITEDINITS"))
++  if (inits && getenv ("INHERITEDINITS"))
 +  {
 +    int i;
 +    tree base_binfo;
++    VEC(vt_fragment,heap) *dest_frags;
++    VEC(vt_fragment,heap) *src_frags;
++
++    debug_vtable (t, TYPE_BINFO (t), vinits);
++
 +    fprintf (stderr, "Inherited from:\n");
 +    for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (t), i, base_binfo); i++)
 +      {
 +	tree btype = BINFO_TYPE (base_binfo);
-+	debug_vtable (btype, TYPE_BINFO (btype));
++	debug_vtable (btype, TYPE_BINFO (btype), NULL);
 +	fprintf (stderr, "same ? %d or super-type\n", 
 +		 base_binfo == TYPE_BINFO (btype));
 +      }
++
++    src_frags = VEC_alloc(vt_fragment,heap,4);
++    dest_frags = VEC_alloc(vt_fragment,heap,4);
++    vtdecompose_frags (TYPE_BINFO (t), vinits, &dest_frags);
++    for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (t), i, base_binfo); i++)
++      {
++	  VEC(constructor_elt,gc) *vtable;
++	  tree vtable_tree = get_vtbl_decl_for_binfo (TYPE_BINFO (BINFO_TYPE (base_binfo)));
++	  if (!vtable_tree)
++	    continue;
++	  vtable = CONSTRUCTOR_ELTS (DECL_INITIAL (vtable_tree));
++	  vtdecompose_frags (TYPE_BINFO (BINFO_TYPE (base_binfo)), vtable, &src_frags);
++      }
++    fprintf (stderr, "dest:\n");
++    debug_fragments (dest_frags);
++    fprintf (stderr, "src:\n");
++    debug_fragments (src_frags);
++
++    if (inits) {
++      tree new_inits = compare_build_vtrelocs (t, vinits, dest_frags, src_frags);
++      if (new_inits)
++	{
++	  fprintf (stderr, "Use new inits !\n");
++	  inits = new_inits;
++	}
+     }
+ 
++    vec_heap_free (dest_frags);
++    vec_heap_free (src_frags);
 +  }
++
+   if (BINFO_VTABLE (TYPE_BINFO (t)))
+-    initialize_vtable (TYPE_BINFO (t), TREE_VALUE (list));
++    initialize_vtable (TYPE_BINFO (t), inits);
  }
  
  /* Initialize the vtable for BINFO with the INITS.  */
-@@ -6945,6 +7197,7 @@
+@@ -6945,6 +7486,7 @@
    tree inits;
    tree id;
    tree vbase;
@@ -359,7 +648,7 @@
  
    /* See if we've already created this construction vtable group.  */
    id = mangle_ctor_vtbl_for_type (t, binfo);
-@@ -6955,11 +7208,13 @@
+@@ -6955,11 +7497,13 @@
    /* Build a version of VTBL (with the wrong type) for use in
       constructing the addresses of secondary vtables in the
       construction vtable group.  */
@@ -374,7 +663,7 @@
  
    /* Add the vtables for each of our virtual bases using the vbase in T
       binfo.  */
-@@ -6973,7 +7228,7 @@
+@@ -6973,7 +7517,7 @@
  	continue;
        b = copied_binfo (vbase, binfo);
  
@@ -383,7 +672,7 @@
      }
    inits = TREE_VALUE (list);
  
-@@ -6986,6 +7241,11 @@
+@@ -6986,6 +7530,11 @@
    CLASSTYPE_VTABLES (t) = chainon (CLASSTYPE_VTABLES (t), vtbl);
    initialize_artificial_var (vtbl, inits);
    dump_vtable (t, binfo, vtbl);
@@ -395,7 +684,7 @@
  }
  
  /* Add the vtbl initializers for BINFO (and its bases other than
-@@ -7003,7 +7263,8 @@
+@@ -7003,7 +7552,8 @@
  		       tree orig_binfo,
  		       tree rtti_binfo,
  		       tree t,
@@ -405,7 +694,7 @@
  {
    int i;
    tree base_binfo;
-@@ -7026,7 +7287,7 @@
+@@ -7026,7 +7576,7 @@
    TREE_VALUE (inits)
      = chainon (TREE_VALUE (inits),
  	       dfs_accumulate_vtbl_inits (binfo, orig_binfo,
@@ -414,7 +703,7 @@
  
    /* Walk the BINFO and its bases.  We walk in preorder so that as we
       initialize each vtable we can figure out at what offset the
-@@ -7041,7 +7302,7 @@
+@@ -7041,7 +7591,7 @@
        accumulate_vtbl_inits (base_binfo,
  			     BINFO_BASE_BINFO (orig_binfo, i),
  			     rtti_binfo, t,
@@ -423,7 +712,7 @@
      }
  }
  
-@@ -7053,7 +7314,8 @@
+@@ -7053,7 +7603,8 @@
  			   tree orig_binfo,
  			   tree rtti_binfo,
  			   tree t,
@@ -433,7 +722,7 @@
  {
    tree inits = NULL_TREE;
    tree vtbl = NULL_TREE;
-@@ -7120,7 +7382,7 @@
+@@ -7120,7 +7671,7 @@
  
        /* Compute the initializer for this vtable.  */
        inits = build_vtbl_initializer (binfo, orig_binfo, t, rtti_binfo,
@@ -442,7 +731,7 @@
  
        /* Figure out the position to which the VPTR should point.  */
        vtbl = TREE_PURPOSE (l);
-@@ -7184,7 +7446,8 @@
+@@ -7184,7 +7735,8 @@
  			tree orig_binfo,
  			tree t,
  			tree rtti_binfo,
@@ -452,7 +741,7 @@
  {
    tree v, b;
    tree vfun_inits;
-@@ -7192,6 +7455,8 @@
+@@ -7192,6 +7744,8 @@
    unsigned ix;
    tree vbinfo;
    VEC(tree,gc) *vbases;
@@ -461,7 +750,7 @@
  
    /* Initialize VID.  */
    memset (&vid, 0, sizeof (vid));
-@@ -7213,7 +7478,7 @@
+@@ -7213,7 +7767,7 @@
       signature, we share the vcall offsets.  */
    vid.fns = VEC_alloc (tree, gc, 32);
    /* Add the vcall and vbase offset entries.  */
@@ -470,7 +759,7 @@
  
    /* Clear BINFO_VTABLE_PATH_MARKED; it's set by
       build_vbase_offset_vtbl_entries.  */
-@@ -7240,20 +7505,62 @@
+@@ -7240,20 +7794,62 @@
  	}
      }
  
@@ -535,7 +824,7 @@
        fn_original = fn;
        if (DECL_THUNK_P (fn))
  	{
-@@ -7281,7 +7588,10 @@
+@@ -7281,7 +7877,10 @@
  	{
  	  /* We found a defn before a lost primary; go ahead as normal.  */
  	  if (look_for_overrides_here (BINFO_TYPE (b), fn_original))
@@ -547,7 +836,7 @@
  
  	  /* The nearest definition is from a lost primary; clear the
  	     slot.  */
-@@ -7299,6 +7609,9 @@
+@@ -7299,6 +7898,9 @@
  	  delta = BV_DELTA (v);
  	  vcall_index = BV_VCALL_INDEX (v);
  
@@ -557,11 +846,8 @@
  	  gcc_assert (TREE_CODE (delta) == INTEGER_CST);
  	  gcc_assert (TREE_CODE (fn) == FUNCTION_DECL);
  
-@@ -7313,15 +7626,60 @@
- 	    }
- 	  else
+@@ -7315,13 +7917,57 @@
  	    {
-+	      // FIXME: switched these around !
  	      if (!integer_zerop (delta) || vcall_index)
  		{
 -		  fn = make_thunk (fn, /*this_adjusting=*/1, delta, vcall_index);
@@ -574,7 +860,7 @@
 +					  vtable_entry_type,
 +					  build_int_cst (build_pointer_type (void_type_node),
 +							 0xdeadf000));
-+		      fprintf (stderr,"inherited thunk!\n");
++/* 		      fprintf (stderr,"inherited thunk!\n"); */
 +		    }
 +		  else
 +		    {
@@ -600,7 +886,7 @@
 +                                     build_int_cst (build_pointer_type (void_type_node),
 +                                                    0xdeadbeef));
 +               }
-+              fprintf (stderr, " %s : ",
++	      /*              fprintf (stderr, " %s : ",
 +                       expr_as_string (fn, TFF_PLAIN_IDENTIFIER));
 +              fprintf (stderr, " %s !=? ",
 +                       type_as_string (BINFO_TYPE (first_overrider), TFF_PLAIN_IDENTIFIER));
@@ -613,7 +899,7 @@
 +                       BINFO_INHERITANCE_CHAIN (t),
 +                       BINFO_INHERITANCE_CHAIN (binfo),
 +                       BINFO_INHERITANCE_CHAIN (orig_binfo),
-+                       BINFO_INHERITANCE_CHAIN (rtti_binfo));
++                       BINFO_INHERITANCE_CHAIN (rtti_binfo)); */
 +
 +              if (!init)
 +                {
@@ -624,7 +910,7 @@
  	    }
  	}
  
-@@ -7346,8 +7704,71 @@
+@@ -7346,8 +7992,71 @@
  	}
        else
  	vfun_inits = tree_cons (NULL_TREE, init, vfun_inits);
@@ -643,33 +929,33 @@
 +      unsigned i;
 +      tree copy_parent = orig_binfo, iter = orig_binfo;
 +
-+      fprintf (stderr, "Find copy parent for (%s)\n",
-+	       type_as_string (BINFO_TYPE (iter), TFF_PLAIN_IDENTIFIER));
++/*      fprintf (stderr, "Find copy parent for (%s)\n",
++	      type_as_string (BINFO_TYPE (iter), TFF_PLAIN_IDENTIFIER)); */
 +      if (orig_binfo == TYPE_BINFO (t))
 +          copy_parent = get_primary_binfo (orig_binfo);
 +      else {
 +	while (iter != TYPE_BINFO (t)) {
 +	  copy_parent = iter;
 +	  iter = BINFO_INHERITANCE_CHAIN (iter);
-+	  fprintf (stderr, "\tUp a class (%s)\n",
-+		   type_as_string (BINFO_TYPE (iter), TFF_PLAIN_IDENTIFIER));
++	  /*	  fprintf (stderr, "\tUp a class (%s)\n",
++		  type_as_string (BINFO_TYPE (iter), TFF_PLAIN_IDENTIFIER)); */
 +	}
 +      }
-+      fprintf (stderr, "\tresult: (%s) %p\n",
++      /*      fprintf (stderr, "\tresult: (%s) %p\n",
 +	       copy_parent ? type_as_string (BINFO_TYPE (copy_parent), TFF_PLAIN_IDENTIFIER) : "<null>",
-+	       copy_parent);
-+      //#error this is more like it !..
++	       copy_parent); */
++
 +      /* FIXME: we want to walk up 'get_primary_binfo' ...
 +	 until we hit the type ... then take the 'last' entry.
 +	 Then we need to collate this with the last entry on
 +	 *slot_relocs if it has the same type ... */
 +
 +      /* We screwed up somehow ? */
-+      if (copy_parent) 
++      /*      if (copy_parent) 
 +	{
 +	  fprintf (stderr, "Copying from:\n");
 +	  debug_class (BINFO_TYPE (copy_parent));
-+	}
++	  } */
 +
 +      slot_reloc_data = nreverse (slot_reloc_data);
 +
@@ -679,7 +965,7 @@
 +				     slot_reloc_data);
 +
 +      if (*slot_relocs && TREE_PURPOSE(*slot_relocs) == copy_parent)
-+	{ // append to that ...
++	{ /* append to that ... */
 +#warning badness happens here.
 +	  /* FIXME: internal entries have fewer slots ? - magic minus one ... */
 +
@@ -696,7 +982,7 @@
    /* The initializers for virtual functions were built up in reverse
       order; straighten them out now.  */
    vfun_inits = nreverse (vfun_inits);
-@@ -7363,7 +7784,8 @@
+@@ -7363,7 +8072,8 @@
     offsets in BINFO, which is in the hierarchy dominated by T.  */
  
  static void
@@ -706,7 +992,7 @@
  {
    tree b;
  
-@@ -7371,10 +7793,17 @@
+@@ -7371,10 +8081,17 @@
       corresponding to the primary base class.  */
    b = get_primary_binfo (binfo);
    if (b)
@@ -972,13 +1258,13 @@
  tree
 diff -u -r -x '*~' -x testsuite -x libjava -x cc-nptl -x build-dir -x '*.orig' -x obj-i586-suse-linux -x texis -x Makeconfig -x version.h -x '*.o' -x '*.1' -x 'Makefile*' -x 'config*' -x libtool -x '*.info' -x '*.tex' pristine-gcc-4.2.1-simple/gcc/cp/method.c gcc-4.2.1-simple/gcc/cp/method.c
 --- pristine-gcc-4.2.1-simple/gcc/cp/method.c	2006-12-11 12:16:19.000000000 +0000
-+++ gcc-4.2.1-simple/gcc/cp/method.c	2008-01-18 15:26:30.000000000 +0000
++++ gcc-4.2.1-simple/gcc/cp/method.c	2008-01-21 16:10:01.000000000 +0000
 @@ -169,6 +169,9 @@
    TREE_CHAIN (thunk) = DECL_THUNKS (function);
    DECL_THUNKS (function) = thunk;
  
-+  fprintf (stderr, "make_thunk for '%s'\n",
-+	   decl_as_string (function, TFF_PLAIN_IDENTIFIER));
++  /*  fprintf (stderr, "make_thunk for '%s'\n",
++      decl_as_string (function, TFF_PLAIN_IDENTIFIER)); */
 +
    return thunk;
  }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]