Skip to content

Conversation

serkm
Copy link
Contributor

@serkm serkm commented Jan 9, 2025

This reduces the size of frame headers for faster PushFrame/Return.
Non-linear handlers get slower though, because now there is an additional indirection for sharers/erasers.

@serkm
Copy link
Contributor Author

serkm commented Jan 9, 2025

I also moved vtables to function prefixes.
This removes one indirection for the first operator of an object.

Here are some benchmark results:
image

@b-studios
Copy link
Collaborator

How does this lead to an additional indirection? I would have assumed it would just be an additional offset computation.

@serkm
Copy link
Contributor Author

serkm commented Jan 27, 2025

Previously it was:
Load stack pointer -> add offset -> load sharer address

Now it is:
Load stack pointer -> add offset -> load return address -> add offset -> load sharer address

@b-studios
Copy link
Collaborator

b-studios commented Jan 27, 2025

Hmm... I expected it to be

Load stack pointer -> add offset -> load return address -> add offset

but maybe my mental model of how LLVM works is just off here, or you implemented a different variant than I had in mind (where the sharers and erasers are always placed at a particular offset of the return address in code).

@serkm
Copy link
Contributor Author

serkm commented Jan 27, 2025

I didn't see an easy way to place functions relative to each other.
I placed function pointers relative to the return address.

@b-studios
Copy link
Collaborator

ok, then the additional indirection makes sense, thanks for the explanation

@b-studios
Copy link
Collaborator

Is there a way to make the linker happy?

@serkm serkm force-pushed the prefix branch 3 times, most recently from 6e6ef9f to c08e1a9 Compare July 15, 2025 07:41
@serkm
Copy link
Contributor Author

serkm commented Jul 16, 2025

This should be ready now. It turns out the linker doesn't like pie :)
Do we want to give up on position independence though?

@b-studios
Copy link
Collaborator

Are the benchmark results from above still up to date?

@b-studios
Copy link
Collaborator

What are the most important down sides in your opinion of giving up position independence?

@serkm
Copy link
Contributor Author

serkm commented Jul 16, 2025

Updated benchmarks:
image

@serkm
Copy link
Contributor Author

serkm commented Jul 16, 2025

I don't know really know about the downsides. According to claude, there are some security vulnerabilities with position dependence.
There might also be issues if we ever want to compile to shared libraries.

@serkm
Copy link
Contributor Author

serkm commented Jul 16, 2025

Without -no-pie the linker complains, but the tests still succeed.

/usr/bin/ld: /tmp/lto-llvm-1c61d0.o: warning: relocation in read-only section `.text.returnAddress_1616'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE

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

Successfully merging this pull request may close these issues.

2 participants