loop unrolled for stack marking
This commit is contained in:
parent
f94941964d
commit
f45967537f
3 changed files with 33 additions and 1 deletions
|
|
@ -626,10 +626,23 @@ else:
|
||||||
# We use a jmp_buf buffer that is in the C stack.
|
# We use a jmp_buf buffer that is in the C stack.
|
||||||
# Used to traverse the stack and registers assuming
|
# Used to traverse the stack and registers assuming
|
||||||
# that 'setjmp' will save registers in the C stack.
|
# that 'setjmp' will save registers in the C stack.
|
||||||
|
type PStackSlice = ptr array [0..7, pointer]
|
||||||
var registers: C_JmpBuf
|
var registers: C_JmpBuf
|
||||||
if c_setjmp(registers) == 0'i32: # To fill the C stack with registers.
|
if c_setjmp(registers) == 0'i32: # To fill the C stack with registers.
|
||||||
var max = cast[TAddress](stackBottom)
|
var max = cast[TAddress](stackBottom)
|
||||||
var sp = cast[TAddress](addr(registers))
|
var sp = cast[TAddress](addr(registers))
|
||||||
|
# loop unrolled:
|
||||||
|
while sp <% max - 8*sizeof(pointer):
|
||||||
|
gcMark(cast[PStackSlice](sp)[0])
|
||||||
|
gcMark(cast[PStackSlice](sp)[1])
|
||||||
|
gcMark(cast[PStackSlice](sp)[2])
|
||||||
|
gcMark(cast[PStackSlice](sp)[3])
|
||||||
|
gcMark(cast[PStackSlice](sp)[4])
|
||||||
|
gcMark(cast[PStackSlice](sp)[5])
|
||||||
|
gcMark(cast[PStackSlice](sp)[6])
|
||||||
|
gcMark(cast[PStackSlice](sp)[7])
|
||||||
|
sp = sp +% sizeof(pointer)*8
|
||||||
|
# last few entries:
|
||||||
while sp <=% max:
|
while sp <=% max:
|
||||||
gcMark(cast[ppointer](sp)[])
|
gcMark(cast[ppointer](sp)[])
|
||||||
sp = sp +% sizeof(pointer)
|
sp = sp +% sizeof(pointer)
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ type
|
||||||
TReprClosure {.final.} = object # we cannot use a global variable here
|
TReprClosure {.final.} = object # we cannot use a global variable here
|
||||||
# as this wouldn't be thread-safe
|
# as this wouldn't be thread-safe
|
||||||
marked: TCellSet
|
marked: TCellSet
|
||||||
recdepth: int # do not recurse endless
|
recdepth: int # do not recurse endlessly
|
||||||
indent: int # indentation
|
indent: int # indentation
|
||||||
|
|
||||||
when not defined(useNimRtl):
|
when not defined(useNimRtl):
|
||||||
|
|
|
||||||
19
tests/accept/compile/teval1.nim
Normal file
19
tests/accept/compile/teval1.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import macros
|
||||||
|
|
||||||
|
proc testProc: string {.compileTime.} =
|
||||||
|
result = ""
|
||||||
|
result = result & ""
|
||||||
|
|
||||||
|
when true:
|
||||||
|
macro test(n: stmt): stmt =
|
||||||
|
result = newNimNode(nnkStmtList)
|
||||||
|
echo "#", testProc(), "#"
|
||||||
|
test:
|
||||||
|
"hi"
|
||||||
|
|
||||||
|
const
|
||||||
|
x = testProc()
|
||||||
|
|
||||||
|
echo "##", x, "##"
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue