[cfe-dev] short Object* object = new Object(); //pointer compression
Mihaly Elekes
misi.aaaa at gmail.com
Tue Dec 9 17:36:41 PST 2014
>
> I don't think that's what the original poster needed (32-bit offset in
> a 64bit segment).
>
let me make a correction. Indeed it is about a 32 bit (or less) offset
inside a 32 bit (or less) addressable segment. Address would be always
calculated as 64 bit pointer + 32 bit offset.
Indeed, as I stated in my prev, email __ptr32 would not make too much
sense...
I further worked on this concept and almost came to the conclusion that
implementation of special class of pointers would become too complicated
(both clang and llvm). Would be though interesting to "teach" the compiler
to allow arithmetics like
shortptr = longptr; //(where shortptro = longptr-base)
//or
longptr = shortptr; //where longptr = shortpr + base), where base would be
a task (thread) specific value
The framework or the "extension" should make sure that such values are
allocated in the correct adress space.
I will probably go for an "eco pointer template" solution
template<class T>
class ecoPtr {
private:
static void * operator new(std::size_t); //forbid allocation on heap
static void * operator new[](std::size_t);
private:
uint32_t ptr; //this is the real pointer compressed to 32 bit
public:
template<typename... Args>
inline eco(Args... args) __attribute__((always_inline)) { /*
custom allocate T and return the offset */ }
T* operator->() {}
};
This would also implement later a ref counting, but ref count would be held
inside T
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141210/671e867e/attachment.html>
More information about the cfe-dev
mailing list