Skip to content

Commit

Permalink
[mini] arm64: Add some more space for tailcall opcodes (#102092)
Browse files Browse the repository at this point in the history
It looks like in some circumstances 255 bytes isn't enough.
255 is encoded in cpu-arm64.mdesc that only uses a uint8 for the
max instruction length.

Fixes #102086
  • Loading branch information
lambdageek authored May 10, 2024
1 parent 9eac175 commit dc98263
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mono/mono/mini/mini-arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -5398,6 +5398,13 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
g_assert (!cfg->method->save_lmf);

max_len += call->stack_usage / sizeof (target_mgreg_t) * ins_get_size (OP_TAILCALL_PARAMETER);
// HACK: In cpu-arm64.mdesc the tailcall opcodes have a len of 255, which is
// arbitrary, but it's the max uint8 value. It looks like in some
// circumstances we need more space than that.
//
// Add some more space to acount for mono_arm_emit_destroy_frame and
// emit_load_regset, below
max_len += 64;
while (G_UNLIKELY (offset + max_len > cfg->code_size)) {
cfg->code_size *= 2;
cfg->native_code = (unsigned char *)mono_realloc_native_code (cfg);
Expand Down

0 comments on commit dc98263

Please sign in to comment.