Commit Graph

20896 Commits

Author SHA1 Message Date
Erick Tryzelaar
7a5ee374e2 std: import HANDLE for os::list_dir for windows 2013-08-07 21:07:06 -07:00
Erick Tryzelaar
e7f0882214 Fix a stack to use the new .to_c_str() api 2013-08-07 20:25:38 -07:00
Erick Tryzelaar
a54476b0aa Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls 2013-08-07 14:10:39 -07:00
Erick Tryzelaar
aababbba8e std: fix a bad type cast for in str.to_c_str() 2013-08-07 14:06:50 -07:00
Erick Tryzelaar
72688eaa13 std: Make CString::new unsafe b/c it can mutate a *T ptr 2013-08-07 14:06:50 -07:00
Erick Tryzelaar
d6257b315b std: remove unnecessary test from c_str.drop and use safer transmute 2013-08-07 14:06:50 -07:00
Erick Tryzelaar
e053bff5d0 std: Fix c_str.iter() and add test 2013-08-07 14:06:45 -07:00
bors
cdba212e72 auto merge of #8326 : thestinger/rust/iterator, r=alexcrichton
The `extra::iter` module wasn't actually included in `extra.rs` when it was moved from `std`... I assume no one is going to miss it.
2013-08-07 10:32:20 -07:00
bors
29ffbbaaa8 auto merge of #8373 : alexcrichton/rust/disable-rusti, r=cmr
These are causing problems on the linux bots, I'll investigate soon.
2013-08-07 08:53:20 -07:00
Alex Crichton
0927d62275 Revert "Re-enable rusti tests"
This reverts commit d5de801cc1.
2013-08-07 08:29:49 -07:00
bors
597b3fd03f auto merge of #8305 : huonw/rust/triage-fixes, r=cmr
The two deletions are because the test cases are very old (still using `class` and modes!), and, as far as I can tell (since they are so old), the areas they test are well tested by other rpass tests.
2013-08-07 06:56:19 -07:00
Huon Wilson
1ce5effac2 testsuite: add explanation to a Note, and remove duplicated code.
Fixes #7302.
2013-08-07 23:17:52 +10:00
Huon Wilson
e5fb4c4359 testsuite: remove incorrect section of 2 test cases. (Also, &const is disappearing.)
Fixes #7304.
2013-08-07 23:17:52 +10:00
Huon Wilson
1016e8b8f7 testsuite: remove 2 very outdated testcases; functionality is tested by other class-*.rs tests.
Fixes #7305, #7307.
2013-08-07 23:17:52 +10:00
Huon Wilson
c57fde2b5f std: adjust str::test_add so that the macro expands to all 3 items (#8012).
Closes #3682.
2013-08-07 23:17:52 +10:00
bors
54c8c23d05 auto merge of #8323 : kballard/rust/saturating, r=thestinger
Implement saturating math in `std::num::Saturating` and use it for `Iterator` impls
2013-08-07 04:02:16 -07:00
bors
4da1cfe923 auto merge of #8285 : huonw/rust/deriving+++, r=alexcrichton
Some general clean-up relating to deriving:
- `TotalOrd` was too eager, and evaluated the `.cmp` call for every field, even if it could short-circuit earlier.
- the pointer types didn't have impls for `TotalOrd` or `TotalEq`.
- the Makefiles didn't reach deep enough into libsyntax for dependencies.

(Split out from https://github.com/mozilla/rust/pull/8258.)
2013-08-07 00:56:18 -07:00
Huon Wilson
4f3944a34f Add test for short-circuiting #[deriving(Eq,Ord,TotalEq,TotalOrd)]. 2013-08-07 16:56:50 +10:00
bors
62dbdc4ea2 auto merge of #8287 : sfackler/rust/hex, r=alexcrichton
FromHex ignores whitespace and parses either upper or lower case hex
digits. ToHex outputs lower case hex digits with no whitespace. Unlike
ToBase64, ToHex doesn't allow you to configure the output format. I
don't feel that it's super useful in this case.
2013-08-06 21:05:11 -07:00
Daniel Micay
55f3d04101 vec: use offset_inbounds for iterators
This allows LLVM to optimize vector iterators to an `getelementptr` and
`icmp` pair, instead of `getelementptr` and *two* comparisons.

Code snippet:

~~~
fn foo(xs: &mut [f64]) {
    for x in xs.mut_iter() {
        *x += 10.0;
    }
}
~~~

LLVM IR at stage0:

~~~
; Function Attrs: noinline uwtable
define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 {
"function top level":
  %2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0
  %3 = load double** %2, align 8
  %4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1
  %5 = load i64* %4, align 8
  %6 = ptrtoint double* %3 to i64
  %7 = and i64 %5, -8
  %8 = add i64 %7, %6
  %9 = inttoptr i64 %8 to double*
  %10 = icmp eq double* %3, %9
  %11 = icmp eq double* %3, null
  %or.cond6 = or i1 %10, %11
  br i1 %or.cond6, label %match_case, label %match_else

match_else:                                       ; preds = %"function top level", %match_else
  %12 = phi double* [ %13, %match_else ], [ %3, %"function top level" ]
  %13 = getelementptr double* %12, i64 1
  %14 = load double* %12, align 8
  %15 = fadd double %14, 1.000000e+01
  store double %15, double* %12, align 8
  %16 = icmp eq double* %13, %9
  %17 = icmp eq double* %13, null
  %or.cond = or i1 %16, %17
  br i1 %or.cond, label %match_case, label %match_else

match_case:                                       ; preds = %match_else, %"function top level"
  ret void
}
~~~

Optimized LLVM IR at stage1/stage2:

~~~
; Function Attrs: noinline uwtable
define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 {
"function top level":
  %2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0
  %3 = load double** %2, align 8
  %4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1
  %5 = load i64* %4, align 8
  %6 = lshr i64 %5, 3
  %7 = getelementptr inbounds double* %3, i64 %6
  %8 = icmp eq i64 %6, 0
  %9 = icmp eq double* %3, null
  %or.cond6 = or i1 %8, %9
  br i1 %or.cond6, label %match_case, label %match_else

match_else:                                       ; preds = %"function top level", %match_else
  %.sroa.0.0.in7 = phi double* [ %10, %match_else ], [ %3, %"function top level" ]
  %10 = getelementptr inbounds double* %.sroa.0.0.in7, i64 1
  %11 = load double* %.sroa.0.0.in7, align 8
  %12 = fadd double %11, 1.000000e+01
  store double %12, double* %.sroa.0.0.in7, align 8
  %13 = icmp eq double* %10, %7
  br i1 %13, label %match_case, label %match_else

match_case:                                       ; preds = %match_else, %"function top level"
  ret void
}
~~~
2013-08-06 23:54:24 -04:00
Daniel Micay
7d115c9420 add an intrinsic for inbounds GEP 2013-08-06 23:41:20 -04:00
Daniel Micay
f23fb19ee5 vec: avoid ptrtoint/inttoptr in the iterators
This results in throwing away alias analysis information, because LLVM
does *not* implement reasoning about these conversions yet.

We specialize zero-size types since a `getelementptr` offset will
return us the same pointer, making it broken as a simple counter.
2013-08-06 23:41:20 -04:00
Daniel Micay
8f9bbc476d remove extra::iter
This module provided adaptors for the old internal iterator protocol,
but they proved to be quite unreadable and are not generic enough to
handle borrowed pointers well.

Since Rust no longer defines an internal iteration protocol, I don't
think there's going to be any reuse via these adaptors.
2013-08-06 23:41:20 -04:00
Erick Tryzelaar
5eaa4d1d2f Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls 2013-08-06 16:21:02 -07:00
Erick Tryzelaar
5e7b666250 std: update str.push_byte to work without str trailing nulls 2013-08-06 16:19:31 -07:00
Erick Tryzelaar
8567611adf Merge commit 'd89ff7eef969aee6b493bc846b64d68358fafbcd' into remove-str-trailing-nulls 2013-08-06 16:18:58 -07:00
bors
5b4244d917 auto merge of #8231 : SimonSapin/rust/ascii-upper-lower-case, r=cmr
Original pull request: Add str.to_ascii_lower() and str.to_ascii_upper() methods in std::str.
2013-08-06 15:32:05 -07:00
Daniel Micay
40d11a5461 iterator: rename Counter::new to count
to match the convention used by `range`, since `iterator::count` is
already namespaced enough and won't be ambiguous
2013-08-06 18:09:20 -04:00
Daniel Micay
c13f4f398a add Extendable to the prelude 2013-08-06 18:09:20 -04:00
Daniel Micay
b3a317c368 iterator: simplify the take implementation 2013-08-06 18:09:20 -04:00
Simon Sapin
88b21f592c Add to_ascii_upper, to_ascii_lower and eq_ignore_ascii_case in std::ascii 2013-08-06 20:22:11 +01:00
bors
6972eb4cd7 auto merge of #8321 : alexcrichton/rust/enable-rusti, r=cmr
Now that LLVM has been upgraded, I think that we can try again to re-enable the rusti tests.
2013-08-06 12:14:07 -07:00
Steven Fackler
3b441c485f Result::get -> Result::unwrap 2013-08-06 10:42:06 -07:00
bors
72080954b9 auto merge of #8317 : bblum/rust/fast-spawn-unlinked, r=brson
This lazily initializes the taskgroup structs for ```spawn_unlinked``` tasks. If such a task never spawns another task linked to it (or a descendant of it), its taskgroup is simply never initialized at all. Also if an unlinked task spawns another unlinked task, neither of them will need to initialize their taskgroups. This works for the main task too.

I benchmarked this with the following test case and observed a ~~21% speedup (average over 4 runs: 7.85 sec -> 6.20 sec, 2.5 GHz)~~ 11% speedup, see comment below.
```
use std::task;
use std::cell::Cell;
use std::rt::comm;

static NUM: uint = 1024*256;

fn run(f: ~fn()) {
    let mut t = task::task();
    t.unlinked();
    t.spawn(f);
}

fn main() {
    do NUM.times {
        let (p,c) = comm::oneshot();
        let c = Cell::new(c);
        do run { c.take().send(()); }
        p.recv();
    }
}
```
2013-08-06 10:32:00 -07:00
Steven Fackler
e617651384 Removed convenience encoding trait impls
Encoding should really only be done from [u8]<->str. The extra
convenience implementations don't really have a place, especially since
they're so trivial.

Also improved error messages in FromBase64.
2013-08-06 09:58:36 -07:00
Steven Fackler
858e166119 Removing space for NULL terminator
String NULL terminators are going away soon, so we may as well get rid
of this now so it doesn't rot.
2013-08-06 09:58:36 -07:00
Steven Fackler
ff5fdffc13 ToBase64 and ToHex perf improvements
The overhead of str::push_char is high enough to cripple the performance
of these two functions. I've switched them to build the output in a
~[u8] and then convert to a string later. Since we know exactly the
bytes going into the vector, we can use the unsafe version to avoid the
is_utf8 check.

I could have riced it further with vec::raw::get, but it only added
~10MB/s so I didn't think it was worth it. ToHex is still ~30% slower
than FromHex, which is puzzling.

Before:

```
test base64::test::from_base64 ... bench: 1000 ns/iter (+/- 349) = 204 MB/s
test base64::test::to_base64 ... bench: 2390 ns/iter (+/- 1130) = 63 MB/s
...
test hex::tests::bench_from_hex ... bench: 884 ns/iter (+/- 220) = 341 MB/s
test hex::tests::bench_to_hex ... bench: 2453 ns/iter (+/- 919) = 61 MB/s
```

After:

```
test base64::test::from_base64 ... bench: 1271 ns/iter (+/- 600) = 160 MB/s
test base64::test::to_base64 ... bench: 759 ns/iter (+/- 286) = 198 MB/s
...
test hex::tests::bench_from_hex ... bench: 875 ns/iter (+/- 377) = 345 MB/s
test hex::tests::bench_to_hex ... bench: 593 ns/iter (+/- 240) = 254 MB/s
```
2013-08-06 09:58:36 -07:00
Steven Fackler
463e2416e9 Some minor hex changes 2013-08-06 09:58:36 -07:00
Steven Fackler
2266df51aa Added hexadecimal encoding module
FromHex ignores whitespace and parses either upper or lower case hex
digits. ToHex outputs lower case hex digits with no whitespace. Unlike
ToBase64, ToHex doesn't allow you to configure the output format. I
don't feel that it's super useful in this case.
2013-08-06 09:58:35 -07:00
bors
3dfb55ab09 auto merge of #8313 : msullivan/rust/cleanup, r=catamorphism 2013-08-06 08:44:05 -07:00
bors
ba3d03d3a4 auto merge of #8312 : alexcrichton/rust/use-treemap, r=erickt
Closes #4430
2013-08-06 07:05:05 -07:00
bors
ca6385034c auto merge of #8308 : blake2-ppc/rust/str-slice-bytes, r=alexcrichton
`fn slice_bytes` is marked unsafe since it allows violating the valid
string encoding property; but the function did also allow extending the
lifetime of the slice by mistake, since it's returning `&str`.

Use the annotation `slice_bytes<'a>(&'a str, ...) -> &'a str` so
that all uses of `slice_bytes` are region checked correctly.
2013-08-06 05:26:01 -07:00
bors
8adcba4300 auto merge of #8054 : sammykim/rust/move-EnumSet, r=alexcrichton
Fix #8004
2013-08-06 02:26:06 -07:00
Kevin Ballard
3db3ce22f5 Update Iterator impls to use Saturating
Replace hand-rolled saturation math with calls to Saturating.

Fix one impl that didn't use saturating math.
2013-08-05 22:49:33 -07:00
Kevin Ballard
5f713da4aa Add std::num::Saturating
Saturating is an implementation of saturating math operations (at the
moment just add and sub) for integral types.
2013-08-05 22:49:33 -07:00
Sangeun Kim
a76943be47 Move EnumSet into libextra 2013-08-06 14:45:02 +09:00
bors
f8cf234b34 auto merge of #8265 : blake2-ppc/rust/std-iter, r=thestinger
Fix #8228 by replacing .iter() and .iter_err() in Result by external iterators.

Implement random access for `iterator::Invert` and `vec::ChunkIter` (and bidirectionality).

Implement Repeat iterator.
2013-08-05 22:38:15 -07:00
bors
6f88f4dea5 auto merge of #8278 : cmr/rust/workaround, r=brson 2013-08-05 20:07:59 -07:00
Erick Tryzelaar
fb9b27910b std: c_str should use regions on methods 2013-08-05 19:55:07 -07:00
Erick Tryzelaar
c8e454097b std: fix a typo where .to_c_str wasn't being called on android 2013-08-05 19:54:49 -07:00