Do we have free bits in the info pointer itself?

Our heap object header is one word -- an info table pointer https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObjects. Well, a 64 bit info table pointer leaves *at least* 16 high bits inside the object header for other purposes, right? Is there any problem with using these other than having to mask the info table pointer each time it is dereferenced? Thanks, -Ryan

Mostly just that GHC still works on 32 bit platforms.
-Edward
On Wed, Sep 7, 2016 at 5:32 PM, Ryan Newton
Our heap object header is one word -- an info table pointer https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObjects .
Well, a 64 bit info table pointer leaves *at least* 16 high bits inside the object header for other purposes, right?
Is there any problem with using these other than having to mask the info table pointer each time it is dereferenced?
Thanks, -Ryan
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Good point. Also
* the high bits are free now, but they may not be free forever (though
that's not a great reason to avoid using them in the meantime)
* masking off the high bits when entering is rather expensive, at
least in code size, compared to a simple "jmp *%rax" or especially
"jmp *symb", which appears at the end of almost every Haskell function
* modifying the low bits of a pointer will leave it pointing at the
same cache line, so the hardware prefetcher may decide to prefetch the
contents (hopefully at an appropriate time) while modifying the high
bits will make it not look like a pointer at all. But it's hard to
know how much we currently gain from hardware prefetching, if
anything.
Certainly these downsides are not necessarily deal-breakers, as
demonstrated by NaN-boxing as used in major JavaScript engines.
What did you intend to use the high bits for?
Regards,
Reid Barton
On Wed, Sep 7, 2016 at 11:16 PM, Edward Kmett
Mostly just that GHC still works on 32 bit platforms.
-Edward
On Wed, Sep 7, 2016 at 5:32 PM, Ryan Newton
wrote: Our heap object header is one word -- an info table pointer.
Well, a 64 bit info table pointer leaves *at least* 16 high bits inside the object header for other purposes, right?
Is there any problem with using these other than having to mask the info table pointer each time it is dereferenced?
Thanks, -Ryan
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

What did you intend to use the high bits for?
Nothing right now. Just speculation. I was actually pondering how our headers are rather svelte compared to many languages. Java, for instance, saves a full word for a hash. There are endless bits of metadata to speculate about... - whether or not the heap object is frozen to disallow further modification (e.g. for MutVars) - whether or not the heap object is part of a contiguous CNF - a flag to invoke some alternate GC behavior - metadata to avoid dereferencing the info table pointer in some circumstances (common type tags?) - you could even index 2^16 per-type values that live off of the info table But most likely it would have to be something that would give across the board perf improvements that would pay for the extra cost in masking. Good point re: HW prefetching.

* Ryan Newton:
Our heap object header is one word -- an info table pointer https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObjects.
Well, a 64 bit info table pointer leaves *at least* 16 high bits inside the object header for other purposes, right?
x86_64 has signed pointers, so the uppoer 16 bits are either all zero or all ones. Some systems use both, but it's rare on Linux. Other 64-bit platforms use more bits.
participants (4)
-
Edward Kmett
-
Florian Weimer
-
Reid Barton
-
Ryan Newton