drd: Add a consistency check
[valgrind.git] / coregrind / pub_core_transtab.h
blob2c91cfabd4af0723e140e166bf55de32da1115ae
2 /*--------------------------------------------------------------------*/
3 /*--- The translation table and cache. ---*/
4 /*--- pub_core_transtab.h ---*/
5 /*--------------------------------------------------------------------*/
7 /*
8 This file is part of Valgrind, a dynamic binary instrumentation
9 framework.
11 Copyright (C) 2000-2013 Julian Seward
12 jseward@acm.org
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 02111-1307, USA.
29 The GNU General Public License is contained in the file COPYING.
32 #ifndef __PUB_CORE_TRANSTAB_H
33 #define __PUB_CORE_TRANSTAB_H
35 //--------------------------------------------------------------------
36 // PURPOSE: This module is responsible for caching translations, and
37 // enabling fast look-ups of them.
38 //--------------------------------------------------------------------
40 #include "pub_core_transtab_asm.h"
41 #include "libvex.h" // VexGuestExtents
43 /* The fast-cache for tt-lookup. Unused entries are denoted by .guest
44 == 1, which is assumed to be a bogus address for all guest code. */
45 typedef
46 struct {
47 Addr guest;
48 Addr host;
50 FastCacheEntry;
52 extern __attribute__((aligned(16)))
53 FastCacheEntry VG_(tt_fast) [VG_TT_FAST_SIZE];
55 #define TRANSTAB_BOGUS_GUEST_ADDR ((Addr)1)
58 /* Initialises the TC, using VG_(clo_num_transtab_sectors).
59 VG_(clo_num_transtab_sectors) must be >= MIN_N_SECTORS
60 and <= MAX_N_SECTORS. */
61 extern void VG_(init_tt_tc) ( void );
64 /* Limits for number of sectors the TC is divided into. If you need a larger
65 overall translation cache, increase MAX_N_SECTORS. */
66 #define MIN_N_SECTORS 2
67 #define MAX_N_SECTORS 24
69 /* Default for the nr of sectors, if not overriden by command line.
70 On Android, space is limited, so try to get by with fewer sectors.
71 On other platforms we can go to town. 16 sectors gives theoretical
72 capacity of about 440MB of JITted code in 1.05 million translations
73 (realistically, about 2/3 of that) for Memcheck. */
74 #if defined(VGPV_arm_linux_android) \
75 || defined(VGPV_x86_linux_android) \
76 || defined(VGPV_mips32_linux_android) \
77 || defined(VGPV_arm64_linux_android)
78 # define N_SECTORS_DEFAULT 6
79 #else
80 # define N_SECTORS_DEFAULT 16
81 #endif
83 extern
84 void VG_(add_to_transtab)( const VexGuestExtents* vge,
85 Addr64 entry,
86 AddrH code,
87 UInt code_len,
88 Bool is_self_checking,
89 Int offs_profInc,
90 UInt n_guest_instrs );
92 extern
93 void VG_(tt_tc_do_chaining) ( void* from__patch_addr,
94 UInt to_sNo,
95 UInt to_tteNo,
96 Bool to_fastEP );
98 extern Bool VG_(search_transtab) ( /*OUT*/AddrH* res_hcode,
99 /*OUT*/UInt* res_sNo,
100 /*OUT*/UInt* res_tteNo,
101 Addr64 guest_addr,
102 Bool upd_cache );
104 extern void VG_(discard_translations) ( Addr64 start, ULong range,
105 const HChar* who );
107 extern void VG_(print_tt_tc_stats) ( void );
109 extern UInt VG_(get_bbs_translated) ( void );
111 /* Add to / search the auxiliary, small, unredirected translation
112 table. */
114 extern
115 void VG_(add_to_unredir_transtab)( const VexGuestExtents* vge,
116 Addr64 entry,
117 AddrH code,
118 UInt code_len );
119 extern
120 Bool VG_(search_unredir_transtab) ( /*OUT*/AddrH* result,
121 Addr64 guest_addr );
123 // SB profiling stuff
125 typedef struct _SBProfEntry {
126 Addr64 addr;
127 ULong score;
128 } SBProfEntry;
130 extern ULong VG_(get_SB_profile) ( SBProfEntry tops[], UInt n_tops );
132 #endif // __PUB_CORE_TRANSTAB_H
134 /*--------------------------------------------------------------------*/
135 /*--- end ---*/
136 /*--------------------------------------------------------------------*/