2

Currently current x86_64 (AMD64) machines do not implement the full 64-bit memory space in wiring. Thus, the available memory space is quite less (in my own machine cat /proc/cpuinfo says 36 bits physical, 48 bits virtual).

If we asume, for the sake of the question, that we need not make our application portable for the full 64 bits of addressing.

Then, we have a lot of room in pointers that are effectively being wasted. Can the unusable space (for addressing) be used for the storage of further information, or to use the same data type with an indicator of whether it is a tagged pointer or something else (maybe an immediate small value instead of a pointer)?

I think the most prominent use-case could be to implement run-times, intepreters and compilers of dynamic languages, but I'm sure it can be extended to more usage.

ssice
  • 3,564
  • 1
  • 26
  • 44
  • just because the physical memory isn't wired up to the full 64bit doesn't mean that 64bit memory pointers only use 36 bits as well. the **FULL** memory range is avaialble, and the MMU takes care of mapping that "anywhere in 64bit space" to "the 36bits that are available in hardware". – Marc B Jun 16 '15 at 17:55
  • http://stackoverflow.com/q/27751470/995714 the top 16 bits are always the same in x86_64 so I think you can store tags in those bits, but remember to sign extend the high bits before dereference the pointer – phuclv Jun 16 '15 at 18:03
  • 1
    No. If you fiddle these bits you create non-canonical (can't remember if this is the official term) address and hardware may throw interrupt or otherwise do something undesirable. – Jeff Hammond Jun 17 '15 at 03:11
  • @Jeff *may* is not exactly the same as *will*. Anyway, it could be possible to sign-extend the address if it happens to be a real pointer, and use the inner value if it doesn't. So, from your comments, it seems it can be done. – ssice Jun 17 '15 at 15:54
  • 1
    http://stackoverflow.com/questions/16198700/using-extra-16-bit-in-64-bit-machine – Jeff Hammond Jun 18 '15 at 00:41
  • "the AMD specification requires that bits 48 through 63 of any virtual address must be copies of bit 47 (in a manner akin to sign extension), or the processor will raise an exception." From https://en.m.wikipedia.org/wiki/X86-64. – Jeff Hammond Jun 18 '15 at 00:42

0 Answers0