Article View: comp.arch
Article #943Re: Large constants in RISC
From: Stefan Monnier
Date: Wed, 25 Nov 2026 04:21
Date: Wed, 25 Nov 2026 04:21
50 lines
4016 bytes
4016 bytes
aph@littlepinkcloud.invalid [2026-11-24 13:46:24] wrote:
> Stefan Monnier <monnier@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
Technical Details
Message-ID:
<jwvv75l7dsm.fsf-monnier+comp.arch@gnu.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11d76uq$11cdc$1@paganini.bofh.team> <11d7ct8$17akn$1@dont-email.me> <11d7ih2$11orr$1@paganini.bofh.team> <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team> <2026Nov14.201017@mips.complang.tuwien.ac.at> <6af911ea.18530156@news.eternal-september.org> <SYScnWsR3rgGWWP3nZ2dnZfqn_WdnZ2d@supernews.com> <jwv1p8hhqmy.fsf-monnier+comp.arch@gnu.org> <4m2MS.132607$Lt64.106487@fx41.iad> <jwvo6bidgit.fsf-monnier+comp.arch@gnu.org> <8OWcnVnljcStCJj2nZ2dnZfqnPqdnZ2d@supernews.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Stefan Monnier <monnier@iro.umontreal.ca> Newsgroups: comp.arch Subject: Re: Large constants in RISC Date: Tue, 24 Nov 2026 23:21:48 -0500 Organization: A noiseless patient Spider Lines: 50 Message-ID: <jwvv75l7dsm.fsf-monnier+comp.arch@gnu.org> References: <11d76uq$11cdc$1@paganini.bofh.team> <11d7ct8$17akn$1@dont-email.me> <11d7ih2$11orr$1@paganini.bofh.team> <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team> <2026Nov14.201017@mips.complang.tuwien.ac.at> <6af911ea.18530156@news.eternal-september.org> <SYScnWsR3rgGWWP3nZ2dnZfqn_WdnZ2d@supernews.com> <jwv1p8hhqmy.fsf-monnier+comp.arch@gnu.org> <4m2MS.132607$Lt64.106487@fx41.iad> <jwvo6bidgit.fsf-monnier+comp.arch@gnu.org> <8OWcnVnljcStCJj2nZ2dnZfqnPqdnZ2d@supernews.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 25 Nov 2026 11:30:20 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3886047"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19s1fmd1AkpO4c/m/Lr2bB/0n6gKzsTLVs="; posting-host="2b1d4c3b56e81216facd83c50a602bad" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:uQOfE+QfY9xtCHIFnniRy4eCl+0= sha1:YgWRcQl2CX/HrKXJhPf71dhOYGQ= sha256:6bDPzDxYA1emSjZpBR5fk1v8sWZQzN4zqxuBpCJiYrM= sha1:CZvKagQhpPVKx6ndMX22Nhpm1zU= sha256:Y/Kf7LaoQoncgDWv+rYGsYs+ygpcPMlg0c4cocvYmGc= In-Reply-To: <8OWcnVnljcStCJj2nZ2dnZfqnPqdnZ2d@supernews.com> (message from aph@littlepinkcloud.invalid on Tue, 24 Nov 2026 13:46:24 +0000)