Skip to content

Commit

Permalink
Merge pull request #8361 from quickfur/tracegc
Browse files Browse the repository at this point in the history
Fix issue 14892: std.array.array support for -profile=gc.
  • Loading branch information
RazvanN7 committed Jan 19, 2022
2 parents a86c1eb + 75d7378 commit 30de0aa
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion std/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,11 @@ if (isDynamicArray!T && allSatisfy!(isIntegral, I))
// from rt/lifetime.d
private extern(C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow;

// from rt/tracegc.d
version (D_ProfileGC)
private extern (C) void[] _d_newarrayUTrace(string file, size_t line,
string funcname, const scope TypeInfo ti, size_t length) pure nothrow;

private auto arrayAllocImpl(bool minimallyInitialized, T, I...)(I sizes) nothrow
{
static assert(I.length <= nDimensions!T,
Expand Down Expand Up @@ -992,7 +997,15 @@ private auto arrayAllocImpl(bool minimallyInitialized, T, I...)(I sizes) nothrow
_d_newarrayU returns a void[], but with the length set according
to E.sizeof.
+/
*(cast(void[]*)&ret) = _d_newarrayU(typeid(E[]), size);
version (D_ProfileGC)
{
// FIXME: file, line, function should be propagated from the
// caller, not here.
*(cast(void[]*)&ret) = _d_newarrayUTrace(__FILE__, __LINE__,
__FUNCTION__, typeid(E[]), size);
}
else
*(cast(void[]*)&ret) = _d_newarrayU(typeid(E[]), size);
static if (minimallyInitialized && hasIndirections!E)
// _d_newarrayU would have asserted if the multiplication below
// had overflowed, so we don't have to check it again.
Expand Down

0 comments on commit 30de0aa

Please sign in to comment.