new compiler option tlsEmulation

This commit is contained in:
Araq
2011-10-27 21:03:53 +02:00
parent abe9dfafe8
commit 5e5e4abfee
11 changed files with 28 additions and 28 deletions

View File

@@ -655,9 +655,7 @@ proc genAsgn(p: BProc, e: PNode, fastAsgn: bool) =
asgnFieldDiscriminant(p, e)
proc genStmts(p: BProc, t: PNode) =
var
a: TLoc
prc: PSym
var a: TLoc
case t.kind
of nkEmpty:
nil
@@ -697,7 +695,7 @@ proc genStmts(p: BProc, t: PNode) =
of nkPragma: genPragma(p, t)
of nkProcDef, nkMethodDef, nkConverterDef:
if (t.sons[genericParamsPos].kind == nkEmpty):
prc = t.sons[namePos].sym
var prc = t.sons[namePos].sym
if (optDeadCodeElim notin gGlobalOptions and
sfDeadCodeElim notin getModule(prc).flags) or
({sfExportc, sfCompilerProc} * prc.flags == {sfExportc}) or

View File

@@ -11,9 +11,7 @@
## thread local storage. (**Thank you Mac OS X!**)
proc emulatedThreadVars(): bool {.inline.} =
result = optThreads in gGlobalOptions
# NOW: Use the work-around everywhere, because it should be faster anyway.
#platform.OS[targetOS].props.contains(ospLacksThreadVars)
result = {optThreads, optTlsEmulation} <= gGlobalOptions
proc AccessThreadLocalVar(p: BProc, s: PSym) =
if emulatedThreadVars() and not p.ThreadVarAccessed:

View File

@@ -34,8 +34,8 @@ const
AdvancedUsage = slurp"doc/advopt.txt".replace("//", "")
proc getCommandLineDesc(): string =
result = `%`(HelpMessage, [VersionAsString, platform.os[platform.hostOS].name,
cpu[platform.hostCPU].name]) & Usage
result = (HelpMessage % [VersionAsString, platform.os[platform.hostOS].name,
cpu[platform.hostCPU].name]) & Usage
var
helpWritten: bool # BUGFIX 19
@@ -191,6 +191,7 @@ proc testCompileOption*(switch: string, info: TLineInfo): bool =
of "genscript": result = contains(gGlobalOptions, optGenScript)
of "threads": result = contains(gGlobalOptions, optThreads)
of "taintmode": result = contains(gGlobalOptions, optTaintMode)
of "tlsemulation": result = contains(gGlobalOptions, optTlsEmulation)
else: InvalidCmdLineOption(passCmd1, switch, info)
proc processPath(path: string): string =
@@ -314,6 +315,7 @@ proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
of "assertions", "a": ProcessOnOffSwitch({optAssert}, arg, pass, info)
of "deadcodeelim": ProcessOnOffSwitchG({optDeadCodeElim}, arg, pass, info)
of "threads": ProcessOnOffSwitchG({optThreads}, arg, pass, info)
of "tlsemulation": ProcessOnOffSwitchG({optTlsEmulation}, arg, pass, info)
of "taintmode": ProcessOnOffSwitchG({optTaintMode}, arg, pass, info)
of "opt":
expectArg(switch, arg, pass, info)
@@ -438,7 +440,6 @@ proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
proc ProcessCommand(switch: string, pass: TCmdLinePass) =
var
cmd, arg: string
info: TLineInfo
info = newLineInfo("command line", 1, 1)
var info = newLineInfo("command line", 1, 1)
splitSwitch(switch, cmd, arg, pass, info)
ProcessSwitch(cmd, arg, pass, info)

View File

@@ -88,4 +88,7 @@ proc InitDefines*() =
DefineSymbol(normalize(endianToStr[cpu[targetCPU].endian]))
DefineSymbol(cpu[targetCPU].name)
DefineSymbol(platform.os[targetOS].name)
if platform.OS[targetOS].props.contains(ospLacksThreadVars):
DefineSymbol("emulatedthreadvars")

View File

@@ -59,7 +59,8 @@ type
errCannotInstantiateX, errExprHasNoAddress, errXStackEscape,
errVarForOutParamNeeded,
errPureTypeMismatch, errTypeMismatch, errButExpected, errButExpectedX,
errAmbiguousCallXYZ, errWrongNumberOfArguments, errXCannotBePassedToProcVar,
errAmbiguousCallXYZ, errWrongNumberOfArguments,
errXCannotBePassedToProcVar,
errXCannotBeInParamDecl, errPragmaOnlyInHeaderOfProc, errImplOfXNotAllowed,
errImplOfXexpected, errNoSymbolToBorrowFromFound, errDiscardValue,
errInvalidDiscard, errIllegalConvFromXtoY, errCannotBindXTwice,
@@ -94,7 +95,7 @@ type
errUser,
warnCannotOpenFile,
warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit,
warnCannotWriteMO2, warnCannotReadMO2, warnDeprecated,
warnDeprecated,
warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel,
warnUnknownSubstitutionX, warnLanguageXNotSupported, warnCommentXIgnored,
warnXisPassedToProcVar, warnDerefDeprecated, warnAnalysisLoophole,
@@ -323,8 +324,6 @@ const
warnOctalEscape: "octal escape sequences do not exist; leading zero is ignored [OctalEscape]",
warnXIsNeverRead: "\'$1\' is never read [XIsNeverRead]",
warnXmightNotBeenInit: "\'$1\' might not have been initialized [XmightNotBeenInit]",
warnCannotWriteMO2: "cannot write file \'$1\' [CannotWriteMO2]",
warnCannotReadMO2: "cannot read file \'$1\' [CannotReadMO2]",
warnDeprecated: "\'$1\' is deprecated [Deprecated]",
warnSmallLshouldNotBeUsed: "\'l\' should not be used as an identifier; may look like \'1\' (one) [SmallLshouldNotBeUsed]",
warnUnknownMagic: "unknown magic \'$1\' might crash the compiler [UnknownMagic]",
@@ -354,8 +353,8 @@ const
hintUser: "$1 [User]"]
const
WarningsToStr*: array[0..18, string] = ["CannotOpenFile", "OctalEscape",
"XIsNeverRead", "XmightNotBeenInit", "CannotWriteMO2", "CannotReadMO2",
WarningsToStr*: array[0..16, string] = ["CannotOpenFile", "OctalEscape",
"XIsNeverRead", "XmightNotBeenInit",
"Deprecated", "SmallLshouldNotBeUsed", "UnknownMagic",
"RedefinitionOfLabel", "UnknownSubstitutionX", "LanguageXNotSupported",
"CommentXIgnored", "XisPassedToProcVar", "DerefDeprecated",

View File

@@ -47,7 +47,8 @@ type # please make sure we have under 32 options
optContext, # ideTools: 'context'
optDef, # ideTools: 'def'
optThreadAnalysis, # thread analysis pass
optTaintMode # taint mode turned on
optTaintMode, # taint mode turned on
optTlsEmulation # thread var emulation turned on
TGlobalOptions* = set[TGlobalOption]
TCommands* = enum # Nimrod's commands

View File

@@ -151,24 +151,24 @@ type
type
TEndian* = enum
littleEndian, bigEndian
TInfoCPU* = tuple[name: string, intSize: int, endian: TEndian, floatSize: int,
bit: int]
TInfoCPU* = tuple[name: string, intSize: int, endian: TEndian,
floatSize, bit: int]
const
const
EndianToStr*: array[TEndian, string] = ["littleEndian", "bigEndian"]
CPU*: array[succ(low(TSystemCPU))..high(TSystemCPU), TInfoCPU] = [
(name: "i386", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32),
(name: "m68k", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
(name: "alpha", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
(name: "powerpc", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
(name: "powerpc64", intSize: 64, endian: bigEndian, floatSize: 64, bit: 64),
(name: "powerpc64", intSize: 64, endian: bigEndian, floatSize: 64,bit: 64),
(name: "sparc", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
(name: "vm", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32),
(name: "ia64", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
(name: "amd64", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
(name: "mips", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
(name: "arm", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32),
(name: "ecmascript", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
(name: "ecmascript", intSize: 32, endian: bigEndian,floatSize: 64,bit: 32),
(name: "nimrodvm", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32)]
var

View File

@@ -40,6 +40,7 @@ Advanced options:
(Nimrod, mangled) identifier pairs
--lineDir:on|off generation of #line directive on|off
--threadanalysis:on|off turn thread analysis on|off
--tlsEmulation:on|off turn thread local storage emulation on|off
--taintMode:on|off turn taint mode on|off
--symbolFiles:on|off turn symbol files on|off (experimental)
--skipCfg do not read the general configuration file

View File

@@ -151,7 +151,7 @@ else:
importc: "pthread_attr_setstack", header: "<pthread.h>".}
const
emulatedThreadVars = true
emulatedThreadVars = compileOption("tlsEmulation")
when emulatedThreadVars:
# the compiler generates this proc for us, so that we can get the size of

View File

@@ -18,10 +18,6 @@ incremental compilation
- the loading has to be MUCH more lazy! --> next version: We should re-load
symbol.ast lazily
- adapt thread var implementation to care about the new merge operation
- write test cases: needs test script support
- test thread var
- automate tests:
- test basic recompilation scheme
- test type converters
@@ -77,6 +73,7 @@ version 0.9.XX
- implicit ref/ptr->var conversion; the compiler may store an object
implicitly on the heap for write barrier efficiency; better:
proc specialization in the code gen
- adapt thread var emulation to care about the new merge operation
- EcmaScript needs a new and better code gen: simply adapt the C code gen to it
- tlastmod returns wrong results on BSD (Linux, MacOS X: works)
- nested tuple unpacking

View File

@@ -75,6 +75,8 @@ Compiler Additions
and Objective C somewhat easier.
- Added a ``--nimcache:PATH`` configuration option for control over the output
directory for generated code.
- Added a ``--tlsEmulation:on|off`` switch for control over thread local
storage emulation.
- The compiler and standard library now support a *taint mode*. Input strings
are declared with the ``TaintedString`` string type. If the taint
mode is turned on it is a distinct string type which helps to detect input