diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2014-10-02 01:35:59 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2014-10-02 01:35:59 +0200 |
commit | c17c8e9afa6ba6a1000fe82b1c8a7af10e3fc698 (patch) | |
tree | 6ff81df2442dac972f41a0ede4f609ae34c1f312 /compiler | |
parent | 2154906fc9b02aa660caec738ebc11529e89bfad (diff) | |
parent | cb6441e73d976dcf59b1e55236887fe5d3a1d6ec (diff) | |
download | Nim-c17c8e9afa6ba6a1000fe82b1c8a7af10e3fc698.tar.gz |
Merge pull request #1545 from rbehrends/setjmp-perf
Improve setjmp()/longjmp() performance.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgstmts.nim | 9 | ||||
-rw-r--r-- | compiler/cgen.nim | 2 | ||||
-rw-r--r-- | compiler/condsyms.nim | 4 |
3 files changed, 13 insertions, 2 deletions
diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index cb9eebb32..8b0a8e9bb 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -832,7 +832,14 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) = discard cgsym(p.module, "E_Base") linefmt(p, cpsLocals, "#TSafePoint $1;$n", safePoint) linefmt(p, cpsStmts, "#pushSafePoint(&$1);$n", safePoint) - linefmt(p, cpsStmts, "$1.status = setjmp($1.context);$n", safePoint) + if isDefined("nimStdSetjmp"): + linefmt(p, cpsStmts, "$1.status = setjmp($1.context);$n", safePoint) + elif isDefined("nimSigSetjmp"): + linefmt(p, cpsStmts, "$1.status = sigsetjmp($1.context, 0);$n", safePoint) + elif isDefined("nimRawSetjmp"): + linefmt(p, cpsStmts, "$1.status = _setjmp($1.context);$n", safePoint) + else: + linefmt(p, cpsStmts, "$1.status = setjmp($1.context);$n", safePoint) startBlock(p, "if ($1.status == 0) {$n", [safePoint]) var length = sonsLen(t) add(p.nestedTryStmts, t) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 315b55801..359fa3309 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -13,7 +13,7 @@ import ast, astalgo, strutils, hashes, trees, platform, magicsys, extccomp, options, intsets, nversion, nimsets, msgs, crc, bitsets, idents, lists, types, ccgutils, os, - times, ropes, math, passes, rodread, wordrecg, treetab, cgmeth, + times, ropes, math, passes, rodread, wordrecg, treetab, cgmeth, condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases, lowerings, semparallel diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index dc61d2f89..238dbf5c7 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -136,3 +136,7 @@ proc initDefines*() = declareSymbol("emulatedthreadvars") if platform.OS[targetOS].props.contains(ospLacksThreadVars): defineSymbol("emulatedthreadvars") + case targetOS + of osSolaris, osNetbsd, osFreebsd, osOpenbsd, osMacosx: + defineSymbol("nimRawSetjmp") + else: discard |