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

Nikola Smiljanic popizdeh at gmail.com
Sun Dec 7 23:12:11 PST 2014


I think your only option is to modify clang itself (someone will correct me
if I'm wrong). It's probably best to choose a different spelling for your
keyword as 'short' is already reserved and can appear in so many contexts.
Seeing short short* would be so confusing :)

On Mon, Dec 8, 2014 at 12:52 PM, mobi phil <mobi at mobiphil.com> wrote:

> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141208/f38315d3/attachment.html>


More information about the cfe-dev mailing list