top | item 40297384

(no title)

couchand | 1 year ago

Oh that's frightening they shift the entire pointer by the alignment

discuss

order

db48x|1 year ago

Why? Alignment causes some low–order bits to be zero. Shifting the pointer to the right drops those zeros on the floor, leaving high–order bits zero (or sign extended or whatever). Then you can put your tag up there instead. Shifting the value left by the same amount drops the tag and recovers the same pointer for use.

couchand|1 year ago

My guideline with pointer tricks is: if you're not just masking bits it's too complicated for real use.

vlovich123|1 year ago

Any idea why it's preferred to do the alignment route instead of storing the bits in the upper part of the pointer & masking?