|
From: <sv...@va...> - 2005-10-12 16:16:07
|
Author: sewardj
Date: 2005-10-12 17:16:03 +0100 (Wed, 12 Oct 2005)
New Revision: 4912
Log:
Get rid of bbSeenBefore and associated logic: it appears to be
irrelevant.
Modified:
trunk/cachegrind/cg_main.c
Modified: trunk/cachegrind/cg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/cachegrind/cg_main.c 2005-10-12 12:53:20 UTC (rev 4911)
+++ trunk/cachegrind/cg_main.c 2005-10-12 16:16:03 UTC (rev 4912)
@@ -471,9 +471,6 @@
/* Number instr_info bins 'used' so far. */
Int bbInfo_i;
=20
- /* Not sure what this is for (jrs 20051009) */
- Bool bbSeenBefore;
-
/* The output BB being constructed. */
IRBB* bbOut;
}
@@ -485,7 +482,7 @@
/*------------------------------------------------------------*/
=20
static
-BB_info* get_BB_info(IRBB* bbIn, Addr origAddr, /*OUT*/Bool* bbSeenBefor=
e)
+BB_info* get_BB_info(IRBB* bbIn, Addr origAddr)
{
Int i, n_instrs;
IRStmt* st;
@@ -498,42 +495,32 @@
if (Ist_IMark =3D=3D st->tag) n_instrs++;
}
=20
- // Get the BB_info
+ // Check that the BB has never been translated before. If this
+ // assertion fails, there has been some screwup in translation
+ // discard/invalidation management.
bbInfo =3D (BB_info*)VG_(HT_lookup)(instr_info_table, origAddr);
- *bbSeenBefore =3D ( NULL =3D=3D bbInfo ? False : True );
- if (*bbSeenBefore) {
- // BB must have been translated before, but flushed from the TT
- tl_assert(bbInfo->n_instrs =3D=3D n_instrs );
- BB_retranslations++;
- } else {
- // BB never translated before (at this address, at least; could h=
ave
- // been unloaded and then reloaded elsewhere in memory)
- bbInfo =3D VG_(calloc)(1, sizeof(BB_info) + n_instrs*sizeof(instr_=
info));=20
- bbInfo->BB_addr =3D origAddr;
- bbInfo->n_instrs =3D n_instrs;
- VG_(HT_add_node)( instr_info_table, (VgHashNode*)bbInfo );
- distinct_instrs++;
- }
+ tl_assert(NULL =3D=3D bbInfo);
+
+ // BB has never translated before (at this address, at least; could
+ // have been unloaded and then reloaded elsewhere in memory).
+ bbInfo =3D VG_(calloc)(1, sizeof(BB_info) + n_instrs*sizeof(instr_inf=
o));=20
+ bbInfo->BB_addr =3D origAddr;
+ bbInfo->n_instrs =3D n_instrs;
+ VG_(HT_add_node)( instr_info_table, (VgHashNode*)bbInfo );
+ distinct_instrs++;
+
return bbInfo;
}
=20
=20
static
-void init_instr_info( instr_info* n, Bool bbSeenBefore,
+void init_instr_info( /*OUT*/instr_info* n,=20
Addr instr_addr, Int instr_len )
{
- if (bbSeenBefore) {
- tl_assert( n->instr_addr =3D=3D instr_addr );
- tl_assert( n->instr_len =3D=3D instr_len );
- // Don't check that (n->parent =3D=3D parent)... it's conceivable =
that
- // the debug info might change; the other asserts should be enoug=
h to
- // detect anything strange.
- } else {
- lineCC* parent =3D get_lineCC(instr_addr);
- n->instr_addr =3D instr_addr;
- n->instr_len =3D instr_len;
- n->parent =3D parent;
- }
+ lineCC* parent =3D get_lineCC(instr_addr);
+ n->instr_addr =3D instr_addr;
+ n->instr_len =3D instr_len;
+ n->parent =3D parent;
}
=20
static void showEvent ( Event* ev )
@@ -634,7 +621,7 @@
/* allocate an instr_info and fill in its addr/size. */
i_node =3D reserve_instr_info( cgs );
tl_assert(i_node);
- init_instr_info( i_node, cgs->bbSeenBefore,
+ init_instr_info( i_node,
(Addr)cgs->events[i].iaddr, /* i addr */
cgs->events[i].size /* i size */);
} else {
@@ -690,14 +677,14 @@
=20
i_node2 =3D reserve_instr_info( cgs );
tl_assert(i_node2);
- init_instr_info( i_node2, cgs->bbSeenBefore,
+ init_instr_info( i_node2,
(Addr)cgs->events[i+1].iaddr, /* i addr =
*/
cgs->events[i+1].size /* i size */);
i_node2_expr =3D mkIRExpr_HWord( (HWord)i_node2 );
=20
i_node3 =3D reserve_instr_info( cgs );
tl_assert(i_node3);
- init_instr_info( i_node3, cgs->bbSeenBefore,
+ init_instr_info( i_node3,
(Addr)cgs->events[i+2].iaddr, /* i addr =
*/
cgs->events[i+2].size /* i size */);
i_node3_expr =3D mkIRExpr_HWord( (HWord)i_node3 );
@@ -714,7 +701,7 @@
helperAddr =3D &log_2I_0D_cache_access;
i_node2 =3D reserve_instr_info( cgs );
tl_assert(i_node2);
- init_instr_info( i_node2, cgs->bbSeenBefore,
+ init_instr_info( i_node2,
(Addr)cgs->events[i+1].iaddr, /* i addr =
*/
cgs->events[i+1].size /* i size */);
i_node2_expr =3D mkIRExpr_HWord( (HWord)i_node2 );
@@ -860,7 +847,7 @@
=20
// Set up running state and get block info
cgs.events_used =3D 0;
- cgs.bbInfo =3D get_BB_info(bbIn, (Addr)cia, &cgs.bbSeenBefore);
+ cgs.bbInfo =3D get_BB_info(bbIn, (Addr)cia);
cgs.bbInfo_i =3D 0;
=20
if (DEBUG_CG)
@@ -1328,7 +1315,9 @@
/*--- Discarding BB info ---*/
/*--------------------------------------------------------------------*/
=20
-// Called when a translation is invalidated due to code unloading.
+// Called when a translation is removed from the translation cache for
+// any reason at all: to free up space, because the guest code was
+// unmapped or modified, or for any arbitrary reason.
static void cg_discard_basic_block_info ( VexGuestExtents vge )
{
VgHashNode* bbInfo;
|