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

Aaron Ballman aaron at aaronballman.com
Mon Dec 8 05:35:18 PST 2014


On Mon, Dec 8, 2014 at 2:12 AM, Nikola Smiljanic <popizdeh at gmail.com> wrote:
> 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 :)

This sounds possibly like __ptr32, which we already have some minor
amount of support for, with the extra benefit of at least one other
vendor implementing such an extension.

http://msdn.microsoft.com/en-us/library/aa985900.aspx

~Aaron

>
> 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
>>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list