Skip to content

INTERP doesn't tail-recurse w/Clang 12 #4

@snej

Description

@snej

The current macOS x86-64 machine code for INTERP is:

0000000100011950	pushq	%rbx
0000000100011951	movq	%rdi, %rbx
0000000100011954	movq	(%rdi), %rax
0000000100011957	leaq	0x8(%rax), %rdi
000000010001195b	callq	*(%rax)
000000010001195d	testq	%rax, %rax
0000000100011960	je	0x10001196e
0000000100011962	leaq	0x10(%rbx), %rdi
0000000100011966	movq	%rax, %rsi
0000000100011969	callq	*0x8(%rbx)
000000010001196c	popq	%rbx
000000010001196d	retq
000000010001196e	xorl	%eax, %eax
0000000100011970	popq	%rbx
0000000100011971	retq

The call to the next word (at 01969) isn't tail-call optimized. That means the stack will grow as multiple INTERPs are called.

This should be fixed when built with a Clang that supports the musttail attribute (Clang 13?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions