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.
> So, we now have 3 suggested circumstances, but it's not clear if these
> occur enough to explain Andrew's experience.
>
> 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.
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.
[ We actually have two compilers. One is optimized to generate code as
fast as possible in order to gather metadata about the program, and
the other compiler optimizes everything, producing small code that
doesn't collect metadata. ]
Andrew.