first steps to thread local heaps

This commit is contained in:
Araq 2011-06-02 13:02:40 +02:00
commit 3260702a60
21 changed files with 1072 additions and 633 deletions

View file

@ -1105,8 +1105,8 @@ proc rdSetElemLoc(a: TLoc, setType: PType): PRope =
# before the set operation
result = rdCharLoc(a)
assert(setType.kind == tySet)
if (firstOrd(setType) != 0):
result = ropef("($1-$2)", [result, toRope(firstOrd(setType))])
if firstOrd(setType) != 0:
result = ropef("($1- $2)", [result, toRope(firstOrd(setType))])
proc fewCmps(s: PNode): bool =
# this function estimates whether it is better to emit code

View file

@ -431,9 +431,18 @@ proc assignLocalVar(p: BProc, s: PSym) =
proc declareThreadVar(m: BModule, s: PSym) =
if optThreads in gGlobalOptions:
app(m.s[cfsVars], "NIM_THREADVAR ")
app(m.s[cfsVars], getTypeDesc(m, s.loc.t))
if platform.OS[targetOS].props.contains(ospLacksThreadVars):
# we gather all thread locals var into a struct and put that into
# nim__dat.c; we need to allocate storage for that somehow, can't use
# the thread local storage allocator for it :-(
# XXX we need to adapt expr() too, every reference to a thread local var
# generates quite some code ...
InternalError("no workaround for lack of thread local vars implemented")
else:
app(m.s[cfsVars], "NIM_THREADVAR ")
app(m.s[cfsVars], getTypeDesc(m, s.loc.t))
else:
app(m.s[cfsVars], getTypeDesc(m, s.loc.t))
proc assignGlobalVar(p: BProc, s: PSym) =
if s.loc.k == locNone:
@ -640,8 +649,8 @@ proc genProcAux(m: BModule, prc: PSym) =
assignParam(p, param)
genStmts(p, prc.ast.sons[codePos]) # modifies p.locals, p.init, etc.
if sfPure in prc.flags:
generatedProc = ropeff("$1 {$n$2$3$4}$n", "define $1 {$n$2$3$4}$n", [header,
p.s[cpsLocals], p.s[cpsInit], p.s[cpsStmts]])
generatedProc = ropeff("$1 {$n$2$3$4}$n", "define $1 {$n$2$3$4}$n",
[header, p.s[cpsLocals], p.s[cpsInit], p.s[cpsStmts]])
else:
generatedProc = ropeff("$1 {$n", "define $1 {$n", [header])
if optStackTrace in prc.options:
@ -756,7 +765,8 @@ proc getFileHeader(cfilenoext: string): PRope =
"; (c) 2011 Andreas Rumpf$n", [toRope(versionAsString)])
else:
result = ropeff("/* Generated by Nimrod Compiler v$1 */$n" &
"/* (c) 2011 Andreas Rumpf */$n" & "/* Compiled for: $2, $3, $4 */$n" &
"/* (c) 2011 Andreas Rumpf */$n" &
"/* Compiled for: $2, $3, $4 */$n" &
"/* Command for C compiler:$n $5 */$n",
"; Generated by Nimrod Compiler v$1$n" &
"; (c) 2011 Andreas Rumpf$n" & "; Compiled for: $2, $3, $4$n" &

View file

@ -27,7 +27,8 @@ type
TInfoOSProp* = enum
ospNeedsPIC, # OS needs PIC for libraries
ospCaseInsensitive, # OS filesystem is case insensitive
ospPosix # OS is posix-like
ospPosix, # OS is posix-like
ospLacksThreadVars # OS lacks proper __threadvar support
TInfoOSProps* = set[TInfoOSProp]
TInfoOS* = tuple[name: string, parDir: string, dllFrmt: string,
altDirSep: string, objExt: string, newLine: string,
@ -129,7 +130,7 @@ const
(name: "MacOSX", parDir: "..", dllFrmt: "lib$1.dylib", altDirSep: ":",
objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/",
scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".",
props: {ospNeedsPIC, ospPosix}),
props: {ospNeedsPIC, ospPosix, ospLacksThreadVars}),
(name: "EcmaScript", parDir: "..",
dllFrmt: "lib$1.so", altDirSep: "/",
objExt: ".o", newLine: "\x0A",