about summary refs log tree commit diff
path: root/src/etc
AgeCommit message (Collapse)AuthorLines
2015-08-29Fix typos in some x86 and arm intrinsics.Huon Wilson-19/+33
2015-08-29Style the generator script more PEP8y.Huon Wilson-4/+42
2015-08-29Autogenerate most x86 platform intrinsics.Huon Wilson-0/+747
2015-08-29Allow unused imports in the generator.Huon Wilson-0/+2
2015-08-29Add support for arbitrary metadata for numbers and widths.Huon Wilson-58/+79
This means that each platform has total control over the formatting info it needs.
2015-08-29Autogenerate most ARM platform intrinsics.Huon Wilson-0/+396
2015-08-29Autogenerate most AArch64 platform intrinsics.Huon Wilson-0/+550
2015-08-29Add the platform intrinsic generator script.Huon Wilson-0/+482
This python script will consume an appropriately formatted JSON file and output either a Rust file for use in librustc_platform_intrinsics, or an extern block for importing the intrinsics in an external library. The --help flag has details.
2015-08-13Auto merge of #27684 - alexcrichton:remove-deprecated, r=aturonbors-163/+0
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-13Auto merge of #27307 - rkruppe:dec2flt, r=pnkfelixbors-0/+798
Completely rewrite the conversion of decimal strings to `f64` and `f32`. The code is intended to be absolutely positively completely 100% accurate (when it doesn't give up). To the best of my knowledge, it achieves that goal. Any input that is not rejected is converted to the floating point number that is closest to the true value of the input. This includes overflow, subnormal numbers, and underflow to zero. In other words, the rounding error is less than or equal to 0.5 units in the last place. Half-way cases (exactly 0.5 ULP error) are handled with half-to-even rounding, also known as banker's rounding. This code implements the algorithms from the paper [How to Read Floating Point Numbers Accurately][paper] by William D. Clinger, with extensions to handle underflow, overflow and subnormals, as well as some algorithmic optimizations. # Correctness With such a large amount of tricky code, many bugs are to be expected. Indeed tracking down the obscure causes of various rounding errors accounts for the bulk of the development time. Extensive tests (taking in the order of hours to run through to completion) are included in `src/etc/test-float-parse`: Though exhaustively testing all possible inputs is impossible, I've had good success with generating millions of instances from various "classes" of inputs. These tests take far too long to be run by @bors so contributors who touch this code need the discipline to run them. There are `#[test]`s, but they don't even cover every stupid mistake I made in course of writing this. Another aspect is *integer* overflow. Extreme (or malicious) inputs could cause overflow both in the machine-sized integers used for bookkeeping throughout the algorithms (e.g., the decimal exponent) as well as the arbitrary-precision arithmetic. There is input validation to reject all such cases I know of, and I am quite sure nobody will *accidentally* cause this code to go out of range. Still, no guarantees. # Limitations Noticed the weasel words "(when it doesn't give up)" at the beginning? Some otherwise well-formed decimal strings are rejected because spelling out the value of the input requires too many digits, i.e., `digits * 10^abs(exp)` can't be stored in a bignum. This only applies if the value is not "obviously" zero or infinite, i.e., if you take a near-infinity or near-zero value and add many pointless fractional digits. At least with the algorithm used here, computing the precise value would require computing the full value as a fraction, which would overflow. The precise limit is `number_of_digits + abs(exp) > 375` but could be raised almost arbitrarily. In the future, another algorithm might lift this restriction entirely. This should not be an issue for any realistic inputs. Still, the code does reject inputs that would result in a finite float when evaluated with unlimited precision. Some of these inputs are even regressions that the old code (mostly) handled, such as `0.333...333` with 400+ `3`s. Thus this might qualify as [breaking-change]. # Performance Benchmarks results are... tolerable. Short numbers that hit the fast paths (`f64` multiplication or shortcuts to zero/inf) have performance in the same order of magnitude as the old code tens of nanoseconds. Numbers that are delegated to Algorithm Bellerophon (using floats with 64 bit significand, implemented in software) are slower, but not drastically so (couple hundred nanoseconds). Numbers that need the AlgorithmM fallback (for `f64`, roughly everything below 1e-305 and above 1e305) take far, far longer, hundreds of microseconds. Note that my implementation is not quite as naive as the expository version in the paper (it needs one to four division instead of ~1000), but division is fundamentally pretty expensive and my implementation of it is extremely simple and slow. All benchmarks run on a mediocre laptop with a i5-4200U CPU under light load. # Binary size Unfortunately the implementation needs to duplicate almost all code: Once for `f32` and once for `f64`. Before you ask, no, this cannot be avoided, at least not completely (but see the Future Work section). There's also a precomputed table of powers of ten, weighing in at about six kilobytes. Running a stage1 `rustc` over a stand-alone program that simply parses pi to `f32` and `f64` and outputs both results reveals that the overhead vs. the old parsing code is about 44 KiB normally and about 28 KiB with LTO. It's presumably half of that + 3 KiB when only one of the two code paths is exercised. | rustc options | old | new | delta | |--------------------------- |--------- |--------- |----------- | | [nothing] | 2588375 | 2633828 | 44.39 KiB | | -O | 2585211 | 2630688 | 44.41 KiB | | -O -C lto | 1026353 | 1054981 | 27.96 KiB | | -O -C lto -C link-args=-s | 414208 | 442368 | 27.5 KiB | # Future Work ## Directory layout The `dec2flt` code uses some types embedded deeply in the `flt2dec` module hierarchy, even though nothing about them it formatting-specific. They should be moved to a more conversion-direction-agnostic location at some point. ## Performance It could be much better, especially for large inputs. Some low-hanging fruit has been picked but much more work could be done. Some specific ideas are jotted down in `FIXME`s all over the code. ## Binary size One could try to compress the table further, though I am skeptical. Another avenue would be reducing the code duplication from basically everything being generic over `T: RawFloat`. Perhaps one can reduce the magnitude of the duplication by pushing the parts that don't need to know the target type into separate functions, but this is finicky and probably makes some code read less naturally. ## Other bases This PR leaves `f{32,64}::from_str_radix` alone. It only replaces `FromStr` (and thus `.parse()`). I am convinced that `from_str_radix` should not exist, and have proposed its [deprecation and speedy removal][deprecate-radix]. Whatever the outcome of that discussion, it is independent from, and out of scope for, this PR. Fixes #24557 Fixes #14353 r? @pnkfelix cc @lifthrasiir @huonw [paper]: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.45.4152 [deprecate-radix]: https://internals.rust-lang.org/t/deprecate-f-32-64-from-str-radix/2405
2015-08-12Remove all unstable deprecated functionalityAlex Crichton-163/+0
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-12Auto merge of #27690 - vadimcn:no-windres, r=alexcrichtonbors-1/+1
Fix #26803
2015-08-11Fix #26803Vadim Chugunov-1/+1
2015-08-11trans: Re-enable unwinding on 64-bit MSVCAlex Crichton-8/+8
This commit leverages the runtime support for DWARF exception info added in #27210 to enable unwinding by default on 64-bit MSVC. This also additionally adds a few minor fixes here and there in the test harness and such to get `make check` entirely passing on 64-bit MSVC: * The invocation of `maketest.py` now works with spaces/quotes in CC * debuginfo tests are disabled on MSVC * A link error for librustc was hacked around (see #27438)
2015-08-09Add optional, external tests for floating point parsing.Robin Kruppe-0/+664
Running these tests takes hours, so they are not run by @bors.
2015-08-08Script for generating the powers-of-ten tables necessary for correct andRobin Kruppe-0/+134
fast decimal-to-float conversions.
2015-07-30Update the ctags rules and targets.Chris Morgan-3/+3
As there’s no C++ runtime any more there’s really no point in having anything but Rust tags being made. I’ve also taken the liberty of excluding the compiler parts of this in the `librust%,,` pattern substitution. Whether or not this is “correct” will depend on whether you want tags for the compiler or for general use. For myself, I want it for general use. I’m not sure how much people use the tags files anyway. I definitely do, but with Racer existing the tags files aren’t quite so necessary.
2015-07-17fix pretty printers to handle new VecAlexis Beingessner-9/+7
2015-07-12Add comments.Nick Hamann-0/+10
2015-07-12Skip diagnostic codes occurring inside a long diagnostic in errorck.Nick Hamann-0/+12
2015-07-06`llconfig` is `llvm-config`Tamir Duberstein-5/+5
2015-07-06SimplifyTamir Duberstein-2/+1
2015-07-01Add netbsd amd64 supportAlex Newman-4/+7
2015-06-24Remove char::to_titlecase. Fix #26555Simon Sapin-10/+0
I added it because it was easy (same a `char::to_lowercase`, just a different table), but it doesn’t make sense to have this in std but not str::to_titlecase, which would require https://github.com/unicode-rs/unicode-segmentation At some point in the future this feature will be available (both on char and str) in a crates.io crate.
2015-06-17Add src/etc/add-authors.sh script for managing the AUTHORS.txt fileBrian Anderson-0/+32
This is the kind of dumb task that gets done a different way every time and is easily automated.
2015-06-06Correctly map upper-case Sigma to lower-case in word-final position. Fix #26035.Simon Sapin-1/+2
2015-06-06Add char::to_titlecaseSimon Sapin-15/+27
But not str::to_titlecase which would require UAX#29 Unicode Text Segmentation which we decided not to include in of `std`: https://github.com/rust-lang/rfcs/pull/1054
2015-06-06Add complex (but unconditional) Unicode case mapping. Fix #25800Simon Sapin-10/+44
As a result, the iterator returned by `char::to_uppercase` sometimes yields two or three `char`s instead of just one.
2015-06-06to_lowercase/to_uppercase: also map chars not in Lu/Ll categories.Simon Sapin-18/+18
This adds 120 mappings: Dž dž Dž DŽ Lj lj Lj LJ Nj nj Nj NJ Dz dz Dz DZ Ι ᾈ ᾀ ᾉ ᾁ ᾊ ᾂ ᾋ ᾃ ᾌ ᾄ ᾍ ᾅ ᾎ ᾆ ᾏ ᾇ ᾘ ᾐ ᾙ ᾑ ᾚ ᾒ ᾛ ᾓ ᾜ ᾔ ᾝ ᾕ ᾞ ᾖ ᾟ ᾗ ᾨ ᾠ ᾩ ᾡ ᾪ ᾢ ᾫ ᾣ ᾬ ᾤ ᾭ ᾥ ᾮ ᾦ ᾯ ᾧ ᾼ ᾳ ῌ ῃ ῼ ῳ Ⅰ ⅰ Ⅱ ⅱ Ⅲ ⅲ Ⅳ ⅳ Ⅴ ⅴ Ⅵ ⅵ Ⅶ ⅶ Ⅷ ⅷ Ⅸ ⅸ Ⅹ ⅹ Ⅺ ⅺ Ⅻ ⅻ Ⅼ ⅼ Ⅽ ⅽ Ⅾ ⅾ Ⅿ ⅿ ⅰ Ⅰ ⅱ Ⅱ ⅲ Ⅲ ⅳ Ⅳ ⅴ Ⅴ ⅵ Ⅵ ⅶ Ⅶ ⅷ Ⅷ ⅸ Ⅸ ⅹ Ⅹ ⅺ Ⅺ ⅻ Ⅻ ⅼ Ⅼ ⅽ Ⅽ ⅾ Ⅾ ⅿ Ⅿ Ⓐ ⓐ Ⓑ ⓑ Ⓒ ⓒ Ⓓ ⓓ Ⓔ ⓔ Ⓕ ⓕ Ⓖ ⓖ Ⓗ ⓗ Ⓘ ⓘ Ⓙ ⓙ Ⓚ ⓚ Ⓛ ⓛ Ⓜ ⓜ Ⓝ ⓝ Ⓞ ⓞ Ⓟ ⓟ Ⓠ ⓠ Ⓡ ⓡ Ⓢ ⓢ Ⓣ ⓣ Ⓤ ⓤ Ⓥ ⓥ Ⓦ ⓦ Ⓧ ⓧ Ⓨ ⓨ Ⓩ ⓩ ⓐ Ⓐ ⓑ Ⓑ ⓒ Ⓒ ⓓ Ⓓ ⓔ Ⓔ ⓕ Ⓕ ⓖ Ⓖ ⓗ Ⓗ ⓘ Ⓘ ⓙ Ⓙ ⓚ Ⓚ ⓛ Ⓛ ⓜ Ⓜ ⓝ Ⓝ ⓞ Ⓞ ⓟ Ⓟ ⓠ Ⓠ ⓡ Ⓡ ⓢ Ⓢ ⓣ Ⓣ ⓤ Ⓤ ⓥ Ⓥ ⓦ Ⓦ ⓧ Ⓧ ⓨ Ⓨ ⓩ Ⓩ
2015-06-02Auto merge of #25905 - michaelwoerister:lldb-pp-strings, r=brsonbors-417/+705
GDB and LLDB pretty printers have some common functionality and also access some common information, such as the layout of standard library types. So far, this information has been duplicated in the two pretty printing python modules. This PR introduces a common module used by both debuggers. This PR also implements proper rendering of `String` and `&str` values in LLDB.
2015-06-02Auto merge of #25654 - petrochenkov:encenv, r=alexcrichtonbors-4/+8
Fixes https://github.com/rust-lang/rust/issues/25268 and a couple of similar test errors r? @alexcrichton
2015-06-01Fix platform detectionpetrochenkov-6/+3
2015-05-30debuginfo: Create common debugger pretty printer module.Michael Woerister-417/+705
GDB and LLDB pretty printers have some common functionality and also access some common information, such as the layout of standard library types. So far, this information has been duplicated in the two pretty printing python modules. This commit introduces a common module used by both debuggers.
2015-05-30Warn if the test suite is run on Windows in console with non-UTF-8 code pagepetrochenkov-0/+7
2015-05-26etc: use codecs in featureckRicho Healey-9/+5
this asserts that source is valid utf8 on both python3 and python2
2015-05-24etc: work around utf8 text in rust sources on py3 in featureckRicho Healey-1/+8
2015-05-24etc: py3 compat for tidy.pyRicho Healey-6/+6
2015-05-24etc: py3 compat for featureckRicho Healey-23/+23
Also rewrite most of the string formatting to be a bit more idiomatic
2015-05-24etc: py3 compat for errorck.pyRicho Healey-1/+1
2015-05-24etc: py3 compat for check-summary.pyRicho Healey-7/+7
2015-05-24etc: Delete unused helper scriptRicho Healey-138/+0
2015-05-19mk: Generate a .def file for rustc_llvm on MSVCAlex Crichton-0/+25
Windows needs explicit exports of functions from DLLs but LLVM does not mention any of its symbols as being export-able from a DLL. The compiler, however, relies on being able to use LLVM symbols across DLL boundaries so we need to force many of LLVM's symbols to be exported from `rustc_llvm.dll`. This commit adds support for generation of a `rustc_llvm.def` file which is passed along to the linker when generating `rustc_llvm.dll` which should keep all these symbols exportable and usable.
2015-05-19mklldeps: Don't link stdc++/c++ on MSVCAlex Crichton-2/+5
These libraries don't exist! The linker for MSVC is highly likely to not pass `/NODEFAULTLIB` in which case the right standard library will automatically be selected.
2015-05-11Auto merge of #25266 - richo:windows-resource-sancheck, r=steveklabnikbors-1/+1
This avoids a crash on windows Closes #25265
2015-05-10Rollup merge of #24948 - derhuerst:patch-1, r=steveklabnikSteve Klabnik-1/+7
I've written a small [EditorConfig](http://editorconfig.org) file for Rust development.
2015-05-10sancheck: import resource inside of the posix checkRicho Healey-1/+1
This avoids a crash on windows
2015-05-03Remove unused extract_grammar.pyCarol (Nichols || Goulding)-156/+0
This script used to be used to extract the grammar sections from the reference, but there is now a separate src/doc/grammar.md where the grammar sections that used to be in the reference live, so there is no longer a need to extract the grammar from the reference.
2015-04-29distinction between official and community pluginsJannis Redmann-2/+7
2015-04-29link to .editorconfig for Rust filesJannis Redmann-0/+1
I've written a small [EditorConfig](http://editorconfig.org) file for Rust development.
2015-04-21LLVM < 3.5 is unsupported since bb18a3cTamir Duberstein-11/+1