a…@littlepinkcloud.invalid [2026-11-24 13:46:24] wrote:
> Stefan Monnier <monn…@iro.umontreal.ca> wrote:
>> Hmm... didn't think of that. Indeed this could lead to actual >> addresses embedded in the code. Then again, I'd expect most such JIT >> setups to want to keep most of those addresses in data rather than in >> the code so the GC can more easily trace through them.
> GCs have not the slightest difficulty tracing through embedded > addresses. We use whatever form of address constants is fastest.
Maybe it's not "hard" compared to the rest of what it takes to write a high performance GC, but it's still a fair bit more work to have to tell the GC where to find the few bitfields that need to be stitched together to make up the actual pointer (it definitely makes tracing through such references slower), and if you have a moving GC it also makes moves harder, because of the need to both retrofit the new address into the corresponding bitfields (which also means you can't use an instruction sequence special-tailored to the original address) and take care of updating/flushing the I-cache.
>> Andrew, do you know what causes all those large constant addresses >> you're seeing?
> > Very common constants are classes used in expressions, such as > > new File("filename") > > or casts between types > > File x = (File)anObject; > > Casts are more common than is immediately apparent, because the > compiler inserts them when it can't prove the type of an object.
Interesting, thanks. So it is indeed the JIT case suggested by Anton!
> The other important case is metadata. We gather a lot of information > about running code: branch frequency, type frequency, and so on. Every > metadata address is a constant in the generated code. After a while, > code is recompiled and we use all the gathered informtion to drive > inlining and other optimizations.
Hmm... even more interesting: since the metadata-gathering is part of the code that's generated cheaply, I'd have expected that code to use a simple approach that always loads the large constants from some data section rather than "use whatever form of address constants is fastest" (which I would have expected is used only for the high-performance version of the code). === Stefan