Skip to content

Commit b5649b9

Browse files
committed
---
yaml --- r: 59382 b: refs/heads/snap-stage3 c: 7b2020f h: refs/heads/master v: v3
1 parent 797da14 commit b5649b9

File tree

19 files changed

+595
-183
lines changed

19 files changed

+595
-183
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: c081ffbd1e845687202a975ea2e698b623e5722f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 930908aa90af3635af3744b08bf2aaaee4e3b381
4+
refs/heads/snap-stage3: 7b2020f2c3f51de0dd4dcfe4a107673eda6f25e7
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/host.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ $$(HLIB$(2)_H_$(4))/$(CFG_RUSTLLVM_$(4)): \
130130
$$(HBIN$(2)_H_$(4))/:
131131
mkdir -p $$@
132132

133-
ifneq ($(CFG_LIBDIR),bin)
134133
$$(HLIB$(2)_H_$(4))/:
135134
mkdir -p $$@
136-
endif
137135

138136
endef
139137

branches/snap-stage3/mk/rt.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ endif
163163
ifdef CFG_WINDOWSY_$(1)
164164
$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS)
165165
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
166+
CFLAGS="$$(CFG_GCCISH_CFLAGS)" \
167+
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS)" \
166168
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \
167169
OS=mingw \
168170
V=$$(VERBOSE)

branches/snap-stage3/mk/target.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,8 @@ endif
8686
$$(TBIN$(1)_T_$(2)_H_$(3))/:
8787
mkdir -p $$@
8888

89-
ifneq ($(CFG_LIBDIR),bin)
9089
$$(TLIB$(1)_T_$(2)_H_$(3))/:
9190
mkdir -p $$@
92-
endif
9391

9492
endef
9593

branches/snap-stage3/src/libcore/char.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use option::{None, Option, Some};
1616
use str;
1717
use u32;
1818
use uint;
19-
use unicode;
19+
use unicode::{derived_property, general_category};
2020

2121
#[cfg(notest)] use cmp::Eq;
2222

@@ -53,18 +53,17 @@ use unicode;
5353
Cn Unassigned a reserved unassigned code point or a noncharacter
5454
*/
5555

56-
pub use is_alphabetic = unicode::derived_property::Alphabetic;
57-
pub use is_XID_start = unicode::derived_property::XID_Start;
58-
pub use is_XID_continue = unicode::derived_property::XID_Continue;
59-
56+
pub fn is_alphabetic(c: char) -> bool { derived_property::Alphabetic(c) }
57+
pub fn is_XID_start(c: char) -> bool { derived_property::XID_Start(c) }
58+
pub fn is_XID_continue(c: char) -> bool { derived_property::XID_Continue(c) }
6059

6160
/**
6261
* Indicates whether a character is in lower case, defined
6362
* in terms of the Unicode General Category 'Ll'
6463
*/
6564
#[inline(always)]
6665
pub fn is_lowercase(c: char) -> bool {
67-
return unicode::general_category::Ll(c);
66+
return general_category::Ll(c);
6867
}
6968

7069
/**
@@ -73,7 +72,7 @@ pub fn is_lowercase(c: char) -> bool {
7372
*/
7473
#[inline(always)]
7574
pub fn is_uppercase(c: char) -> bool {
76-
return unicode::general_category::Lu(c);
75+
return general_category::Lu(c);
7776
}
7877

7978
/**
@@ -84,9 +83,9 @@ pub fn is_uppercase(c: char) -> bool {
8483
#[inline(always)]
8584
pub fn is_whitespace(c: char) -> bool {
8685
return ('\x09' <= c && c <= '\x0d')
87-
|| unicode::general_category::Zs(c)
88-
|| unicode::general_category::Zl(c)
89-
|| unicode::general_category::Zp(c);
86+
|| general_category::Zs(c)
87+
|| general_category::Zl(c)
88+
|| general_category::Zp(c);
9089
}
9190

9291
/**
@@ -96,18 +95,18 @@ pub fn is_whitespace(c: char) -> bool {
9695
*/
9796
#[inline(always)]
9897
pub fn is_alphanumeric(c: char) -> bool {
99-
return unicode::derived_property::Alphabetic(c) ||
100-
unicode::general_category::Nd(c) ||
101-
unicode::general_category::Nl(c) ||
102-
unicode::general_category::No(c);
98+
return derived_property::Alphabetic(c) ||
99+
general_category::Nd(c) ||
100+
general_category::Nl(c) ||
101+
general_category::No(c);
103102
}
104103

105104
/// Indicates whether the character is numeric (Nd, Nl, or No)
106105
#[inline(always)]
107106
pub fn is_digit(c: char) -> bool {
108-
return unicode::general_category::Nd(c) ||
109-
unicode::general_category::Nl(c) ||
110-
unicode::general_category::No(c);
107+
return general_category::Nd(c) ||
108+
general_category::Nl(c) ||
109+
general_category::No(c);
111110
}
112111

113112
/**

branches/snap-stage3/src/libcore/container.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ pub trait Map<K, V>: Mutable {
5555
/// Remove a key-value pair from the map. Return true if the key
5656
/// was present in the map, otherwise false.
5757
fn remove(&mut self, key: &K) -> bool;
58+
59+
/// Insert a key-value pair from the map. If the key already had a value
60+
/// present in the map, that value is returned. Otherwise None is returned.
61+
fn swap(&mut self, k: K, v: V) -> Option<V>;
62+
63+
/// Removes a key from the map, returning the value at the key if the key
64+
/// was previously in the map.
65+
fn pop(&mut self, k: &K) -> Option<V>;
5866
}
5967

6068
pub trait Set<T>: Mutable {

branches/snap-stage3/src/libcore/core.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,12 @@ pub mod unstable;
244244

245245
/* For internal use, not exported */
246246

247-
pub mod unicode;
247+
mod unicode;
248248
#[path = "num/cmath.rs"]
249-
pub mod cmath;
250-
pub mod stackwalk;
249+
mod cmath;
250+
mod stackwalk;
251251
#[path = "rt/mod.rs"]
252-
pub mod rt;
252+
mod rt;
253253

254254
// A curious inner-module that's not exported that contains the binding
255255
// 'core' so that macro-expanded references to core::error and such

branches/snap-stage3/src/libcore/gc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use libc::{size_t, uintptr_t};
4444
use option::{None, Option, Some};
4545
use ptr;
4646
use hashmap::HashSet;
47-
use stackwalk;
47+
use stackwalk::walk_stack;
4848
use sys;
4949

5050
pub use stackwalk::Word;
@@ -230,7 +230,7 @@ unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) {
230230
// frame is marked by a sentinel, which is a box pointer stored on
231231
// the stack.
232232
let mut reached_sentinel = ptr::is_null(sentinel);
233-
for stackwalk::walk_stack |frame| {
233+
for walk_stack |frame| {
234234
let pc = last_ret;
235235
let Segment {segment: next_segment, boundary: boundary} =
236236
find_segment_for_frame(frame.fp, segment);

branches/snap-stage3/src/libcore/hashmap.rs

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use rand::RngUtil;
2424
use rand;
2525
use uint;
2626
use vec;
27-
use util::unreachable;
2827
use kinds::Copy;
28+
use util::{replace, unreachable};
2929

3030
static INITIAL_CAPACITY: uint = 32u; // 2^5
3131

@@ -204,7 +204,7 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
204204
/// Inserts the key value pair into the buckets.
205205
/// Assumes that there will be a bucket.
206206
/// True if there was no previous entry with that key
207-
fn insert_internal(&mut self, hash: uint, k: K, v: V) -> bool {
207+
fn insert_internal(&mut self, hash: uint, k: K, v: V) -> Option<V> {
208208
match self.bucket_for_key_with_hash(hash, &k) {
209209
TableFull => { fail!(~"Internal logic error"); }
210210
FoundHole(idx) => {
@@ -213,14 +213,19 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
213213
self.buckets[idx] = Some(Bucket{hash: hash, key: k,
214214
value: v});
215215
self.size += 1;
216-
true
216+
None
217217
}
218218
FoundEntry(idx) => {
219219
debug!("insert overwrite (%?->%?) at idx %?, hash %?",
220220
k, v, idx, hash);
221-
self.buckets[idx] = Some(Bucket{hash: hash, key: k,
222-
value: v});
223-
false
221+
match self.buckets[idx] {
222+
None => { fail!(~"insert_internal: Internal logic error") }
223+
Some(ref mut b) => {
224+
b.hash = hash;
225+
b.key = k;
226+
Some(replace(&mut b.value, v))
227+
}
228+
}
224229
}
225230
}
226231
}
@@ -361,6 +366,20 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
361366
/// key is replaced by the new value. Return true if the key did
362367
/// not already exist in the map.
363368
fn insert(&mut self, k: K, v: V) -> bool {
369+
self.swap(k, v).is_none()
370+
}
371+
372+
/// Remove a key-value pair from the map. Return true if the key
373+
/// was present in the map, otherwise false.
374+
fn remove(&mut self, k: &K) -> bool {
375+
self.pop(k).is_some()
376+
}
377+
378+
/// Insert a key-value pair from the map. If the key already had a value
379+
/// present in the map, that value is returned. Otherwise None is returned.
380+
fn swap(&mut self, k: K, v: V) -> Option<V> {
381+
// this could be faster.
382+
364383
if self.size >= self.resize_at {
365384
// n.b.: We could also do this after searching, so
366385
// that we do not resize if this call to insert is
@@ -375,10 +394,11 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
375394
self.insert_internal(hash, k, v)
376395
}
377396
378-
/// Remove a key-value pair from the map. Return true if the key
379-
/// was present in the map, otherwise false.
380-
fn remove(&mut self, k: &K) -> bool {
381-
self.pop(k).is_some()
397+
/// Removes a key from the map, returning the value at the key if the key
398+
/// was previously in the map.
399+
fn pop(&mut self, k: &K) -> Option<V> {
400+
let hash = k.hash_keyed(self.k0, self.k1) as uint;
401+
self.pop_internal(hash, k)
382402
}
383403
}
384404
@@ -402,31 +422,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
402422
}
403423
}
404424
405-
fn pop(&mut self, k: &K) -> Option<V> {
406-
let hash = k.hash_keyed(self.k0, self.k1) as uint;
407-
self.pop_internal(hash, k)
408-
}
409-
410-
fn swap(&mut self, k: K, v: V) -> Option<V> {
411-
// this could be faster.
412-
let hash = k.hash_keyed(self.k0, self.k1) as uint;
413-
let old_value = self.pop_internal(hash, &k);
414-
415-
if self.size >= self.resize_at {
416-
// n.b.: We could also do this after searching, so
417-
// that we do not resize if this call to insert is
418-
// simply going to update a key in place. My sense
419-
// though is that it's worse to have to search through
420-
// buckets to find the right spot twice than to just
421-
// resize in this corner case.
422-
self.expand();
423-
}
424-
425-
self.insert_internal(hash, k, v);
426-
427-
old_value
428-
}
429-
430425
/// Return the value corresponding to the key in the map, or insert
431426
/// and return the value if it doesn't exist.
432427
fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V {

branches/snap-stage3/src/libcore/run.rs

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -855,74 +855,4 @@ mod tests {
855855
fn waitpid_non_existant_pid() {
856856
run::waitpid(123456789); // assume that this pid doesn't exist
857857
}
858-
859-
#[test]
860-
fn test_destroy_once() {
861-
let mut p = run::start_program("echo", []);
862-
p.destroy(); // this shouldn't crash (and nor should the destructor)
863-
}
864-
865-
#[test]
866-
fn test_destroy_twice() {
867-
let mut p = run::start_program("echo", []);
868-
p.destroy(); // this shouldnt crash...
869-
p.destroy(); // ...and nor should this (and nor should the destructor)
870-
}
871-
872-
fn test_destroy_actually_kills(force: bool) {
873-
874-
#[cfg(unix)]
875-
static BLOCK_COMMAND: &'static str = "cat";
876-
877-
#[cfg(windows)]
878-
static BLOCK_COMMAND: &'static str = "cmd";
879-
880-
#[cfg(unix)]
881-
fn process_exists(pid: libc::pid_t) -> bool {
882-
run::program_output("ps", [~"-p", pid.to_str()]).out.contains(pid.to_str())
883-
}
884-
885-
#[cfg(windows)]
886-
fn process_exists(pid: libc::pid_t) -> bool {
887-
888-
use libc::types::os::arch::extra::DWORD;
889-
use libc::funcs::extra::kernel32::{CloseHandle, GetExitCodeProcess, OpenProcess};
890-
use libc::consts::os::extra::{FALSE, PROCESS_QUERY_INFORMATION, STILL_ACTIVE };
891-
892-
unsafe {
893-
let proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD);
894-
if proc.is_null() {
895-
return false;
896-
}
897-
// proc will be non-null if the process is alive, or if it died recently
898-
let mut status = 0;
899-
GetExitCodeProcess(proc, &mut status);
900-
CloseHandle(proc);
901-
return status == STILL_ACTIVE;
902-
}
903-
}
904-
905-
// this program will stay alive indefinitely trying to read from stdin
906-
let mut p = run::start_program(BLOCK_COMMAND, []);
907-
908-
assert!(process_exists(p.get_id()));
909-
910-
if force {
911-
p.force_destroy();
912-
} else {
913-
p.destroy();
914-
}
915-
916-
assert!(!process_exists(p.get_id()));
917-
}
918-
919-
#[test]
920-
fn test_unforced_destroy_actually_kills() {
921-
test_destroy_actually_kills(false);
922-
}
923-
924-
#[test]
925-
fn test_forced_destroy_actually_kills() {
926-
test_destroy_actually_kills(true);
927-
}
928858
}

0 commit comments

Comments
 (0)