new compiler option tlsEmulation
This commit is contained in:
parent
abe9dfafe8
commit
5e5e4abfee
11 changed files with 28 additions and 28 deletions
|
|
@ -655,9 +655,7 @@ proc genAsgn(p: BProc, e: PNode, fastAsgn: bool) =
|
||||||
asgnFieldDiscriminant(p, e)
|
asgnFieldDiscriminant(p, e)
|
||||||
|
|
||||||
proc genStmts(p: BProc, t: PNode) =
|
proc genStmts(p: BProc, t: PNode) =
|
||||||
var
|
var a: TLoc
|
||||||
a: TLoc
|
|
||||||
prc: PSym
|
|
||||||
case t.kind
|
case t.kind
|
||||||
of nkEmpty:
|
of nkEmpty:
|
||||||
nil
|
nil
|
||||||
|
|
@ -697,7 +695,7 @@ proc genStmts(p: BProc, t: PNode) =
|
||||||
of nkPragma: genPragma(p, t)
|
of nkPragma: genPragma(p, t)
|
||||||
of nkProcDef, nkMethodDef, nkConverterDef:
|
of nkProcDef, nkMethodDef, nkConverterDef:
|
||||||
if (t.sons[genericParamsPos].kind == nkEmpty):
|
if (t.sons[genericParamsPos].kind == nkEmpty):
|
||||||
prc = t.sons[namePos].sym
|
var prc = t.sons[namePos].sym
|
||||||
if (optDeadCodeElim notin gGlobalOptions and
|
if (optDeadCodeElim notin gGlobalOptions and
|
||||||
sfDeadCodeElim notin getModule(prc).flags) or
|
sfDeadCodeElim notin getModule(prc).flags) or
|
||||||
({sfExportc, sfCompilerProc} * prc.flags == {sfExportc}) or
|
({sfExportc, sfCompilerProc} * prc.flags == {sfExportc}) or
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,7 @@
|
||||||
## thread local storage. (**Thank you Mac OS X!**)
|
## thread local storage. (**Thank you Mac OS X!**)
|
||||||
|
|
||||||
proc emulatedThreadVars(): bool {.inline.} =
|
proc emulatedThreadVars(): bool {.inline.} =
|
||||||
result = optThreads in gGlobalOptions
|
result = {optThreads, optTlsEmulation} <= gGlobalOptions
|
||||||
# NOW: Use the work-around everywhere, because it should be faster anyway.
|
|
||||||
#platform.OS[targetOS].props.contains(ospLacksThreadVars)
|
|
||||||
|
|
||||||
proc AccessThreadLocalVar(p: BProc, s: PSym) =
|
proc AccessThreadLocalVar(p: BProc, s: PSym) =
|
||||||
if emulatedThreadVars() and not p.ThreadVarAccessed:
|
if emulatedThreadVars() and not p.ThreadVarAccessed:
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ const
|
||||||
AdvancedUsage = slurp"doc/advopt.txt".replace("//", "")
|
AdvancedUsage = slurp"doc/advopt.txt".replace("//", "")
|
||||||
|
|
||||||
proc getCommandLineDesc(): string =
|
proc getCommandLineDesc(): string =
|
||||||
result = `%`(HelpMessage, [VersionAsString, platform.os[platform.hostOS].name,
|
result = (HelpMessage % [VersionAsString, platform.os[platform.hostOS].name,
|
||||||
cpu[platform.hostCPU].name]) & Usage
|
cpu[platform.hostCPU].name]) & Usage
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
@ -191,6 +191,7 @@ proc testCompileOption*(switch: string, info: TLineInfo): bool =
|
||||||
of "genscript": result = contains(gGlobalOptions, optGenScript)
|
of "genscript": result = contains(gGlobalOptions, optGenScript)
|
||||||
of "threads": result = contains(gGlobalOptions, optThreads)
|
of "threads": result = contains(gGlobalOptions, optThreads)
|
||||||
of "taintmode": result = contains(gGlobalOptions, optTaintMode)
|
of "taintmode": result = contains(gGlobalOptions, optTaintMode)
|
||||||
|
of "tlsemulation": result = contains(gGlobalOptions, optTlsEmulation)
|
||||||
else: InvalidCmdLineOption(passCmd1, switch, info)
|
else: InvalidCmdLineOption(passCmd1, switch, info)
|
||||||
|
|
||||||
proc processPath(path: string): string =
|
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 "assertions", "a": ProcessOnOffSwitch({optAssert}, arg, pass, info)
|
||||||
of "deadcodeelim": ProcessOnOffSwitchG({optDeadCodeElim}, arg, pass, info)
|
of "deadcodeelim": ProcessOnOffSwitchG({optDeadCodeElim}, arg, pass, info)
|
||||||
of "threads": ProcessOnOffSwitchG({optThreads}, 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 "taintmode": ProcessOnOffSwitchG({optTaintMode}, arg, pass, info)
|
||||||
of "opt":
|
of "opt":
|
||||||
expectArg(switch, arg, pass, info)
|
expectArg(switch, arg, pass, info)
|
||||||
|
|
@ -438,7 +440,6 @@ proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
|
||||||
proc ProcessCommand(switch: string, pass: TCmdLinePass) =
|
proc ProcessCommand(switch: string, pass: TCmdLinePass) =
|
||||||
var
|
var
|
||||||
cmd, arg: string
|
cmd, arg: string
|
||||||
info: TLineInfo
|
var info = newLineInfo("command line", 1, 1)
|
||||||
info = newLineInfo("command line", 1, 1)
|
|
||||||
splitSwitch(switch, cmd, arg, pass, info)
|
splitSwitch(switch, cmd, arg, pass, info)
|
||||||
ProcessSwitch(cmd, arg, pass, info)
|
ProcessSwitch(cmd, arg, pass, info)
|
||||||
|
|
|
||||||
|
|
@ -88,4 +88,7 @@ proc InitDefines*() =
|
||||||
DefineSymbol(normalize(endianToStr[cpu[targetCPU].endian]))
|
DefineSymbol(normalize(endianToStr[cpu[targetCPU].endian]))
|
||||||
DefineSymbol(cpu[targetCPU].name)
|
DefineSymbol(cpu[targetCPU].name)
|
||||||
DefineSymbol(platform.os[targetOS].name)
|
DefineSymbol(platform.os[targetOS].name)
|
||||||
|
if platform.OS[targetOS].props.contains(ospLacksThreadVars):
|
||||||
|
DefineSymbol("emulatedthreadvars")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,8 @@ type
|
||||||
errCannotInstantiateX, errExprHasNoAddress, errXStackEscape,
|
errCannotInstantiateX, errExprHasNoAddress, errXStackEscape,
|
||||||
errVarForOutParamNeeded,
|
errVarForOutParamNeeded,
|
||||||
errPureTypeMismatch, errTypeMismatch, errButExpected, errButExpectedX,
|
errPureTypeMismatch, errTypeMismatch, errButExpected, errButExpectedX,
|
||||||
errAmbiguousCallXYZ, errWrongNumberOfArguments, errXCannotBePassedToProcVar,
|
errAmbiguousCallXYZ, errWrongNumberOfArguments,
|
||||||
|
errXCannotBePassedToProcVar,
|
||||||
errXCannotBeInParamDecl, errPragmaOnlyInHeaderOfProc, errImplOfXNotAllowed,
|
errXCannotBeInParamDecl, errPragmaOnlyInHeaderOfProc, errImplOfXNotAllowed,
|
||||||
errImplOfXexpected, errNoSymbolToBorrowFromFound, errDiscardValue,
|
errImplOfXexpected, errNoSymbolToBorrowFromFound, errDiscardValue,
|
||||||
errInvalidDiscard, errIllegalConvFromXtoY, errCannotBindXTwice,
|
errInvalidDiscard, errIllegalConvFromXtoY, errCannotBindXTwice,
|
||||||
|
|
@ -94,7 +95,7 @@ type
|
||||||
errUser,
|
errUser,
|
||||||
warnCannotOpenFile,
|
warnCannotOpenFile,
|
||||||
warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit,
|
warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit,
|
||||||
warnCannotWriteMO2, warnCannotReadMO2, warnDeprecated,
|
warnDeprecated,
|
||||||
warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel,
|
warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel,
|
||||||
warnUnknownSubstitutionX, warnLanguageXNotSupported, warnCommentXIgnored,
|
warnUnknownSubstitutionX, warnLanguageXNotSupported, warnCommentXIgnored,
|
||||||
warnXisPassedToProcVar, warnDerefDeprecated, warnAnalysisLoophole,
|
warnXisPassedToProcVar, warnDerefDeprecated, warnAnalysisLoophole,
|
||||||
|
|
@ -323,8 +324,6 @@ const
|
||||||
warnOctalEscape: "octal escape sequences do not exist; leading zero is ignored [OctalEscape]",
|
warnOctalEscape: "octal escape sequences do not exist; leading zero is ignored [OctalEscape]",
|
||||||
warnXIsNeverRead: "\'$1\' is never read [XIsNeverRead]",
|
warnXIsNeverRead: "\'$1\' is never read [XIsNeverRead]",
|
||||||
warnXmightNotBeenInit: "\'$1\' might not have been initialized [XmightNotBeenInit]",
|
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]",
|
warnDeprecated: "\'$1\' is deprecated [Deprecated]",
|
||||||
warnSmallLshouldNotBeUsed: "\'l\' should not be used as an identifier; may look like \'1\' (one) [SmallLshouldNotBeUsed]",
|
warnSmallLshouldNotBeUsed: "\'l\' should not be used as an identifier; may look like \'1\' (one) [SmallLshouldNotBeUsed]",
|
||||||
warnUnknownMagic: "unknown magic \'$1\' might crash the compiler [UnknownMagic]",
|
warnUnknownMagic: "unknown magic \'$1\' might crash the compiler [UnknownMagic]",
|
||||||
|
|
@ -354,8 +353,8 @@ const
|
||||||
hintUser: "$1 [User]"]
|
hintUser: "$1 [User]"]
|
||||||
|
|
||||||
const
|
const
|
||||||
WarningsToStr*: array[0..18, string] = ["CannotOpenFile", "OctalEscape",
|
WarningsToStr*: array[0..16, string] = ["CannotOpenFile", "OctalEscape",
|
||||||
"XIsNeverRead", "XmightNotBeenInit", "CannotWriteMO2", "CannotReadMO2",
|
"XIsNeverRead", "XmightNotBeenInit",
|
||||||
"Deprecated", "SmallLshouldNotBeUsed", "UnknownMagic",
|
"Deprecated", "SmallLshouldNotBeUsed", "UnknownMagic",
|
||||||
"RedefinitionOfLabel", "UnknownSubstitutionX", "LanguageXNotSupported",
|
"RedefinitionOfLabel", "UnknownSubstitutionX", "LanguageXNotSupported",
|
||||||
"CommentXIgnored", "XisPassedToProcVar", "DerefDeprecated",
|
"CommentXIgnored", "XisPassedToProcVar", "DerefDeprecated",
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,8 @@ type # please make sure we have under 32 options
|
||||||
optContext, # ideTools: 'context'
|
optContext, # ideTools: 'context'
|
||||||
optDef, # ideTools: 'def'
|
optDef, # ideTools: 'def'
|
||||||
optThreadAnalysis, # thread analysis pass
|
optThreadAnalysis, # thread analysis pass
|
||||||
optTaintMode # taint mode turned on
|
optTaintMode, # taint mode turned on
|
||||||
|
optTlsEmulation # thread var emulation turned on
|
||||||
|
|
||||||
TGlobalOptions* = set[TGlobalOption]
|
TGlobalOptions* = set[TGlobalOption]
|
||||||
TCommands* = enum # Nimrod's commands
|
TCommands* = enum # Nimrod's commands
|
||||||
|
|
|
||||||
|
|
@ -151,8 +151,8 @@ type
|
||||||
type
|
type
|
||||||
TEndian* = enum
|
TEndian* = enum
|
||||||
littleEndian, bigEndian
|
littleEndian, bigEndian
|
||||||
TInfoCPU* = tuple[name: string, intSize: int, endian: TEndian, floatSize: int,
|
TInfoCPU* = tuple[name: string, intSize: int, endian: TEndian,
|
||||||
bit: int]
|
floatSize, bit: int]
|
||||||
|
|
||||||
const
|
const
|
||||||
EndianToStr*: array[TEndian, string] = ["littleEndian", "bigEndian"]
|
EndianToStr*: array[TEndian, string] = ["littleEndian", "bigEndian"]
|
||||||
|
|
@ -161,14 +161,14 @@ const
|
||||||
(name: "m68k", intSize: 32, endian: bigEndian, 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: "alpha", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
|
||||||
(name: "powerpc", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
|
(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: "sparc", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
|
||||||
(name: "vm", intSize: 32, endian: littleEndian, 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: "ia64", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
|
||||||
(name: "amd64", 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: "mips", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
|
||||||
(name: "arm", intSize: 32, endian: littleEndian, 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)]
|
(name: "nimrodvm", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32)]
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ Advanced options:
|
||||||
(Nimrod, mangled) identifier pairs
|
(Nimrod, mangled) identifier pairs
|
||||||
--lineDir:on|off generation of #line directive on|off
|
--lineDir:on|off generation of #line directive on|off
|
||||||
--threadanalysis:on|off turn thread analysis 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
|
--taintMode:on|off turn taint mode on|off
|
||||||
--symbolFiles:on|off turn symbol files on|off (experimental)
|
--symbolFiles:on|off turn symbol files on|off (experimental)
|
||||||
--skipCfg do not read the general configuration file
|
--skipCfg do not read the general configuration file
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ else:
|
||||||
importc: "pthread_attr_setstack", header: "<pthread.h>".}
|
importc: "pthread_attr_setstack", header: "<pthread.h>".}
|
||||||
|
|
||||||
const
|
const
|
||||||
emulatedThreadVars = true
|
emulatedThreadVars = compileOption("tlsEmulation")
|
||||||
|
|
||||||
when emulatedThreadVars:
|
when emulatedThreadVars:
|
||||||
# the compiler generates this proc for us, so that we can get the size of
|
# the compiler generates this proc for us, so that we can get the size of
|
||||||
|
|
|
||||||
5
todo.txt
5
todo.txt
|
|
@ -18,10 +18,6 @@ incremental compilation
|
||||||
|
|
||||||
- the loading has to be MUCH more lazy! --> next version: We should re-load
|
- the loading has to be MUCH more lazy! --> next version: We should re-load
|
||||||
symbol.ast lazily
|
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:
|
- automate tests:
|
||||||
- test basic recompilation scheme
|
- test basic recompilation scheme
|
||||||
- test type converters
|
- test type converters
|
||||||
|
|
@ -77,6 +73,7 @@ version 0.9.XX
|
||||||
- implicit ref/ptr->var conversion; the compiler may store an object
|
- implicit ref/ptr->var conversion; the compiler may store an object
|
||||||
implicitly on the heap for write barrier efficiency; better:
|
implicitly on the heap for write barrier efficiency; better:
|
||||||
proc specialization in the code gen
|
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
|
- 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)
|
- tlastmod returns wrong results on BSD (Linux, MacOS X: works)
|
||||||
- nested tuple unpacking
|
- nested tuple unpacking
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,8 @@ Compiler Additions
|
||||||
and Objective C somewhat easier.
|
and Objective C somewhat easier.
|
||||||
- Added a ``--nimcache:PATH`` configuration option for control over the output
|
- Added a ``--nimcache:PATH`` configuration option for control over the output
|
||||||
directory for generated code.
|
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
|
- The compiler and standard library now support a *taint mode*. Input strings
|
||||||
are declared with the ``TaintedString`` string type. If the taint
|
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
|
mode is turned on it is a distinct string type which helps to detect input
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue