Neat project: add pointer capability to std.bitmanip.bitfields

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 3 17:51:24 PST 2015


On Thursday, 3 December 2015 at 12:45:10 UTC, Steven 
Schveighoffer wrote:
> Do you have any rationale to prefer arbitrary bitfield pointers 
> over GC safe ones?
>

There are various valid use of this in HHVM for instance. One of 
the nasty trick that is used is to allocate the memory to JIT 
code in the the lower 32bits of memory, and then pad pointer with 
0 to retrieve them.

Because of this, various datastructures can be compacted, and 
address of code can be cramed directly in the instruction stream 
(at least on x86) when it can't be on 64 bits.

There is a talk by Drew Parowski where he explains it 
(https://www.youtube.com/watch?v=XqK8Yuoq4ig I think, but not 
sure).

However, I agree with the sentiment. This is the kind of features 
you are looking for to get the last few percent and shouldn't be 
encouraged. That is highly non portable and probably doesn't 
belong in an std module.

NB: I considered adding this functionality when doing the 
taggedPointer thing, (x64 has 48bits of effective address space) 
but eventually decided against.


More information about the Digitalmars-d mailing list