diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-05-12 15:00:08 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-05-12 15:00:08 +0200 |
commit | 6e6c15081d8e660ebd4e7111c69962e4da2d2aa5 (patch) | |
tree | 1f4e397f42c903c8e5dcc0708525ee1c50838e2d /lib | |
parent | 4b1348402504f9b874def5f94638ded2a12f2965 (diff) | |
parent | 0dc35b7841375e4a00bcdbc546b38137ca7483f8 (diff) | |
download | Nim-6e6c15081d8e660ebd4e7111c69962e4da2d2aa5.tar.gz |
Merge pull request #4142 from endragor/gc-allow-skip-stack
Added stackSize parameter to GC_step
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/gc.nim | 14 | ||||
-rw-r--r-- | lib/system/gc2.nim | 14 |
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 4f461b5c3..5c2170a17 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -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() = diff --git a/lib/system/gc2.nim b/lib/system/gc2.nim index 6c44d509e..7d54c07be 100644 --- a/lib/system/gc2.nim +++ b/lib/system/gc2.nim @@ -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() = |