<div dir="ltr"><div>Hi@ one of the most interesting mailing lists in IT :)</div><div><br></div><div>as stated in the subject, would like to implement a new keyword short in the context of pointer declaration.</div><div><br></div><div>short Object* object = new Object(); <br></div><div><br></div><div>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.</div><div><br></div><div>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) </div><div><br></div><div>class MyObject {</div><div>    public:</div><div>      short Object *mainObject;<br></div><div>      vector<short Object*> children(10000);</div><div> };<br></div><div><br>not necessarily extreme example but suddenly my MyObject object would save a significative amount of memory.</div><div><br></div><div>All references to the members should be as with normal pointers:</div><div><br></div><div>short MyObject *myObject = new MyObject();</div><div>short Object*  object = myObject->mainObject;</div><br clear="all"><div>Of course there should be some glue code that will glue the factory method for new and will manage the segment address.</div><div><br></div><div>Besides pointer compression, what other advantages? Data would be position independent. This means that:</div><div><br></div><div>-> 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.</div><div>-> data from segments can be equally easily shared and accessed between processes through mmap  (pointer semantics would not change)<br></div><div><br></div><div><br></div><div>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. </div><div><br></div><div>any hints would be more than wellcome</div><div><br></div><br><div class="gmail_signature">rgrds,<br>mobi phil<br><br>being mobile, but including technology<br><a href="http://mobiphil.com">http://mobiphil.com</a></div>
</div>