Thread overview | |||||
---|---|---|---|---|---|
|
March 29, 2014 [dmd-internals] Using symbol for instance variable offset | ||||
---|---|---|---|---|
| ||||
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. 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]. Any ideas how to solve this? [1] https://github.com/jacob-carlborg/dmd/commit/9d9f6c9a5edc455b066ec77c5f1373b2886860a6 [2] https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/e2ir.c#L3664-L3674 [3] https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/backend/cod1.c#L1487 [4] https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/objc.c#L1629 Note, the code is not up to date with upstream HEAD, but it's fairly recent. -- /Jacob Carlborg _______________________________________________ dmd-internals mailing list dmd-internals@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-internals |
April 01, 2014 Re: [dmd-internals] Using symbol for instance variable offset | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg Attachments:
| 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.
On Sat, Mar 29, 2014 at 11:48 PM, Jacob Carlborg <doob@me.com> wrote:
> 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.
>
> 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].
>
> Any ideas how to solve this?
>
> [1]
> https://github.com/jacob-carlborg/dmd/commit/9d9f6c9a5edc455b066ec77c5f1373b2886860a6
> [2]
> https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/e2ir.c#L3664-L3674
> [3]
> https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/backend/cod1.c#L1487
> [4]
> https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/objc.c#L1629
>
> Note, the code is not up to date with upstream HEAD, but it's fairly recent.
>
> --
> /Jacob Carlborg
>
> _______________________________________________
> dmd-internals mailing list
> dmd-internals@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>
|
April 01, 2014 Re: [dmd-internals] Using symbol for instance variable offset | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On 1 apr 2014, at 12:43, Daniel Murphy <yebblies@gmail.com> wrote: > 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. The idea was to do it once per class then reference them from DotVarExp::toElem. I can have a look at how it's done for vtbl symbols. Would it be something like ClassDeclaration::toVtblSymbol? [1] https://github.com/D-Programming-Language/dmd/blob/master/src/tocsym.c#L529 -- /Jacob Carlborg _______________________________________________ dmd-internals mailing list dmd-internals@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-internals |
Copyright © 1999-2021 by the D Language Foundation