Commit Graph

21157 Commits

Author SHA1 Message Date
Palmer Cox
ee3f75366c Sha2: Re-write the Sha2 compression functions to improve performance.
The Sha2 compression functions were re-written to execute the message
scheduling calculations in the same loop as the rest of the compression
function. The compiler is able to generate much better code. Additionally,
innermost part of the compression functions were turned into macros to
reduce code duplicate and to make the functions more concise.
2013-08-02 18:49:00 -04:00
Palmer Cox
654c536fec Sha2: Create cryptoutil.rs and re-write the Sha2 module to make use of it.
There are 2 main pieces of functionality in cryptoutil.rs:
* A set of unsafe function for efficiently reading and writing u32 and u64
  values. All of these functions are fairly easy to audit to confirm that
  they do what they are supposed to.
* A FixedBuffer struct. This struct keeps track of input data until there
  is enough of it to execute the a function on it which expects a fixed
  block of data.

The Sha2 module was rewritten to take advantage of the new functions in
cryptoutil as well as FixedBuffer. The result is that the duplicate code
for maintaining a buffer of input data is removed from the Sha512 and
Sha256 implementation. Additionally, the FixedBuffer code is much more
efficient than the previous code was.
2013-08-02 18:48:14 -04:00
Palmer Cox
3cac62822e Sha2: Remove the result_X() methods; move logic into the Digest impls.
The result_X() methods just calculate an output of a fixed size. They don't
really have much to do with running the actually hash algorithm until the very
last step - the output. It makes much more sense to put all this logic into
the Digest impls for each specific variation on the hash function.
2013-08-02 18:46:11 -04:00
Palmer Cox
5b01555155 Sha2: Rearrage traits / impls / structs.
The code was arranged so that the core Sha2 code came first, and then
all of the various implementation of Digest followed along later. The
problem is that the Sha512 compression function code is far away from
the Sha512 Digest implementation, so, if you are trying to read over
the code, you need to scroll all around the file for no good reason. The
code was rearranged so that all of the Sha512 code is in one place and
all of the Sha256 code is in another and so that all impls for a struct
are near the definition of that struct.
2013-08-02 18:46:11 -04:00
Palmer Cox
a1bbd18dc1 Sha2: Remove unecessary integer type specifications. 2013-08-02 18:46:11 -04:00
Stepan Koltsov
9046516444 Rename IpAddr -> SocketAddr, extract IpAddr from SocketAddr
multicast functions now take IpAddr (without port), because they dont't
need port.

Uv* types renamed:
* UvIpAddr -> UvSocketAddr
* UvIpv4 -> UvIpv4SocketAddr
* UvIpv6 -> UvIpv6SocketAddr

"Socket address" is a common name for (ip-address, port) pair (e.g. in
sockaddr_in struct).
2013-08-03 02:06:24 +04:00
bors
3ddc72f69b auto merge of #8234 : bblum/rust/assorted-fixes, r=brson
This fixes 4 bugs that prevented the extra::arc and extra::sync tests from passing on the new runtime.

* In ```Add SendDeferred trait``` I add a non-rescheduling ```send_deferred``` method to our various channel types. The ```extra::sync``` concurrency primitives need this guarantee so they can send while inside of an exclusive. (This fixes deterministic deadlocks seen with ```RUST_THREADS=1```.)
* In "Fix nasty double-free bug" I make sure that a ```ChanOne``` suppresses_finalize *before* rescheduling away to the receiver, so in case it gets a kill signal upon coming back, the destructor is inhibited as desired. (This is pretty uncommon on multiple CPUs but showed up always with ```RUST_THREADS=1```.)
* In ```Fix embarrassing bug where 'unkillable' would unwind improperly``` I make sure the task's unkillable counter stays consistent when a kill signal is received right at the start of an unkillable section. (This is a very uncommon race and can only occur with multiple CPUs.)
* In ```Don't fail from kill signals if already unwinding``` I do pretty much what it says on the tin. Surprising that it took the whole suite of sync/arc tests to expose this.

The other two commits are cleanup.

r @brson
2013-08-02 14:55:54 -07:00
David Halperin
fe8ad14c87 Add backticks around trait name in conflicting implementations error message 2013-08-02 17:54:54 -04:00
David Halperin
77adec9c9b Add trait name to conflicting implementation error message 2013-08-02 17:54:53 -04:00
Ben Blum
43fecf3556 Add an assert_may_sleep() check on every context switch. 2013-08-02 17:31:45 -04:00
Ben Blum
92f60f4365 Don't fail from kill signals if already unwinding. 2013-08-02 17:31:45 -04:00
Ben Blum
bd35798773 (cleanup) Use more do...finally in extra::sync. 2013-08-02 17:31:45 -04:00
Ben Blum
d30cca46e6 Fix embarrassing bug where 'unkillable' would unwind improperly when it receives a kill signal. 2013-08-02 17:31:45 -04:00
Ben Blum
cde6ad3992 Fix nasty double-free bug where a newrt chan could get killed after rescheduling but before suppressing_finalize. 2013-08-02 17:31:44 -04:00
Ben Blum
be7738bfa1 Add SendDeferred trait and use it to fix #8214. 2013-08-02 17:31:44 -04:00
blake2-ppc
0504d7e57b std: Speed up str::is_utf8
Use unchecked vec indexing since the vector bounds are checked by the
loop. Iterators are not easy to use in this case since we skip 1-4 bytes
each lap. This part of the commit speeds up is_utf8 for ASCII input.

Check codepoint ranges by checking the byte ranges manually instead of
computing a full decoding for multibyte encodings. This is easy to read
and corresponds to the UTF-8 syntax in the RFC.

No changes to what we accept. A comment notes that surrogate halves are
accepted.

Before:

	test str::bench::is_utf8_100_ascii ... bench: 165 ns/iter (+/- 3)
	test str::bench::is_utf8_100_multibyte ... bench: 218 ns/iter (+/- 5)

After:
	test str::bench::is_utf8_100_ascii ... bench: 130 ns/iter (+/- 1)
	test str::bench::is_utf8_100_multibyte ... bench: 156 ns/iter (+/- 3)
2013-08-02 23:20:57 +02:00
bors
f1c1f92d0c auto merge of #8221 : brson/rust/single-threaded, r=graydon
This is the last major runtime feature needed for the transition to the new scheduler.
2013-08-02 10:52:50 -07:00
bors
fc571820d1 auto merge of #8202 : pnkfelix/rust/fsk-issue8056-make-crates-must-dep-on-subcrates, r=graydon
Reorder TEST_HOST_CRATES in hopes of exposing future instances of this bug.

Fix #8056
2013-08-02 09:13:53 -07:00
bors
986df44753 auto merge of #8195 : bblum/rust/task-cleanup, r=brson
In the first commit it is obvious why some of the barriers can be changed to ```Relaxed```, but it is not as obvious for the once I changed in ```kill.rs```. The rationale for those is documented as part of the documenting commit.

Also the last commit is a temporary hack to prevent kill signals from being received in taskgroup cleanup code, which could be fixed in a more principled way once the old runtime is gone.
2013-08-02 07:31:52 -07:00
bors
af97339771 auto merge of #8193 : cmr/rust/linux-errno, r=graydon 2013-08-02 05:49:53 -07:00
bors
2460170e6a auto merge of #8188 : huonw/rust/cfg-macro, r=pcwalton
Example:

    if cfg!(test) {
       calculation_to_run_only_when_testing();
    }

Closes #8130.
2013-08-02 03:52:51 -07:00
bors
dbde42e59e auto merge of #8175 : brson/rust/nodbg, r=graydon
This stuff is ancient, unused, and tied to oldsched
2013-08-02 01:13:51 -07:00
Brian Anderson
c3fa411459 std: Implement SingleThreaded spawn mode for newsched 2013-08-02 00:26:45 -07:00
Steven Stewart-Gallus
2047026fef Fix calling destructor on uninitialized dynamic library crash.
A test case was also created for this situation to prevent the problem
occuring again.

A similar problem was also fixed for the symbol method.

There was some minor code cleanup.
2013-08-01 23:41:33 -07:00
bors
bbcce8d95c auto merge of #8216 : thestinger/rust/range, r=huonw 2013-08-01 22:10:45 -07:00
Daniel Micay
234acad404 replace range with an external iterator 2013-08-02 00:51:14 -04:00
bors
ecefeb03cc auto merge of #8185 : alexcrichton/rust/issue-8179, r=pcwalton
* All globals marked as `pub` won't have the `internal` linkage type set
* All global references across crates are forced to use the address of the
  global in the other crate via an external reference.

r? @graydon

Closes #8179
2013-08-01 19:46:47 -07:00
bors
5890fcf872 auto merge of #8116 : toddaaro/rust/tls-tk-pr-pre, r=brson
Merged with task killing code this time around.
2013-08-01 18:01:42 -07:00
toddaaro
ce761f4980 xfailed the myserious failing test 2013-08-01 17:23:55 -07:00
OGINO Masanori
09efc4e855 Replace 'blk' -> 'block' in AstBuilder.
I didn't rename variables because they are local and are not parts of
the public interfaces.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-02 09:12:05 +09:00
bors
d346f1a40e auto merge of #8172 : brson/rust/nomorestack, r=pcwalton
The new scheduler does not yet implement split stacks
2013-08-01 16:19:37 -07:00
Felix S. Klock II
3e5b058521 Make crate tests depend on their extern crates. Reorder TEST_HOST_CRATES in hopes of exposing future instances of this bug. 2013-08-02 01:11:24 +02:00
Kevin Ballard
aa94dfa625 str: Add method .into_owned(self) -> ~str to Str
The method .into_owned() is meant to be used as an optimization when you
need to get a ~str from a Str, but don't want to unnecessarily copy it
if it's already a ~str.

This is meant to ease functions that look like

  fn foo<S: Str>(strs: &[S])

Previously they could work with the strings as slices using .as_slice(),
but producing ~str required copying the string, even if the vector
turned out be a &[~str] already.
2013-08-01 15:54:58 -07:00
toddaaro
8e98eabce5 modified local to include an implementation for try_unsafe_borrow::<Task> so that the log methods will work 2013-08-01 15:38:48 -07:00
toddaaro
1d82fe5aea fixed incorrect handling of returned scheduler option and restructed scheduler functions slightly 2013-08-01 15:18:29 -07:00
toddaaro
a5f55b3ead minor tweaks - unboxed the coroutine so that it is no longer a ~ pointer inside the task struct, and also added an assert to verify that send is never called inside scheduler context as it is undefined (BROKEN) if that happens 2013-08-01 15:17:19 -07:00
toddaaro
997719c13d Fixed a race where a scheduler configured to only run tasks pinned to it would "bounch" a regular task in and out of the work queue without allowing a different scheduler to run it. 2013-08-01 15:16:01 -07:00
Ben Blum
37f385e44b Have linked failure tests run on the new scheduler instead of requiring RUST_NEWRT to test. 2013-08-01 15:16:01 -07:00
toddaaro
f7eed22387 A major refactoring that changes the way the runtime uses TLS. In the
old design the TLS held the scheduler struct, and the scheduler struct
held the active task. This posed all sorts of weird problems due to
how we wanted to use the contents of TLS. The cleaner approach is to
leave the active task in TLS and have the task hold the scheduler. To
make this work out the scheduler has to run inside a regular task, and
then once that is the case the context switching code is massively
simplified, as instead of three possible paths there is only one. The
logical flow is also easier to follow, as the scheduler struct acts
somewhat like a "token" indicating what is active.

These changes also necessitated changing a large number of runtime
tests, and rewriting most of the runtime testing helpers.

Polish level is "low", as I will very soon start on more scheduler
changes that will require wiping the polish off. That being said there
should be sufficient comments around anything complex to make this
entirely respectable as a standalone commit.
2013-08-01 15:14:00 -07:00
bors
eb5743bfb2 auto merge of #8170 : brson/rust/nopipes, r=pcwalton
The pipes compiler produced data types that encoded efficient and safe
bounded message passing protocols between two endpoints. It was also
capable of producing unbounded protocols.

It was useful research but was arguably done before its proper time.

I am removing it for the following reasons:

* In practice we used it only for producing the `oneshot` protcol  and
  the unbounded `stream` protocol and all communication in Rust use those.
* The interface between the proto! macro and the standard library
  has a large surface area and was difficult to maintain through
  language and library changes.
* It is now written in an old dialect of Rust and generates code
  which would likely be considered non-idiomatic.
* Both the compiler and the runtime are difficult to understand,
  and likewise the relationship between the generated code and
  the library is hard to understand. Debugging is difficult.
* The new scheduler implements `stream` and `oneshot` by hand
  in a way that will be significantly easier to maintain.

This shouldn't be taken as an indication that 'channel protocols'
for Rust are not worth pursuing again in the future.

Concerned parties may include: @graydon, @pcwalton, @eholk, @bblum

The most likely candidates for closing are #7666, #3018, #3020, #7021, #7667, #7303, #3658, #3295.
2013-08-01 14:37:31 -07:00
Ben Blum
963d37e821 Temporary workaround to prevent taskgroup cleanup code from failing without an exception handler. 2013-08-01 17:07:31 -04:00
Ben Blum
aeaed77301 Make a forgotten assert in comm be cfg(test)-dependent 2013-08-01 16:52:37 -04:00
Ben Blum
036a6d2f00 Document task killing design and relaxed barrier rationale. 2013-08-01 16:52:37 -04:00
Ben Blum
880246618b Relax some atomic barriers. Loosen up all that tension. There, doesn't that feel good? 2013-08-01 16:52:37 -04:00
bors
82b24559e6 auto merge of #8190 : thestinger/rust/for, r=thestinger 2013-08-01 12:52:29 -07:00
Corey Richardson
2b026718c3 Add a boatload of Linux x86/x86-64/arm errnos 2013-08-01 15:37:01 -04:00
Daniel Micay
94f1a5d6f8 migrate to foreach 2013-08-01 15:28:45 -04:00
Brian Anderson
4b3e766ac6 Remove the pipes compiler
The pipes compiler produced data types that encoded efficient and safe
bounded message passing protocols between two endpoints. It was also
capable of producing unbounded protocols.

It was useful research but was arguably done before its proper time.

I am removing it for the following reasons:

* In practice we used it only for producing the `oneshot` and `stream`
  unbounded protocols and all communication in Rust use those.
* The interface between the proto! macro and the standard library
  has a large surface area and was difficult to maintain through
  language and library changes.
* It is now written in an old dialect of Rust and generates code
  which would likely be considered non-idiomatic.
* Both the compiler and the runtime are difficult to understand,
  and likewise the relationship between the generated code and
  the library is hard to understand. Debugging is difficult.
* The new scheduler implements `stream` and `oneshot` by hand
  in a way that will be significantly easier to maintain.

This shouldn't be taken as an indication that 'channel protocols'
for Rust are not worth pursuing again in the future.
2013-08-01 12:17:32 -07:00
Huon Wilson
7c21ccc483 rustc: add a lint for for, suggesting foreach or do.
This is just to aid the transistion to the new `for` loop, by
pointing at each location where the old one occurs.
2013-08-01 15:07:19 -04:00
bors
479809a267 auto merge of #8166 : emillon/rust/clean-tests-mk, r=brson
Hello,

While looking at `tests.mk` I noticed two errors:

  - there's a `srcrustllvm` instead of `src/rustllvm`
  - some filtered out files don't exist anymore

These two commits fix these issues. Thanks!
2013-08-01 11:10:35 -07:00