Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
by ndesaulniers
1 subcomments
- Happy to see discussion of LLVM's interesting implementation of Static Polymorphism using CRTP. Some recommended reads:
1. https://en.wikipedia.org/wiki/Curiously_recurring_template_p...
2. https://david.alvarezrosa.com/posts/devirtualization-and-sta...
3. https://llvm.org/docs/ProgrammersManual.html#the-isa-cast-an...
by internet_points
0 subcomment
- Drawn in by the Emacs, learnt something new about C and C++, thank you for this! Very readable article for someone who doesn't feel too confident with low-level bits.
Btw, is this representation the reason why OCaml's ints are not as big as C ints?
Also interesting that the Haskell pointer tagging you link to[0] was done the way it was to avoid CPU branch misprediction, and that the old way which it replaced was "the source of half of the branch misprediction events". I wonder how "branch prediction friendly" current Haskell is.
[0] https://simonmar.github.io/bib/papers/ptr-tagging.pdf
by tialaramex
3 subcomments
- It's not clear to me (and as an unsafe language it's not called out by your compiler if you do something illegal) what the correct way to spell this kind of trick is in C++
I had thought you need the pointer-sized integer types and mustn't do this directly to an actual pointer, but maybe I was wrong (in theory, obviously practice doesn't follow but that's a dangerous game)
by thecloudlet
0 subcomment
- Emacs internal part 2 HN link:
https://news.ycombinator.com/item?id=47259961
by mshockwave
0 subcomment
- LLVM now has another way to implement RTTI using the `CastInfo` trait instead of `classof`: https://llvm.org/doxygen/structllvm_1_1CastInfo.html
But it's really just an implementation difference, the idea is still to have a lightweight RTTI.