Lines Matching refs:tb
55 /* make various TB consistency checks */
63 /* TB consistency checks only implemented for usermode emulation. */
679 TranslationBlock *tb;
683 for(tb = tb_phys_hash[i]; tb != NULL; tb = tb->phys_hash_next) {
684 if (!(address + TARGET_PAGE_SIZE <= tb->pc ||
685 address >= tb->pc + tb->size)) {
688 address, (long)tb->pc, tb->size);
697 TranslationBlock *tb;
701 for(tb = tb_phys_hash[i]; tb != NULL; tb = tb->phys_hash_next) {
702 flags1 = page_get_flags(tb->pc);
703 flags2 = page_get_flags(tb->pc + tb->size - 1);
706 (long)tb->pc, tb->size, flags1, flags2);
714 /* invalidate one TB */
715 static inline void tb_remove(TranslationBlock **ptb, TranslationBlock *tb,
721 if (tb1 == tb) {
729 static inline void tb_page_remove(TranslationBlock **ptb, TranslationBlock *tb)
738 if (tb1 == tb) {
746 static inline void tb_jmp_remove(TranslationBlock *tb, int n)
751 ptb = &tb->jmp_next[n];
754 /* find tb(n) in circular list */
759 if (n1 == n && tb1 == tb)
767 /* now we can suppress tb(n) from the list */
768 *ptb = tb->jmp_next[n];
770 tb->jmp_next[n] = NULL;
774 /* reset the jump entry 'n' of a TB so that it is not chained to
775 another TB */
776 static inline void tb_reset_jump(TranslationBlock *tb, int n)
778 tb_set_jmp_target(tb, n, (unsigned long)(tb->tc_ptr + tb->tb_next_offset[n]));
781 void tb_phys_invalidate(TranslationBlock *tb, target_ulong page_addr)
789 /* remove the TB from the hash list */
790 phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
792 tb_remove(&tb_phys_hash[h], tb,
795 /* remove the TB from the page list */
796 if (tb->page_addr[0] != page_addr) {
797 p = page_find(tb->page_addr[0] >> TARGET_PAGE_BITS);
798 tb_page_remove(&p->first_tb, tb);
801 if (tb->page_addr[1] != -1 && tb->page_addr[1] != page_addr) {
802 p = page_find(tb->page_addr[1] >> TARGET_PAGE_BITS);
803 tb_page_remove(&p->first_tb, tb);
809 /* remove the TB from the hash list */
810 h = tb_jmp_cache_hash_func(tb->pc);
812 if (env->tb_jmp_cache[h] == tb)
816 /* suppress this TB from the two jump lists */
817 tb_jmp_remove(tb, 0);
818 tb_jmp_remove(tb, 1);
820 /* suppress any remaining jumps to this TB */
821 tb1 = tb->jmp_first;
832 tb->jmp_first = (TranslationBlock *)((long)tb | 2); /* fail safe */
835 if (tb->tpc2gpc != NULL) {
836 qemu_free(tb->tpc2gpc);
837 tb->tpc2gpc = NULL;
838 tb->tpc2gpc_pairs = 0;
875 TranslationBlock *tb;
879 tb = p->first_tb;
880 while (tb != NULL) {
881 n = (long)tb & 3;
882 tb = (TranslationBlock *)((long)tb & ~3);
883 /* NOTE: this is subtle as a TB may span two physical pages */
887 tb_start = tb->pc & ~TARGET_PAGE_MASK;
888 tb_end = tb_start + tb->size;
893 tb_end = ((tb->pc + tb->size) & ~TARGET_PAGE_MASK);
896 tb = tb->page_next[n];
904 TranslationBlock *tb;
910 tb = tb_alloc(pc);
911 if (!tb) {
915 tb = tb_alloc(pc);
916 /* Don't forget to invalidate previous TB info. */
920 tb->tc_ptr = tc_ptr;
921 tb->cs_base = cs_base;
922 tb->flags = flags;
923 tb->cflags = cflags;
925 tb->bb_rec = NULL;
926 tb->prev_time = 0;
928 cpu_gen_code(env, tb, &code_gen_size);
932 virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
937 tb_link_phys(tb, phys_pc, phys_page2);
938 return tb;
945 TB if code is modified inside this TB. */
949 TranslationBlock *tb, *tb_next, *saved_tb;
975 tb = p->first_tb;
976 while (tb != NULL) {
977 n = (long)tb & 3;
978 tb = (TranslationBlock *)((long)tb & ~3);
979 tb_next = tb->page_next[n];
980 /* NOTE: this is subtle as a TB may span two physical pages */
984 tb_start = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
985 tb_end = tb_start + tb->size;
987 tb_start = tb->page_addr[1];
988 tb_end = tb_start + ((tb->pc + tb->size) & ~TARGET_PAGE_MASK);
1000 if (current_tb == tb &&
1002 /* If we are modifying the current TB, we must stop
1021 tb_phys_invalidate(tb, -1);
1028 tb = tb_next;
1082 TranslationBlock *tb;
1098 tb = p->first_tb;
1100 if (tb && pc != 0) {
1104 while (tb != NULL) {
1105 n = (long)tb & 3;
1106 tb = (TranslationBlock *)((long)tb & ~3);
1108 if (current_tb == tb &&
1110 /* If we are modifying the current TB, we must stop
1122 tb_phys_invalidate(tb, addr);
1123 tb = tb->page_next[n];
1139 /* add the tb in the target page and protect it if necessary */
1140 static inline void tb_alloc_page(TranslationBlock *tb,
1146 tb->page_addr[n] = page_addr;
1148 tb->page_next[n] = p->first_tb;
1150 p->first_tb = (TranslationBlock *)((long)tb | n);
1184 protected. So we handle the case where only the first TB is
1198 TranslationBlock *tb;
1203 tb = &tbs[nb_tbs++];
1204 tb->pc = pc;
1205 tb->cflags = 0;
1207 tb->tpc2gpc = NULL;
1208 tb->tpc2gpc_pairs = 0;
1210 return tb;
1213 void tb_free(TranslationBlock *tb)
1215 /* In practice this is mostly used for single use temporary TB
1216 Ignore the hard cases and just back up if this TB happens to
1218 if (nb_tbs > 0 && tb == &tbs[nb_tbs - 1]) {
1219 code_gen_ptr = tb->tc_ptr;
1224 /* add a new TB and link it to the physical page tables. phys_page2 is
1225 (-1) to indicate that only one page contains the TB. */
1226 void tb_link_phys(TranslationBlock *tb,
1232 /* Grab the mmap lock to stop another thread invalidating this TB
1238 tb->phys_hash_next = *ptb;
1239 *ptb = tb;
1242 tb_alloc_page(tb, 0, phys_pc & TARGET_PAGE_MASK);
1244 tb_alloc_page(tb, 1, phys_page2);
1246 tb->page_addr[1] = -1;
1248 tb->jmp_first = (TranslationBlock *)((long)tb | 2);
1249 tb->jmp_next[0] = NULL;
1250 tb->jmp_next[1] = NULL;
1253 if (tb->tb_next_offset[0] != 0xffff)
1254 tb_reset_jump(tb, 0);
1255 if (tb->tb_next_offset[1] != 0xffff)
1256 tb_reset_jump(tb, 1);
1264 /* find the TB 'tb' such that tb[0].tc_ptr <= tc_ptr <
1265 tb[1].tc_ptr. Return NULL if not found */
1270 TranslationBlock *tb;
1282 tb = &tbs[m];
1283 v = (unsigned long)tb->tc_ptr;
1285 return tb;
1295 static void tb_reset_jump_recursive(TranslationBlock *tb);
1297 static inline void tb_reset_jump_recursive2(TranslationBlock *tb, int n)
1302 tb1 = tb->jmp_next[n];
1312 /* we are now sure now that tb jumps to tb1 */
1315 /* remove tb from the jmp_first list */
1321 if (n1 == n && tb1 == tb)
1325 *ptb = tb->jmp_next[n];
1326 tb->jmp_next[n] = NULL;
1328 /* suppress the jump to next tb in generated code */
1329 tb_reset_jump(tb, n);
1331 /* suppress jumps in the tb on which we could have jumped */
1336 static void tb_reset_jump_recursive(TranslationBlock *tb)
1338 tb_reset_jump_recursive2(tb, 0);
1339 tb_reset_jump_recursive2(tb, 1);
1561 /* FIXME: TB unchaining isn't SMP safe. For now just ignore the
1565 TranslationBlock *tb;
1569 tb = env->current_tb;
1571 all the potentially executing TB */
1572 if (tb) {
1574 tb_reset_jump_recursive(tb);
1624 "show generated host assembly code for each compiled TB" },
1626 "show target assembly code for each compiled TB" },
1628 "show micro ops for each compiled TB" },
1638 "show trace before each executed TB (lots of logs)" },
1774 /* Discard jump cache entries for any tb which might potentially
1794 /* must reset current TB so that interrupts cannot modify the
1839 /* must reset current TB so that interrupts cannot modify the
2915 TranslationBlock *tb;
2921 /* We re-entered the check after replacing the TB. Now raise
2934 tb = tb_find_pc(env->mem_io_pc);
2935 if (!tb) {
2936 cpu_abort(env, "check_watchpoint: could not find TB for "
2939 cpu_restore_state(tb, env, env->mem_io_pc);
2940 tb_phys_invalidate(tb, -1);
3815 must be at the end of the TB */
3818 TranslationBlock *tb;
3823 tb = tb_find_pc((unsigned long)retaddr);
3824 if (!tb) {
3825 cpu_abort(env, "cpu_io_recompile: could not find TB for pc=%p",
3828 n = env->icount_decr.u16.low + tb->icount;
3829 cpu_restore_state(tb, env, (unsigned long)retaddr);
3833 /* Generate a new TB ending on the I/O insn. */
3836 they were already the first instruction in the TB. If this is not
3837 the first instruction in a TB then re-execute the preceding
3855 cpu_abort(env, "TB too big during recompile");
3858 pc = tb->pc;
3859 cs_base = tb->cs_base;
3860 flags = tb->flags;
3861 tb_phys_invalidate(tb, -1);
3865 /* TODO: If env->pc != tb->pc (i.e. the faulting instruction was not
3866 the first in the TB) then we end up generating a whole new TB and
3869 second new TB. */
3879 TranslationBlock *tb;
3887 tb = &tbs[i];
3888 target_code_size += tb->size;
3889 if (tb->size > max_target_code_size)
3890 max_target_code_size = tb->size;
3891 if (tb->page_addr[1] != -1)
3893 if (tb->tb_next_offset[0] != 0xffff) {
3895 if (tb->tb_next_offset[1] != 0xffff) {
3904 cpu_fprintf(f, "TB count %d/%d\n",
3906 cpu_fprintf(f, "TB avg target size %d max=%d bytes\n",
3909 cpu_fprintf(f, "TB avg host size %td bytes (expansion ratio: %0.1f)\n",
3912 cpu_fprintf(f, "cross page TB count %d (%d%%)\n",
3921 cpu_fprintf(f, "TB flush count %d\n", tb_flush_count);
3922 cpu_fprintf(f, "TB invalidate count %d\n", tb_phys_invalidate_count);