Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
snej opened this issue Jun 16, 2021 · 0 comments
Open

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

snej opened this issue Jun 16, 2021 · 0 comments

Comments

@snej
Copy link
Owner

snej commented Jun 16, 2021

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?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant