http://d.puremagic.com/issues/show_bug.cgi?id=7243
Summary: Compiler should call separate function when allocating
a struct on the heap
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Steven Schveighoffer <[email protected]> 2012-01-07
12:00:56 PST ---
Note, this requires druntime fixes too, but I can't select both DMD and
druntime.
Currently, when creating a struct on the heap, _d_newarrayT is called with a
length of 1.
However, the runtime must assume this is an array of length 1. Therefore, it
must set the appendable bit, and reserve space for the 'used' length.
This can waste space.
For instance, the following could fit in a 16-byte block, but will go into a
32-byte block due to the used field:
import core.memory;
struct S
{
int[4] buf;
}
void main()
{
auto s = new S;
assert(GC.sizeof(s) == 32);
}
I think instead, a _d_newstruct function should be called (and implemented in
druntime) to initialize a single struct on the heap in the most efficient
manner possible.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------