fixes #11082
This commit is contained in:
parent
7ce24d91a3
commit
02920c2cd9
2 changed files with 6 additions and 3 deletions
|
|
@ -207,7 +207,7 @@ proc blockLeaveActions(p: BProc, howManyTrys, howManyExcepts: int) =
|
||||||
let tryStmt = p.nestedTryStmts.pop
|
let tryStmt = p.nestedTryStmts.pop
|
||||||
if not p.module.compileToCpp or optNoCppExceptions in p.config.globalOptions:
|
if not p.module.compileToCpp or optNoCppExceptions in p.config.globalOptions:
|
||||||
# Pop safe points generated by try
|
# Pop safe points generated by try
|
||||||
if not tryStmt.inExcept and not isDefined(p.config, "nimQuirky"):
|
if not tryStmt.inExcept:
|
||||||
linefmt(p, cpsStmts, "#popSafePoint();$n", [])
|
linefmt(p, cpsStmts, "#popSafePoint();$n", [])
|
||||||
|
|
||||||
# Pop this try-stmt of the list of nested trys
|
# Pop this try-stmt of the list of nested trys
|
||||||
|
|
@ -449,7 +449,7 @@ proc genReturnStmt(p: BProc, t: PNode) =
|
||||||
blockLeaveActions(p,
|
blockLeaveActions(p,
|
||||||
howManyTrys = p.nestedTryStmts.len,
|
howManyTrys = p.nestedTryStmts.len,
|
||||||
howManyExcepts = p.inExceptBlockLen)
|
howManyExcepts = p.inExceptBlockLen)
|
||||||
if (p.finallySafePoints.len > 0) and not isDefined(p.config, "nimQuirky"):
|
if (p.finallySafePoints.len > 0) and not p.noSafePoints:
|
||||||
# If we're in a finally block, and we came here by exception
|
# If we're in a finally block, and we came here by exception
|
||||||
# consume it before we return.
|
# consume it before we return.
|
||||||
var safePoint = p.finallySafePoints[p.finallySafePoints.len-1]
|
var safePoint = p.finallySafePoints[p.finallySafePoints.len-1]
|
||||||
|
|
@ -1004,6 +1004,8 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) =
|
||||||
(t.kind == nkHiddenTryStmt and sfSystemModule in p.module.module.flags)
|
(t.kind == nkHiddenTryStmt and sfSystemModule in p.module.module.flags)
|
||||||
if not quirkyExceptions:
|
if not quirkyExceptions:
|
||||||
p.module.includeHeader("<setjmp.h>")
|
p.module.includeHeader("<setjmp.h>")
|
||||||
|
else:
|
||||||
|
p.noSafePoints = true
|
||||||
genLineDir(p, t)
|
genLineDir(p, t)
|
||||||
discard cgsym(p.module, "Exception")
|
discard cgsym(p.module, "Exception")
|
||||||
var safePoint: Rope
|
var safePoint: Rope
|
||||||
|
|
@ -1021,7 +1023,7 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) =
|
||||||
linefmt(p, cpsStmts, "$1.status = setjmp($1.context);$n", [safePoint])
|
linefmt(p, cpsStmts, "$1.status = setjmp($1.context);$n", [safePoint])
|
||||||
startBlock(p, "if ($1.status == 0) {$n", [safePoint])
|
startBlock(p, "if ($1.status == 0) {$n", [safePoint])
|
||||||
var length = sonsLen(t)
|
var length = sonsLen(t)
|
||||||
add(p.nestedTryStmts, (t, false))
|
add(p.nestedTryStmts, (t, quirkyExceptions))
|
||||||
expr(p, t.sons[0], d)
|
expr(p, t.sons[0], d)
|
||||||
if not quirkyExceptions:
|
if not quirkyExceptions:
|
||||||
linefmt(p, cpsStmts, "#popSafePoint();$n", [])
|
linefmt(p, cpsStmts, "#popSafePoint();$n", [])
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ type
|
||||||
threadVarAccessed*: bool # true if the proc already accessed some threadvar
|
threadVarAccessed*: bool # true if the proc already accessed some threadvar
|
||||||
hasCurFramePointer*: bool # true if _nimCurFrame var needed to recover after
|
hasCurFramePointer*: bool # true if _nimCurFrame var needed to recover after
|
||||||
# exception is generated
|
# exception is generated
|
||||||
|
noSafePoints*: bool # the proc doesn't use safe points in exception handling
|
||||||
lastLineInfo*: TLineInfo # to avoid generating excessive 'nimln' statements
|
lastLineInfo*: TLineInfo # to avoid generating excessive 'nimln' statements
|
||||||
currLineInfo*: TLineInfo # AST codegen will make this superfluous
|
currLineInfo*: TLineInfo # AST codegen will make this superfluous
|
||||||
nestedTryStmts*: seq[tuple[n: PNode, inExcept: bool]]
|
nestedTryStmts*: seq[tuple[n: PNode, inExcept: bool]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue