Skip to content

Commit 13f9bb8

Browse files
Ico Doornekampzevv
authored andcommitted
*allocShared implementations for boehm and go allocators now depend on the proper *allocImpl procs
1 parent 00742d2 commit 13f9bb8

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

lib/system/alloc.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,10 +1050,10 @@ template instantiateForRegion(allocator: untyped) {.dirty.} =
10501050
result = alloc(sharedHeap, size)
10511051
releaseSys(heapLock)
10521052
else:
1053-
result = alloc(size)
1053+
result = allocImpl(size)
10541054
10551055
proc allocShared0Impl(size: Natural): pointer =
1056-
result = allocShared(size)
1056+
result = allocSharedImpl(size)
10571057
zeroMem(result, size)
10581058
10591059
proc deallocSharedImpl(p: pointer) =
@@ -1062,23 +1062,23 @@ template instantiateForRegion(allocator: untyped) {.dirty.} =
10621062
dealloc(sharedHeap, p)
10631063
releaseSys(heapLock)
10641064
else:
1065-
dealloc(p)
1065+
deallocImpl(p)
10661066
10671067
proc reallocSharedImpl(p: pointer, newSize: Natural): pointer =
10681068
when hasThreadSupport:
10691069
acquireSys(heapLock)
10701070
result = realloc(sharedHeap, p, newSize)
10711071
releaseSys(heapLock)
10721072
else:
1073-
result = realloc(p, newSize)
1073+
result = reallocImpl(p, newSize)
10741074
10751075
proc reallocShared0Impl(p: pointer, oldSize, newSize: Natural): pointer =
10761076
when hasThreadSupport:
10771077
acquireSys(heapLock)
10781078
result = realloc0(sharedHeap, p, oldSize, newSize)
10791079
releaseSys(heapLock)
10801080
else:
1081-
result = realloc0(p, oldSize, newSize)
1081+
result = realloc0Impl(p, oldSize, newSize)
10821082
10831083
when hasThreadSupport:
10841084
template sharedMemStatsShared(v: int) =

lib/system/mmdisp.nim

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ when defined(boehmgc):
122122
zeroMem(cast[pointer](cast[int](result) + oldsize), newsize - oldsize)
123123
proc deallocImpl(p: pointer) = boehmDealloc(p)
124124

125-
proc allocSharedImpl(size: Natural): pointer = alloc(size)
126-
proc allocShared0Impl(size: Natural): pointer = alloc(size)
127-
proc reallocSharedImpl(p: pointer, newSize: Natural): pointer = realloc(p, newSize)
128-
proc reallocShared0Impl(p: pointer, oldSize, newSize: Natural): pointer = realloc0Impl(p, newSize, oldSize)
129-
proc deallocSharedImpl(p: pointer) = dealloc(p)
125+
proc allocSharedImpl(size: Natural): pointer = allocImpl(size)
126+
proc allocShared0Impl(size: Natural): pointer = alloc0Impl(size)
127+
proc reallocSharedImpl(p: pointer, newsize: Natural): pointer = reallocImpl(p, newsize)
128+
proc reallocShared0Impl(p: pointer, oldsize, newsize: Natural): pointer = realloc0Impl(p, oldsize, newsize)
129+
proc deallocSharedImpl(p: pointer) = deallocImpl(p)
130130

131131
when hasThreadSupport:
132132
proc getFreeSharedMem(): int =
@@ -281,19 +281,11 @@ elif defined(gogc):
281281
proc deallocImpl(p: pointer) =
282282
discard
283283
284-
proc allocSharedImpl(size: Natural): pointer =
285-
result = alloc(size)
286-
287-
proc allocShared0Impl(size: Natural): pointer =
288-
result = alloc0(size)
289-
290-
proc reallocSharedImpl(p: pointer, newsize: Natural): pointer =
291-
result = realloc(p, newsize)
292-
293-
proc reallocShared0Impl(p: pointer, oldsize, newsize: Natural): pointer =
294-
result = realloc0(p, oldsize, newsize)
295-
296-
proc deallocSharedImpl(p: pointer) = dealloc(p)
284+
proc allocSharedImpl(size: Natural): pointer = allocImpl(size)
285+
proc allocShared0Impl(size: Natural): pointer = alloc0Impl(size)
286+
proc reallocSharedImpl(p: pointer, newsize: Natural): pointer = reallocImpl(p, newsize)
287+
proc reallocShared0Impl(p: pointer, oldsize, newsize: Natural): pointer = realloc0Impl(p, oldsize, newsize)
288+
proc deallocSharedImpl(p: pointer) = deallocImpl(p)
297289
298290
when hasThreadSupport:
299291
proc getFreeSharedMem(): int = discard

tests/destructor/tbintree2.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
discard """
22
cmd: '''nim c -d:allocStats --newruntime $file'''
33
output: '''0
4-
(allocCount: 12, deallocCount: 9)'''
4+
(allocCount: 6, deallocCount: 6)'''
55
"""
66

77
import system / ansi_c

tests/destructor/tgcdestructors.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ a: @[4, 2, 3]
1010
0
1111
30
1212
true
13-
(allocCount: 123, deallocCount: 82)'''
13+
(allocCount: 41, deallocCount: 41)'''
1414
"""
1515

1616
include system / ansi_c

0 commit comments

Comments
 (0)