Save a word in the info table on x86_64
ClosedPublic

Authored by simonmar on Apr 25 2018, 5:37 PM.

Details

Summary

An info table with an SRT normally looks like this:

StgWord64 srt_offset
StgClosureInfo layout
StgWord32 layout
StgWord32 has_srt

But we only need 32 bits for srt_offset on x86_64, because the small
memory model requires that code segments are at most 2GB. So we can
optimise this to

StgClosureInfo layout
StgWord32 layout
StgWord32 srt_offset

saving a word. We can tell whether the info table has an SRT or not,
because zero is not a valid srt_offset, so zero still indicates that
there's no SRT.

Test Plan
  • validate
  • For results, see D4632.

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
simonmar created this revision.Apr 25 2018, 5:37 PM
simonmar requested review of this revision.Apr 30 2018, 10:43 AM

Good catch! Patch looks good, just a few documentation wibbles.

compiler/cmm/CmmInfo.hs
273

It won't be clear to a reader new to the code what this refers to. Can you add a reference to the "referring to SRTs" section off Note [SRTs]?

includes/rts/storage/InfoTables.h
158

Perhaps reference the Note. Also perhaps the CmmInfo.inlineSRT lest someone think they can disable this optimisation by merely commenting out this macro.

simonmar updated this revision to Diff 16309.May 4 2018, 7:41 AM

address comments

One more request spurred by a debugging experience I'm currently in the middle of:

It would be nice if there were an easy switch to disable this optimization. It's quite helpful to be able to use find on an SRT in GDB.

This can be easily done by just guarding the logic in CmmInfo with USE_INLINE_SRT_FIELD.

Whoops, ignore the previous remark. I neglected to consider that the field is already an offset and therefore find is already quite useless.

simonmar updated this revision to Diff 16422.May 15 2018, 11:09 AM

fix comment

This revision was not accepted when it landed; it landed in state Needs Review.May 16 2018, 7:36 AM
This revision was automatically updated to reflect the committed changes.