atomicInc global alloc counters (#20571)

(cherry picked from commit ed26156c99)
This commit is contained in:
Antonis Geralis
2022-10-16 02:07:22 +03:00
committed by narimiran
parent 425f828178
commit b47d12fe0a
2 changed files with 9 additions and 9 deletions

View File

@@ -1536,6 +1536,14 @@ const
## and expect a reasonable result - use the `isNaN` or `classify` procedure
## in the `math module <math.html>`_ for checking for NaN.
when not defined(nimscript):
proc atomicInc*(memLoc: var int, x: int = 1): int {.inline,
discardable, raises: [], tags: [], benign.}
## Atomic increment of `memLoc`. Returns the value after the operation.
proc atomicDec*(memLoc: var int, x: int = 1): int {.inline,
discardable, raises: [], tags: [], benign.}
## Atomic decrement of `memLoc`. Returns the value after the operation.
include "system/memalloc"
@@ -1808,14 +1816,6 @@ when not declared(sysFatal):
when not defined(nimscript):
{.push stackTrace: off, profiler: off.}
proc atomicInc*(memLoc: var int, x: int = 1): int {.inline,
discardable, benign.}
## Atomic increment of `memLoc`. Returns the value after the operation.
proc atomicDec*(memLoc: var int, x: int = 1): int {.inline,
discardable, benign.}
## Atomic decrement of `memLoc`. Returns the value after the operation.
include "system/atomics"
{.pop.}

View File

@@ -80,7 +80,7 @@ when hasAlloc and not defined(js):
when defined(nimAllocStats):
var stats: AllocStats
template incStat(what: untyped) = inc stats.what
template incStat(what: untyped) = atomicInc stats.what
proc getAllocStats*(): AllocStats = stats
else: