Merge pull request #4142 from endragor/gc-allow-skip-stack
Added stackSize parameter to GC_step
This commit is contained in:
commit
6e6c15081d
3 changed files with 34 additions and 4 deletions
|
|
@ -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() =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue