mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
gc:stack compiles with --threads:on
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
when defined(nimphpext):
|
||||
proc roundup(x, v: int): int {.inline.} =
|
||||
result = (x + (v-1)) and not (v-1)
|
||||
proc emalloc(size: int): pointer {.importc:"_emalloc".}
|
||||
proc efree(mem: pointer) {.importc:"_efree".}
|
||||
proc emalloc(size: int): pointer {.importc: "_emalloc".}
|
||||
proc efree(mem: pointer) {.importc: "_efree".}
|
||||
|
||||
proc osAllocPages(size: int): pointer {.inline.} =
|
||||
emalloc(size)
|
||||
@@ -144,11 +144,12 @@ proc runFinalizers(c: Chunk) =
|
||||
(cast[Finalizer](it.typ.finalizer))(it+!sizeof(ObjHeader))
|
||||
it = it.nextFinal
|
||||
|
||||
proc dealloc(r: var MemRegion; p: pointer) =
|
||||
let it = cast[ptr ObjHeader](p-!sizeof(ObjHeader))
|
||||
if it.typ != nil and it.typ.finalizer != nil:
|
||||
(cast[Finalizer](it.typ.finalizer))(p)
|
||||
it.typ = nil
|
||||
when false:
|
||||
proc dealloc(r: var MemRegion; p: pointer) =
|
||||
let it = cast[ptr ObjHeader](p-!sizeof(ObjHeader))
|
||||
if it.typ != nil and it.typ.finalizer != nil:
|
||||
(cast[Finalizer](it.typ.finalizer))(p)
|
||||
it.typ = nil
|
||||
|
||||
proc deallocAll(r: var MemRegion; head: Chunk) =
|
||||
var it = head
|
||||
@@ -187,6 +188,8 @@ proc obstackPtr*(): StackPtr = tlRegion.obstackPtr()
|
||||
proc setObstackPtr*(sp: StackPtr) = tlRegion.setObstackPtr(sp)
|
||||
proc deallocAll*() = tlRegion.deallocAll()
|
||||
|
||||
proc deallocOsPages(r: var MemRegion) = r.deallocAll()
|
||||
|
||||
proc joinRegion*(dest: var MemRegion; src: MemRegion) =
|
||||
# merging is not hard.
|
||||
if dest.head.isNil:
|
||||
@@ -424,6 +427,13 @@ proc realloc(p: pointer, newsize: Natural): pointer =
|
||||
if result == nil: raiseOutOfMem()
|
||||
proc dealloc(p: pointer) = cfree(p)
|
||||
|
||||
proc alloc0(r: var MemRegion; size: Natural): pointer =
|
||||
# ignore the region. That is correct for the channels module
|
||||
# but incorrect in general. XXX
|
||||
result = alloc0(size)
|
||||
|
||||
proc dealloc(r: var MemRegion; p: pointer) = dealloc(p)
|
||||
|
||||
proc allocShared(size: Natural): pointer =
|
||||
result = cmalloc(size)
|
||||
if result == nil: raiseOutOfMem()
|
||||
|
||||
Reference in New Issue
Block a user