Skip to content

Commit

Permalink
tcg: Restart TB generation after constant pool overflow
Browse files Browse the repository at this point in the history
This is part b of relocation overflow handling.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Apr 24, 2019
1 parent 7ecd02a commit 1768987
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 7 additions & 5 deletions tcg/tcg-pool.inc.c
Expand Up @@ -121,14 +121,14 @@ static inline void new_pool_l8(TCGContext *s, int rtype, tcg_insn_unit *label,
/* To be provided by cpu/tcg-target.inc.c. */
static void tcg_out_nop_fill(tcg_insn_unit *p, int count);

static bool tcg_out_pool_finalize(TCGContext *s)
static int tcg_out_pool_finalize(TCGContext *s)
{
TCGLabelPoolData *p = s->pool_labels;
TCGLabelPoolData *l = NULL;
void *a;

if (p == NULL) {
return true;
return 0;
}

/* ??? Round up to qemu_icache_linesize, but then do not round
Expand All @@ -142,15 +142,17 @@ static bool tcg_out_pool_finalize(TCGContext *s)
size_t size = sizeof(tcg_target_ulong) * p->nlong;
if (!l || l->nlong != p->nlong || memcmp(l->data, p->data, size)) {
if (unlikely(a > s->code_gen_highwater)) {
return false;
return -1;
}
memcpy(a, p->data, size);
a += size;
l = p;
}
patch_reloc(p->label, p->rtype, (intptr_t)a - size, p->addend);
if (!patch_reloc(p->label, p->rtype, (intptr_t)a - size, p->addend)) {
return -2;
}
}

s->code_ptr = a;
return true;
return 0;
}
9 changes: 5 additions & 4 deletions tcg/tcg.c
Expand Up @@ -1019,8 +1019,8 @@ void tcg_prologue_init(TCGContext *s)
#ifdef TCG_TARGET_NEED_POOL_LABELS
/* Allow the prologue to put e.g. guest_base into a pool entry. */
{
bool ok = tcg_out_pool_finalize(s);
tcg_debug_assert(ok);
int result = tcg_out_pool_finalize(s);
tcg_debug_assert(result == 0);
}
#endif

Expand Down Expand Up @@ -4005,8 +4005,9 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
}
#endif
#ifdef TCG_TARGET_NEED_POOL_LABELS
if (!tcg_out_pool_finalize(s)) {
return -1;
i = tcg_out_pool_finalize(s);
if (i < 0) {
return i;
}
#endif
if (!tcg_resolve_relocs(s)) {
Expand Down

0 comments on commit 1768987

Please sign in to comment.