<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 6 February 2014 01:22, Michel Fortin <span dir="ltr"><<a href="mailto:michel.fortin@michelf.ca" target="_blank">michel.fortin@michelf.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 2014-02-05 15:01:04 +0000, Manu <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>> said:<br>

<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Aligned data is a challenge. I have often wondered if it would be feasible<br>
to access the RC via a pointer hash or something, and keep it in a side<br>
table... sounds tricky, but I wonder if it's possible.<br>
</blockquote>
<br></div>
That's what Apple is doing (as seen in the CoreFoundation source code). They actually have eight such tables on OS X, each protected by a spin lock. The right table is chosen according to a few bits of the pointer.<br>

<br>
The obvious advantage is you can put immutable data in read-only memory without making the reference count immutable. The downside is that it's more complicated to access the counter.</blockquote><div><br></div><div>
Indeed. Good to know someone else is doing it. Sounds like a realistic option then :)</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Fat pointers might be necessary. That's a bit annoying. Hmmm...<br>
</blockquote>
<br></div>
Since we're talking about adding reference counts to GC-allocated memory, you could use the GC to find the base address of the memory block. What is the cost of that?</blockquote><div><br></div><div>Can you elaborate? How would the GC know this?</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm sure there's a clever solution out there which would allow the ARC to<br>
detect if it's a raw C pointer or not...<br>
</blockquote>
<br></div>
Ask the GC for the base address of the memory block. If it does not come from a GC block, there's no reference counter to update.<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
-- <br>
Michel Fortin<br>
<a href="mailto:michel.fortin@michelf.ca" target="_blank">michel.fortin@michelf.ca</a><br>
<a href="http://michelf.ca" target="_blank">http://michelf.ca</a><br>
<br>
</font></span></blockquote></div><br></div></div>