Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions druntime/src/core/internal/array/utils.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,16 @@ auto gcStatsPure() nothrow pure
return impureBypass();
}

ulong accumulatePure(string file, int line, string funcname, string name, ulong size) nothrow pure
version (D_ProfileGC)
{
static ulong impureBypass(string file, int line, string funcname, string name, ulong size) @nogc nothrow
// Needs to be templated to emit only as needed.
ulong accumulatePure()(string file, int line, string funcname, string name, ulong size) @nogc nothrow pure
{
import core.internal.traits : externDFunc;

alias accumulate = externDFunc!("rt.profilegc.accumulate", void function(string file, uint line, string funcname, string type, ulong sz) @nogc nothrow);
accumulate(file, line, funcname, name, size);
return size;
alias impl = externDFunc!("rt.profilegc.accumulatePure", ulong function(string file, int line, string funcname, string name, ulong size) @nogc nothrow pure);
return impl(file, line, funcname, name, size);
}

auto func = cast(ulong function(string file, int line, string funcname, string name, ulong size) @nogc nothrow pure)&impureBypass;
return func(file, line, funcname, name, size);
}

version (D_ProfileGC)
{
/**
* TraceGC wrapper generator around the runtime hook `Hook`.
* Params:
Expand Down
12 changes: 12 additions & 0 deletions druntime/src/rt/profilegc.d
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ public void accumulate(string file, uint line, string funcname, string type, ulo
}
}

public ulong accumulatePure(string file, int line, string funcname, string name, ulong size) @nogc nothrow pure
{
static ulong impureBypass(string file, int line, string funcname, string name, ulong size) @nogc nothrow
{
accumulate(file, line, funcname, name, size);
return size;
}

auto func = cast(ulong function(string file, int line, string funcname, string name, ulong size) @nogc nothrow pure)&impureBypass;
return func(file, line, funcname, name, size);
}

// Merge thread local newCounts into globalNewCounts
static ~this()
{
Expand Down
Loading