ARC related bugfixes and refactorings (#12781)

This commit is contained in:
Andreas Rumpf 2019-12-05 16:59:06 +01:00 • committed by Miran
commit 3fbb3bfd3f
11 changed files with 381 additions and 367 deletions

View file

@ -3218,6 +3218,9 @@ proc `<`*[T: tuple](x, y: T): bool =
const
usesDestructors = defined(gcDestructors) or defined(gcHooks)
when not usesDestructors:
{.pragma: nodestroy.}
when not defined(nimscript) and hasAlloc:
type
GC_Strategy* = enum ## The strategy the GC should use for the application.
@ -3671,8 +3674,6 @@ when not defined(JS): #and not defined(nimscript):
prev: PSafePoint # points to next safe point ON THE STACK
status: int
context: C_JmpBuf
hasRaiseAction: bool
raiseAction: proc (e: ref Exception): bool {.closure.}
SafePoint = TSafePoint
when declared(initAllocator):
@ -3776,11 +3777,15 @@ when not defined(JS): #and not defined(nimscript):
## Retrieves the current exception; if there is none, `nil` is returned.
result = currException
proc nimBorrowCurrentException(): ref Exception {.compilerRtl, inl, benign, nodestroy.} =
# .nodestroy here so that we do not produce a write barrier as the
# C codegen only uses it in a borrowed way:
result = currException
proc getCurrentExceptionMsg*(): string {.inline, benign.} =
## Retrieves the error message that was attached to the current
## exception; if there is none, `""` is returned.
var e = getCurrentException()
return if e == nil: "" else: e.msg
return if currException == nil: "" else: currException.msg
proc setCurrentException*(exc: ref Exception) {.inline, benign.} =
## Sets the current exception.