diff options
author | Araq <rumpf_a@web.de> | 2011-01-18 02:22:01 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-01-18 02:22:01 +0100 |
commit | 66cfc851a1aeb9eb8d011a8e0c53b0f8ee83f770 (patch) | |
tree | 197c0b859516210ab9d32e8da958ed05a03bbe3f /rod | |
parent | 0f743e01833290e2995756fbd459728b12d833be (diff) | |
download | Nim-66cfc851a1aeb9eb8d011a8e0c53b0f8ee83f770.tar.gz |
basic thread support; still broken on Windows; untested on Mac OS X
Diffstat (limited to 'rod')
-rwxr-xr-x | rod/ccgstmts.nim | 4 | ||||
-rwxr-xr-x | rod/cgen.nim | 23 |
2 files changed, 10 insertions, 17 deletions
diff --git a/rod/ccgstmts.nim b/rod/ccgstmts.nim index f98a59580..2ac87824c 100755 --- a/rod/ccgstmts.nim +++ b/rod/ccgstmts.nim @@ -477,7 +477,7 @@ proc genTryStmtCpp(p: BProc, t: PNode) = rethrowFlag = getTempName() appf(p.s[cpsLocals], "volatile NIM_BOOL $1 = NIM_FALSE;$n", [rethrowFlag]) if optStackTrace in p.Options: - app(p.s[cpsStmts], "framePtr = (TFrame*)&F;" & tnl) + appcg(p, cpsStmts, "#framePtr = (TFrame*)&F;" & tnl) app(p.s[cpsStmts], "try {" & tnl) add(p.nestedTryStmts, t) genStmts(p, t.sons[0]) @@ -542,7 +542,7 @@ proc genTryStmt(p: BProc, t: PNode) = appcg(p, cpsStmts, "#pushSafePoint(&$1);$n" & "$1.status = setjmp($1.context);$n", [safePoint]) if optStackTrace in p.Options: - app(p.s[cpsStmts], "framePtr = (TFrame*)&F;" & tnl) + appcg(p, cpsStmts, "#framePtr = (TFrame*)&F;" & tnl) appf(p.s[cpsStmts], "if ($1.status == 0) {$n", [safePoint]) var length = sonsLen(t) add(p.nestedTryStmts, t) diff --git a/rod/cgen.nim b/rod/cgen.nim index 360b46a3b..f99a06a97 100755 --- a/rod/cgen.nim +++ b/rod/cgen.nim @@ -386,10 +386,10 @@ proc assignGlobalVar(p: BProc, s: PSym) = useHeader(p.module, s) if lfNoDecl in s.loc.flags: return if sfImportc in s.flags: app(p.module.s[cfsVars], "extern ") + if sfThreadVar in s.flags: app(p.module.s[cfsVars], "NIM_THREADVAR ") app(p.module.s[cfsVars], getTypeDesc(p.module, s.loc.t)) if sfRegister in s.flags: app(p.module.s[cfsVars], " register") if sfVolatile in s.flags: app(p.module.s[cfsVars], " volatile") - if sfThreadVar in s.flags: app(p.module.s[cfsVars], " NIM_THREADVAR") appf(p.module.s[cfsVars], " $1;$n", [s.loc.r]) if {optStackTrace, optEndb} * p.module.module.options == {optStackTrace, optEndb}: @@ -550,19 +550,12 @@ proc retIsNotVoid(s: PSym): bool = result = (s.typ.sons[0] != nil) and not isInvalidReturnType(s.typ.sons[0]) proc initFrame(p: BProc, procname, filename: PRope): PRope = - inc(p.labels, 5) - result = ropeff("F.procname = $1;$n" & "F.prev = framePtr;$n" & - "F.filename = $2;$n" & "F.line = 0;$n" & "framePtr = (TFrame*)&F;$n", - "%LOC$3 = getelementptr %TF %F, %NI 1$n" & - "%LOC$4 = getelementptr %TF %F, %NI 0$n" & - "%LOC$5 = getelementptr %TF %F, %NI 3$n" & - "%LOC$6 = getelementptr %TF %F, %NI 2$n" & "store i8* $1, i8** %LOC$3$n" & - "store %TFrame* @framePtr, %TFrame** %LOC$4$n" & - "store i8* $2, i8** %LOC$5$n" & "store %NI 0, %NI* %LOC$6$n" & - "%LOC$7 = bitcast %TF* %F to %TFrame*$n" & - "store %TFrame* %LOC$7, %TFrame** @framePtr$n", [procname, filename, - toRope(p.labels), toRope(p.labels - 1), toRope(p.labels - 2), - toRope(p.labels - 3), toRope(p.labels - 4)]) + result = ropecg(p.module, + "F.procname = $1;$n" & + "F.prev = #framePtr;$n" & + "F.filename = $2;$n" & + "F.line = 0;$n" & + "framePtr = (TFrame*)&F;$n", [procname, filename]) proc deinitFrame(p: BProc): PRope = inc(p.labels, 3) @@ -693,10 +686,10 @@ proc genVarPrototype(m: BModule, sym: PSym) = [sym.loc.r, getTypeDesc(m, sym.loc.t)]) else: app(m.s[cfsVars], "extern ") + if sfThreadVar in sym.flags: app(m.s[cfsVars], "NIM_THREADVAR ") app(m.s[cfsVars], getTypeDesc(m, sym.loc.t)) if sfRegister in sym.flags: app(m.s[cfsVars], " register") if sfVolatile in sym.flags: app(m.s[cfsVars], " volatile") - if sfThreadVar in sym.flags: app(m.s[cfsVars], " NIM_THREADVAR") appf(m.s[cfsVars], " $1;$n", [sym.loc.r]) proc genConstPrototype(m: BModule, sym: PSym) = |