Use pointer equality to compare StableNames
AbandonedPublic

Authored by dfeuer on Aug 20 2018, 7:18 PM.

Details

Summary

My understanding is that there is a one-to-one correspondence
between stable name objects and stable name table entries. We
should, therefore, be able to implement eqStableName# using
pointer equality, instead of dereferencing the pointers to compare
stable name table indices.

dfeuer created this revision.Aug 20 2018, 7:18 PM

Well, it certainly looks like it works. I checked that there are indeed some tests that exercise the stable name mechanism, but it would still be nice if one of the people who has worked on it could confirm that this is really valid.

You surely need a long Note to explain the moving parts here :-). See the email thread.

Eg what do the entires in the stable name table actually look like? What's this fixedHdrSizeW offset doing? It's all very mysterious

You surely need a long Note to explain the moving parts here :-). See the email thread.

Eg what do the entires in the stable name table actually look like? What's this fixedHdrSizeW offset doing? It's all very mysterious

I can only guess that fixedHdrSizeW is about skipping over the stable pointer object header to get to its payload, the stable pointer table index. But as I said, I don't think we actually need its payload for the equality test.

I can only guess that fixedHdrSizeW is about skipping over the stable pointer object header to get to its payload,

Maybe so; but it's a funny way to do so. I thought we had more explicit abstractions for getting at the fields of heap objects. Anyway if we keep it, we could add a comment

You surely need a long Note to explain the moving parts here :-). See the email thread.

Eg what do the entires in the stable name table actually look like? What's this fixedHdrSizeW offset doing? It's all very mysterious

I can only guess that fixedHdrSizeW is about skipping over the stable pointer object header to get to its payload, the stable pointer table index. But as I said, I don't think we actually need its payload for the equality test.

This is defined it the SMRep module and accounts for the size of the standard StgHeader header (typically an info table pointer and possibly a profiling header; see includes/rts/storage/Closures.h).

Looking more closely, @simonpj is right that the previous implementation was a bit odd. This likely should have been using something like oFFSET_StgStableName_sn.

I suspect using pointer equality here is fine, although I'll defer to @simonmar for the final word.

simonmar accepted this revision.Aug 23 2018, 1:02 PM

I think this is OK, but needs a comment.

compiler/codeGen/StgCmmPrim.hs
1400

A comment here to say why we believe pointer equality is a valid implementation of eqStableName# would be good.

This revision is now accepted and ready to land.Aug 23 2018, 1:02 PM
dfeuer abandoned this revision.Aug 27 2018, 2:37 PM

I've folded this into D5084.