3112 – Specification on what operations call the GC is missing

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3112 - Specification on what operations call the GC is missing
Summary: Specification on what operations call the GC is missing
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks: 677
Show dependency tree / graph
Reported: 2009年06月29日 18:41 UTC by Leandro Lucarella
Modified: 2014年04月18日 09:12 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Leandro Lucarella 2009年06月29日 18:41:43 UTC
There are several languages constructs that rely on the GC and use it, like array concatenation and appending. This operations are not properly documented.
Comment 1 Walter Bright 2010年11月10日 00:25:48 UTC
http://www.dsource.org/projects/phobos/changeset/2153 
Comment 2 Petr Janda 2010年12月21日 23:40:16 UTC
Why are things such as array concat and appending relying on GC? It looks to me as that a lot of them could be accomplished without it.
Comment 3 Jonathan M Davis 2010年12月22日 00:03:29 UTC
They use the GC for two reasons of which I am aware:
1. They potentially have to reallocate. That means allocating memory which normally means using the GC. And since there's no way to tell something like ~= to use malloc() (and potentially free()) instead of the GC, it _has_ to use the GC.
2. As I understand it, the GC does some sort of voodoo to determine whether an array actually has the capacity to increase its size in place. That's likely going to have to figure out whether _other_ arrays refer to the memory immediately after the end of the array, which would somehow involve looking at the other arrays, which would require the GC, since one malloc-ed item knows nothing about another malloc-ed item. The fact that you have slicing likely complicates things a fair bit.
It would probably be possible to do array concatenation and appending without the GC if arrays were not designed to use the GC (after all, vectors in C++ are able to reallocate without the GC), but since they _do_ use the GC, they have to use the GC for operations which would result in reallocating memory.
Actually, I believe that Steven pointed out on the list recently that you _can_ use appending with non-GCed dynamic arrays but that you have to maintain references to the original before you append so that you can free that memory if you need to. So, it _is_ possible, but it doesn't work very well.


AltStyle によって変換されたページ (->オリジナル) /