mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-25 08:43:58 +00:00
Merge pull request #4142 from endragor/gc-allow-skip-stack
Added stackSize parameter to GC_step
This commit is contained in:
@@ -980,7 +980,19 @@ when withRealTime:
|
||||
collectCTBody(gch)
|
||||
release(gch)
|
||||
|
||||
proc GC_step*(us: int, strongAdvice = false) = GC_step(gch, us, strongAdvice)
|
||||
proc GC_step*(us: int, strongAdvice = false, stackSize = -1) {.noinline.} =
|
||||
var stackTop {.volatile.}: pointer
|
||||
let prevStackBottom = gch.stackBottom
|
||||
if stackSize >= 0:
|
||||
stackTop = addr(stackTop)
|
||||
when stackIncreases:
|
||||
gch.stackBottom = cast[pointer](
|
||||
cast[ByteAddress](stackTop) - sizeof(pointer) * 6 - stackSize)
|
||||
else:
|
||||
gch.stackBottom = cast[pointer](
|
||||
cast[ByteAddress](stackTop) + sizeof(pointer) * 6 + stackSize)
|
||||
GC_step(gch, us, strongAdvice)
|
||||
gch.stackBottom = prevStackBottom
|
||||
|
||||
when not defined(useNimRtl):
|
||||
proc GC_disable() =
|
||||
|
||||
@@ -956,7 +956,19 @@ when withRealTime:
|
||||
strongAdvice:
|
||||
collectCTBody(gch)
|
||||
|
||||
proc GC_step*(us: int, strongAdvice = false) = GC_step(gch, us, strongAdvice)
|
||||
proc GC_step*(us: int, strongAdvice = false, stackSize = -1) {.noinline.} =
|
||||
var stackTop {.volatile.}: pointer
|
||||
let prevStackBottom = gch.stackBottom
|
||||
if stackSize >= 0:
|
||||
stackTop = addr(stackTop)
|
||||
when stackIncreases:
|
||||
gch.stackBottom = cast[pointer](
|
||||
cast[ByteAddress](stackTop) - sizeof(pointer) * 6 - stackSize)
|
||||
else:
|
||||
gch.stackBottom = cast[pointer](
|
||||
cast[ByteAddress](stackTop) + sizeof(pointer) * 6 + stackSize)
|
||||
GC_step(gch, us, strongAdvice)
|
||||
gch.stackBottom = prevStackBottom
|
||||
|
||||
when not defined(useNimRtl):
|
||||
proc GC_disable() =
|
||||
|
||||
Reference in New Issue
Block a user