Skip to content

Commit 40fe59b

Browse files
authored
remove alloc cruft (#25170)
1 parent 8b9972c commit 40fe59b

File tree

2 files changed

+0
-26
lines changed

2 files changed

+0
-26
lines changed

lib/system.nim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,8 +2182,6 @@ when notJSnotNims and not gotoBasedExceptions:
21822182
SafePoint = TSafePoint
21832183

21842184
when not defined(js):
2185-
when declared(initAllocator):
2186-
initAllocator()
21872185
when hasThreadSupport:
21882186
when hostOS != "standalone":
21892187
include system/threadimpl

lib/system/alloc.nim

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ type
9797
key, upperBound: int
9898
level: int
9999

100-
const
101-
RegionHasLock = false # hasThreadSupport and defined(gcDestructors)
102-
103100
type
104101
FreeCell {.final, pure.} = object
105102
# A free cell is a pointer that has been freed, meaning it became available for reuse.
@@ -161,8 +158,6 @@ type
161158
llmem: PLLChunk
162159
currMem, maxMem, freeMem, occ: int # memory sizes (allocated from OS)
163160
lastSize: int # needed for the case that OS gives us pages linearly
164-
when RegionHasLock:
165-
lock: SysLock
166161
when defined(gcDestructors):
167162
sharedFreeListBigChunks: PBigChunk # make no attempt at avoiding false sharing for now for this object field
168163

@@ -680,12 +675,6 @@ proc getBigChunk(a: var MemRegion, size: int): PBigChunk =
680675
sysAssert((size and PageMask) == 0, "getBigChunk: unaligned chunk")
681676
result = findSuitableBlock(a, fl, sl)
682677

683-
when RegionHasLock:
684-
if not a.lockActive:
685-
a.lockActive = true
686-
initSysLock(a.lock)
687-
acquireSys a.lock
688-
689678
if result == nil:
690679
if size < nimMinHeapPages * PageSize:
691680
result = requestOsChunks(a, nimMinHeapPages * PageSize)
@@ -707,16 +696,9 @@ proc getBigChunk(a: var MemRegion, size: int): PBigChunk =
707696

708697
incl(a, a.chunkStarts, pageIndex(result))
709698
dec(a.freeMem, size)
710-
when RegionHasLock:
711-
releaseSys a.lock
712699

713700
proc getHugeChunk(a: var MemRegion; size: int): PBigChunk =
714701
result = cast[PBigChunk](allocPages(a, size))
715-
when RegionHasLock:
716-
if not a.lockActive:
717-
a.lockActive = true
718-
initSysLock(a.lock)
719-
acquireSys a.lock
720702
incCurrMem(a, size)
721703
# XXX add this to the heap links. But also remove it from it later.
722704
when false: a.addHeapLink(result, size)
@@ -728,8 +710,6 @@ proc getHugeChunk(a: var MemRegion; size: int): PBigChunk =
728710
result.prevSize = 1
729711
result.owner = addr a
730712
incl(a, a.chunkStarts, pageIndex(result))
731-
when RegionHasLock:
732-
releaseSys a.lock
733713

734714
proc freeHugeChunk(a: var MemRegion; c: PBigChunk) =
735715
let size = c.size
@@ -794,8 +774,6 @@ else:
794774
template untrackSize(x) = discard
795775

796776
proc deallocBigChunk(a: var MemRegion, c: PBigChunk) =
797-
when RegionHasLock:
798-
acquireSys a.lock
799777
dec a.occ, c.size
800778
untrackSize(c.size)
801779
sysAssert a.occ >= 0, "rawDealloc: negative occupied memory (case B)"
@@ -804,8 +782,6 @@ proc deallocBigChunk(a: var MemRegion, c: PBigChunk) =
804782
del(a, a.root, cast[int](addr(c.data)))
805783
if c.size >= HugeChunkSize: freeHugeChunk(a, c)
806784
else: freeBigChunk(a, c)
807-
when RegionHasLock:
808-
releaseSys a.lock
809785

810786
when defined(gcDestructors):
811787
template atomicPrepend(head, elem: untyped) =

0 commit comments

Comments
 (0)