<div dir="ltr">Can you do the offset symbols the same way as vtbl symbols (ie once per class) then reference them from DotVarExp::toElem?  If I understand correctly that's the right place for this.</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sat, Mar 29, 2014 at 11:48 PM, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
As a part of implementing D/Objective-C I need to implement non-fragile instance variables for 64bit. Non-fragile instance variables work like regular instance variables except that instead of using a compile time known offset a symbol containing the offset is used. The compiler outputs these symbols with the compile time known offset. Then at load time the offset can be replaced with something else. At runtime when accessing an instance variable the offset stored in the symbol should be used.<br>

<br>
I hit a problem I hit a problem trying to implement this. This is how the implementation currently looks like [1]. If I output the offset symbol for an instance variable in DotVarExp::toElem [2] I get a duplicate symbol error when compiling an application. If I don't output the offset symbol I get an assertion failure here instead [3]. Note that I'm currently always outputting the offset symbol when outputting the metadata for a class [4].<br>

<br>
Any ideas how to solve this?<br>
<br>
[1] <a href="https://github.com/jacob-carlborg/dmd/commit/9d9f6c9a5edc455b066ec77c5f1373b2886860a6" target="_blank">https://github.com/jacob-carlborg/dmd/commit/9d9f6c9a5edc455b066ec77c5f1373b2886860a6</a><br>
[2] <a href="https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/e2ir.c#L3664-L3674" target="_blank">https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/e2ir.c#L3664-L3674</a><br>

[3] <a href="https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/backend/cod1.c#L1487" target="_blank">https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/backend/cod1.c#L1487</a><br>

[4] <a href="https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/objc.c#L1629" target="_blank">https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/objc.c#L1629</a><br>

<br>
Note, the code is not up to date with upstream HEAD, but it's fairly recent.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
/Jacob Carlborg<br>
<br>
_______________________________________________<br>
dmd-internals mailing list<br>
<a href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-internals" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a><br>
</font></span></blockquote></div><br></div>