From eeed93083e73396985d8ade7d90006021b517315 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 11 Dec 2023 15:06:52 +0300 Subject: [PATCH] Restore ability to reach "local" exit table base address --- ir.h | 3 ++- ir_aarch64.dasc | 13 +++++++++++-- ir_private.h | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ir.h b/ir.h index c9a9a31..8443514 100644 --- a/ir.h +++ b/ir.h @@ -547,7 +547,7 @@ struct _ir_ctx { ir_ref consts_count; /* number of constants stored in constants buffer */ ir_ref consts_limit; /* size of allocated constants buffer (it's extended when overflow) */ uint32_t flags; /* IR context flags (see IR_* defines above) */ - uint32_t flags2; /* IR context provate flags (see IR_* defines in ir_private.h) */ + uint32_t flags2; /* IR context private flags (see IR_* defines in ir_private.h) */ ir_type ret_type; /* Function return type */ uint32_t mflags; /* CPU specific flags (see IR_X86_... macros below) */ int32_t status; /* non-zero error code (see IR_ERROR_... macros), app may use negative codes */ @@ -602,6 +602,7 @@ struct _ir_ctx { ir_code_buffer *code_buffer; #if defined(IR_TARGET_AARCH64) int32_t deoptimization_exits; + const void *deoptimization_exits_base; ir_get_exit_addr_t get_exit_addr; ir_get_veneer_t get_veneer; ir_set_veneer_t set_veneer; diff --git a/ir_aarch64.dasc b/ir_aarch64.dasc index afb4885..ae156ed 100644 --- a/ir_aarch64.dasc +++ b/ir_aarch64.dasc @@ -5349,8 +5349,8 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) dasm_init(&data.dasm_state, DASM_MAXSECTION); dasm_setupglobal(&data.dasm_state, dasm_labels, ir_lb_MAX); dasm_setup(&data.dasm_state, dasm_actions); - /* labels for each block + for each constant + rodata label + jmp_table label + for each entry */ - dasm_growpc(&data.dasm_state, ctx->cfg_blocks_count + 1 + ctx->consts_count + 1 + 1 + 1 + ctx->entries_count); + /* labels for each block + for each constant + rodata label + jmp_table label + for each entry + exit_table label */ + dasm_growpc(&data.dasm_state, ctx->cfg_blocks_count + 1 + ctx->consts_count + 1 + 1 + 1 + ctx->entries_count + 1); data.emit_constants = ir_bitset_malloc(ctx->consts_count); if (!(ctx->flags & IR_SKIP_PROLOGUE)) { @@ -5607,6 +5607,9 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) } if (ctx->deoptimization_exits) { + uint32_t exit_table_label = ctx->cfg_blocks_count + 1 + ctx->consts_count + 1 + 1 + 1 + ctx->entries_count; + + |=>exit_table_label: for (i = 0; i < ctx->deoptimization_exits; i++) { const void *exit_addr = ctx->get_exit_addr(i); @@ -5757,6 +5760,12 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) ir_mem_unprotect(entry, size); } + if (ctx->deoptimization_exits) { + uint32_t exit_table_label = ctx->cfg_blocks_count + 1 + ctx->consts_count + 1 + 1 + 1 + ctx->entries_count; + + ctx->deoptimization_exits_base = (const void*)((char*)entry + dasm_getpclabel(&data.dasm_state, exit_table_label)); + } + ir_current_ctx = ctx; ret = dasm_encode(&data.dasm_state, entry); if (ret != DASM_S_OK) { diff --git a/ir_private.h b/ir_private.h index bd3e7c6..1caa029 100644 --- a/ir_private.h +++ b/ir_private.h @@ -904,6 +904,8 @@ IR_ALWAYS_INLINE uint32_t ir_insn_len(const ir_insn *insn) #define IR_RA_HAVE_SPLITS (1<<25) #define IR_RA_HAVE_SPILLS (1<<26) +#define IR_RESERVED_FLAG_1 (1U<<31) + /*** IR Binding ***/ IR_ALWAYS_INLINE ir_ref ir_binding_find(const ir_ctx *ctx, ir_ref ref) {