The root issue is that dlerror isn't reentrant or even thread safe.
The solution implemented here is to make a yielding spin lock over an
AtomicFlag. This is pretty hacky, but the best we can do at this point.
As far as I can tell, it isn't possible to create a global mutex without
having to initialize it in a single threaded context.
The Windows code isn't affected since errno is thread-local on Windows
and it's running in an atomically block to ensure there isn't a green
thread context switch.
Closes#8156
This PR solves one of the pain points with c-style enums. Simplifies writing a fn to convert from an int/uint to an enum. It does this through a `#[deriving(FromPrimitive)]` syntax extension.
Before this is committed though, we need to discuss if `ToPrimitive`/`FromPrimitive` has the right design (cc #4819). I've changed all the `.to_int()` and `from_int()` style functions to return `Option<int>` so we can handle partial functions. For this PR though only enums and `extra::num::bigint::*` take advantage of returning None for unrepresentable values. In the long run it'd be better if `i64.to_i8()` returned `None` if the value was too large, but I'll save this for a future PR.
Closes#3868.
The root issue is that dlerror isn't reentrant or even thread safe.
The Windows code isn't affected since errno is thread-local on Windows
and it's running in an atomically block to ensure there isn't a green
thread context switch.
Closes#8156
According to http://huonw.github.io/isrustfastyet/mem/#012f909, the "const
marking" pass generates about 400MB of extra memory during compilation. It
appears that this is due to two different factors:
1. There is a `ccache` map in the ty::ctxt which is only ever used in this
pass, so this commit moves the map out of the ty::ctxt struct and into
just this pass's visitor. This turned out to not benefit that much in
memory (as indicated by http://i.imgur.com/Eo4iOzK.png), but it's helpful
to do nonetheless.
2. During const_eval, there are a lot of lookups into decoding inlined items
from external crates. There is no caching involved here, so the same
static or variant could be re-translated many times. After adding
separate caches for variants and statics, the memory peak of compiling
rustc decreased by 200MB (as evident by http://i.imgur.com/ULAUMtq.png)
The culmination of this is basically a slight reorganization of a caching map
for the const_eval pass along with a 200MB decrease in peak memory usage when
compiling librustc.
According to http://huonw.github.io/isrustfastyet/mem/#012f909, the "const
marking" pass generates about 400MB of extra memory during compilation. It
appears that this is due to two different factors:
1. There is a `ccache` map in the ty::ctxt which is only ever used in this
pass, so this commit moves the map out of the ty::ctxt struct and into
just this pass's visitor. This turned out to not benefit that much in
memory (as indicated by http://i.imgur.com/Eo4iOzK.png), but it's helpful
to do nonetheless.
2. During const_eval, there are a lot of lookups into decoding inlined items
from external crates. There is no caching involved here, so the same
static or variant could be re-translated many times. After adding
separate caches for variants and statics, the memory peak of compiling
rustc decreased by 200MB (as evident by http://i.imgur.com/ULAUMtq.png)
The culmination of this is basically a slight reorganization of a caching map
for the const_eval pass along with a 200MB decrease in peak memory usage when
compiling librustc.
Avoid cloning the stack on every `push_ctxt` call in trans
Rewrite the use of TLS variable for `push_ctxt` so that it uses a ~[]
instead of a @~[]. Before it cloned the whole vector on each push and
pop, which is unnecessary.
Rewrite the use of TLS variable for `push_ctxt` so that it uses a ~[]
instead of a @~[]. Before it cloned the whole vector on each push and
pop, which is unnecessary.
rustc: Use static strings in a few literals
Avoid allocating extra copies of strings by using "" instead of ~"" for
the debug options list and for the `time` function. This is a small
change, but it is in a path that's always executed.
Avoid allocating extra copies of strings by using "" instead of ~"" for
the debug options list and for the `time` function. This is a small
change, but it is in a path that's always executed.
This will make sure that system files that rust binaries depend on in Windows get packaged into stage0 snapshots as well as into Windows installer.
Currently these include `libgcc_s_dw2-1.dll`, `libstdc++-6.dll` and `libpthread-2.dll`. Note that the latter will need to be changed to `pthreadGC2.dll` once Windows build bots get upgraded to mingw 4.0
Closes#9252Closes#5878Closes#9218Closes#5712
Mostly as per a short discussion on irc. (@cmr)
08:46 < cmr> so I'm thinking
Obsolete{Let,With,FieldTerminator,ClassTraits,ModeInFnType,MoveInit,BinaryMove,I
mplSyntax,MutOwnedPointer,MutVector,RecordType,RecordPattern,PostFnTySigil,Newty
pEnum,Mode,ImplicitSelf,LifetimeNotation,Purity,StaticMethod,ConstItem,FixedLeng
thVectorType}
08:46 < cmr> Those are the ones that are older than 0.6
08:46 < cmr> (at least!)
This PR removes these specific "obsolete syntax"/"suggestion for change" errors and just lets the parser run into regular parser errors for long-invalid syntax. I also removed `ObsoletePrivSection` which apparently dates further back than cmr or I could recall and `ObsoleteUnenforcedBound` which seemed unused. Also I removed `ObsoleteNewtypeEnum`.
Replaces existing tests for removed obsolete-syntax errors with tests
for the resulting regular errors, adds a test for each of the removed
parser errors to make sure that obsolete forms don't start working
again, removes some obsolete/superfluous tests that were now failing.
Deletes some amount of dead code in the parser, also includes some small
changes to parser error messages to accomodate new tests.
do_strptime() and do_strftime()
I don't see any reason why src/libextra/time.rs has two functions that just call a very similar function, which only use is to be called by them.
strftime() just calls do_strftime()
strptime() just calls do_strptime()
and the do_functions aren't called by anyone else.
the parameters and return types are exactly the same in both levels, so I just have removed the second layer.
Unless there is a need for that second level.