[cfe-dev] short Object* object = new Object(); //pointer compression

mobi phil mobi at mobiphil.com
Sun Dec 7 17:52:33 PST 2014


Hi@ one of the most interesting mailing lists in IT :)

as stated in the subject, would like to implement a new keyword short in
the context of pointer declaration.

short Object* object = new Object();

The objective is to implement some sort of 64 bit pointer compression that
will have some additional benefits. Related to the topic I also started a
thread on llvm mailing list.

So what should happen behind? A custom new operator (name could change
accordingly) would allocate memory from the active segment, but would
return only a 32 bit offset inside a 4GB adressable segment. The segment
address would be kept either as a thread local storage, register, or as
method argument)

class MyObject {
    public:
      short Object *mainObject;
      vector<short Object*> children(10000);
 };

not necessarily extreme example but suddenly my MyObject object would save
a significative amount of memory.

All references to the members should be as with normal pointers:

short MyObject *myObject = new MyObject();
short Object*  object = myObject->mainObject;

Of course there should be some glue code that will glue the factory method
for new and will manage the segment address.

Besides pointer compression, what other advantages? Data would be position
independent. This means that:

-> data from segments (segments can be smaller than 4GB) can be saved and
loaded at any address. Interesting candidate for some fast in/out memory
database.
-> data from segments can be equally easily shared and accessed between
processes through mmap  (pointer semantics would not change)


After this short story I wonder what would be the easiest way to implement
this as an extension to clang infra for C++ parsing. I saw that there were
some threads from 2011 about plugins, but nothing afterwards can be found.

any hints would be more than wellcome


rgrds,
mobi phil

being mobile, but including technology
http://mobiphil.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141208/a44206bc/attachment.html>


More information about the cfe-dev mailing list