D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7008 - Associative array ABI is under-specified
Summary: Associative array ABI is under-specified
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks:
 
Reported: 2011-11-25 14:25 UTC by Jerry Quinn
Modified: 2024-12-15 15:21 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jerry Quinn 2011-11-25 14:25:09 UTC
The current ABI describes associative arrays as an opaque type.
However, for a debugger to work with them, it must understand the
structure.  For 2 compilers to be able to generate compatible code, they must agree on the structure.  Currently the ABI specifies an AA as an opaque implementation-defined type.

This means that multiple compilers will not be able to guarantee compatibility since the AA ABI is not specified.  Also, debuggers must refer to the source code of the compiler druntime in order to know how to work with the contents of an AA.

Specifying C functions to manipulate the opaque pointer solves the debugger issue, but not the issue of ensuring compatibility across compilers.
Comment 1 Martin Nowak 2011-11-26 15:13:37 UTC
The functions are only partly helpful for a debugger.

IMHO we should switch completely to using
AssociativeArray from object.
The current situation of using it only in
certain cases is messy.
Comment 2 Walter Bright 2011-11-26 20:48:29 UTC
Being an opaque pointer means that the implementation of associative arrays is entirely up to the runtime, not the compiler. The compiler should emit no dependencies on how it is implemented.
Comment 3 Jerry Quinn 2011-12-11 21:32:49 UTC
(In reply to comment #2)
> Being an opaque pointer means that the implementation of associative arrays is
> entirely up to the runtime, not the compiler. The compiler should emit no
> dependencies on how it is implemented.

To make this work, the compiler has to have a documented interface to the AA.  I feel we need a documented set of calls that will be output by the compiler, just as $ is documented as being translated to length.

At the moment, the only documentation is "read this file in druntime".  It's not a guarantee of how the compiler-AA interface works.  Without the guarantee another compiler cannot safely generate compatible code, and debuggers can't be guaranteed to know how to look at the contents of the AA.

Am I missing something in this request?
Comment 4 Andrej Mitrovic 2014-04-23 11:46:47 UTC
If/when the hashes are replaced with a library implementation there won't be a need to emit any special debugging information, it will largely be automatic. So I think we shouldn't try to add more cruft to the compiler right now.
Comment 5 Andrej Mitrovic 2014-04-23 11:47:12 UTC
(In reply to Andrej Mitrovic from comment #4)
> If/when the hashes are replaced with a library implementation there won't be
> a need to emit any special debugging information, it will largely be
> automatic. So I think we shouldn't try to add more cruft to the compiler
> right now.

Sorry, I meant to the ABI as well.
Comment 6 Martin Nowak 2014-04-23 13:18:09 UTC
BTW, I'm currently working on the library AA, but it's more work than anticipated. Mostly because getting all the details of attributes, rvalues, construction and range interfaces right is quite involved.
https://github.com/MartinNowak/dmd/tree/libraryAA
https://github.com/MartinNowak/druntime/tree/libraryAA
Comment 7 Andrej Mitrovic 2014-04-23 15:04:08 UTC
(In reply to Martin Nowak from comment #6)
> BTW, I'm currently working on the library AA, but it's more work than
> anticipated. Mostly because getting all the details of attributes, rvalues,
> construction and range interfaces right is quite involved.
> https://github.com/MartinNowak/dmd/tree/libraryAA
> https://github.com/MartinNowak/druntime/tree/libraryAA

Good luck with it! :>
Comment 8 hsteoh 2014-04-23 15:34:52 UTC
Wow. Best wishes on that! And yes, being more complicated than anticipated is a familiar feeling w.r.t. AA's. :-)
Comment 9 dlangBugzillaToGithub 2024-12-15 15:21:51 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dlang.org/issues/4016

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB