Skip to content

Commit 4cee93f

Browse files
committed
---
yaml --- r: 139057 b: refs/heads/try2 c: 087a015 h: refs/heads/master i: 139055: 4da73cf v: v3
1 parent 519b906 commit 4cee93f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+453
-135
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 321a54d26f1851f64feab6dba19b7af2e9e7c75f
8+
refs/heads/try2: 087a015a727b11d46ff5a309ff37c7967e8636d1
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/cleanup.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,7 @@ unsafe fn each_live_alloc(f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
145145

146146
#[cfg(unix)]
147147
fn debug_mem() -> bool {
148-
use os;
149-
use libc;
150-
do os::as_c_charp("RUST_DEBUG_MEM") |p| {
151-
unsafe { libc::getenv(p) != null() }
152-
}
148+
::rt::env::get().debug_mem
153149
}
154150

155151
#[cfg(windows)]

branches/try2/src/libcore/clone.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ impl Clone for () {
2020
fn clone(&self) -> () { () }
2121
}
2222

23+
impl<T:Clone> Clone for ~T {
24+
#[inline(always)]
25+
fn clone(&self) -> ~T { ~(**self).clone() }
26+
}
27+
2328
macro_rules! clone_impl(
2429
($t:ty) => {
2530
impl Clone for $t {

branches/try2/src/libcore/rt/env.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Runtime environment settings
12+
13+
use libc::{size_t, c_char, c_int};
14+
15+
pub struct Environment {
16+
/// The number of threads to use by default
17+
num_sched_threads: size_t,
18+
/// The minimum size of a stack segment
19+
min_stack_size: size_t,
20+
/// The maximum amount of total stack per task before aborting
21+
max_stack_size: size_t,
22+
/// The default logging configuration
23+
logspec: *c_char,
24+
/// Record and report detailed information about memory leaks
25+
detailed_leaks: bool,
26+
/// Seed the random number generator
27+
rust_seed: *c_char,
28+
/// Poison allocations on free
29+
poison_on_free: bool,
30+
/// The argc value passed to main
31+
argc: c_int,
32+
/// The argv value passed to main
33+
argv: **c_char,
34+
/// Print GC debugging info
35+
debug_mem: bool
36+
}
37+
38+
/// Get the global environment settings
39+
/// # Safety Note
40+
/// This will abort the process if run outside of task context
41+
pub fn get() -> &Environment {
42+
unsafe { rust_get_rt_env() }
43+
}
44+
45+
extern {
46+
fn rust_get_rt_env() -> &Environment;
47+
}

branches/try2/src/libcore/rt/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ mod work_queue;
4545
mod stack;
4646
mod context;
4747
mod thread;
48+
pub mod env;

branches/try2/src/libcore/str.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use at_vec;
2121
use cast;
2222
use char;
23+
use clone::Clone;
2324
use cmp::{Equiv, TotalOrd, Ordering, Less, Equal, Greater};
2425
use libc;
2526
use option::{None, Option, Some};
@@ -2436,6 +2437,13 @@ impl OwnedStr for ~str {
24362437
}
24372438
}
24382439
2440+
impl Clone for ~str {
2441+
#[inline(always)]
2442+
fn clone(&self) -> ~str {
2443+
self.to_str() // hilarious
2444+
}
2445+
}
2446+
24392447
#[cfg(test)]
24402448
mod tests {
24412449
use char;

branches/try2/src/libcore/trie.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl<T> Map<uint, T> for TrieMap<T> {
137137
}
138138

139139
impl<T> TrieMap<T> {
140+
/// Create an empty TrieMap
140141
#[inline(always)]
141142
static pure fn new() -> TrieMap<T> {
142143
TrieMap{root: TrieNode::new(), length: 0}
@@ -191,6 +192,12 @@ impl Mutable for TrieSet {
191192
}
192193

193194
impl TrieSet {
195+
/// Create an empty TrieSet
196+
#[inline(always)]
197+
static pure fn new() -> TrieSet {
198+
TrieSet{map: TrieMap::new()}
199+
}
200+
194201
/// Return true if the set contains a value
195202
#[inline(always)]
196203
pure fn contains(&self, value: &uint) -> bool {
@@ -265,8 +272,8 @@ impl<T> TrieNode<T> {
265272
// if this was done via a trait, the key could be generic
266273
#[inline(always)]
267274
pure fn chunk(n: uint, idx: uint) -> uint {
268-
let real_idx = uint::bytes - 1 - idx;
269-
(n >> (SHIFT * real_idx)) & MASK
275+
let sh = uint::bits - (SHIFT * (idx + 1));
276+
(n >> sh) & MASK
270277
}
271278

272279
fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T,
@@ -462,4 +469,26 @@ mod tests {
462469
n -= 1;
463470
}
464471
}
472+
473+
#[test]
474+
fn test_sane_chunk() {
475+
let x = 1;
476+
let y = 1 << (uint::bits - 1);
477+
478+
let mut trie = TrieSet::new();
479+
480+
fail_unless!(trie.insert(x));
481+
fail_unless!(trie.insert(y));
482+
483+
fail_unless!(trie.len() == 2);
484+
485+
let expected = [x, y];
486+
487+
let mut i = 0;
488+
489+
for trie.each |x| {
490+
fail_unless!(expected[i] == *x);
491+
i += 1;
492+
}
493+
}
465494
}

branches/try2/src/libcore/unstable/global.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ unsafe fn global_data_clone_create_<T:Owned + Clone>(
6868
match value {
6969
None => {
7070
let value = create();
71-
clone_value = Some(value.clone());
71+
clone_value = Some((*value).clone());
7272
Some(value)
7373
}
7474
Some(value) => {
75-
clone_value = Some(value.clone());
75+
clone_value = Some((*value).clone());
7676
Some(value)
7777
}
7878
}
@@ -193,7 +193,7 @@ fn get_global_state() -> Exclusive<GlobalState> {
193193
// Successfully installed the global pointer
194194

195195
// Take a handle to return
196-
let clone = state.clone();
196+
let clone = (*state).clone();
197197

198198
// Install a runtime exit function to destroy the global object
199199
do at_exit {

branches/try2/src/libcore/vec.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use container::{Container, Mutable};
1616
use cast;
1717
use cmp::{Eq, Equiv, Ord, TotalOrd, Ordering, Less, Equal, Greater};
18+
use clone::Clone;
1819
use iter::BaseIter;
1920
use iter;
2021
use kinds::Copy;
@@ -2501,6 +2502,18 @@ impl<A:Copy> iter::CopyableNonstrictIter<A> for @[A] {
25012502
}
25022503
}
25032504

2505+
impl<A:Clone> Clone for ~[A] {
2506+
#[inline]
2507+
fn clone(&self) -> ~[A] {
2508+
let mut dolly = ~[];
2509+
vec::reserve(&mut dolly, self.len());
2510+
for self.each |item| {
2511+
dolly.push(item.clone());
2512+
}
2513+
return dolly;
2514+
}
2515+
}
2516+
25042517
// ___________________________________________________________________________
25052518

25062519
#[cfg(test)]

branches/try2/src/librustc/middle/liveness.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,15 @@ pub impl Liveness {
13471347
self.propagate_through_expr(e, succ)
13481348
}
13491349
1350-
expr_inline_asm(*) |
1350+
expr_inline_asm(_, ins, outs, _, _, _) =>{
1351+
let succ = do ins.foldr(succ) |&(_, expr), succ| {
1352+
self.propagate_through_expr(expr, succ)
1353+
};
1354+
do outs.foldr(succ) |&(_, expr), succ| {
1355+
self.propagate_through_expr(expr, succ)
1356+
}
1357+
}
1358+
13511359
expr_lit(*) => {
13521360
succ
13531361
}
@@ -1613,6 +1621,20 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
16131621
visit::visit_expr(expr, self, vt);
16141622
}
16151623

1624+
expr_inline_asm(_, ins, outs, _, _, _) => {
1625+
for ins.each |&(_, in)| {
1626+
(vt.visit_expr)(in, self, vt);
1627+
}
1628+
1629+
// Output operands must be lvalues
1630+
for outs.each |&(_, out)| {
1631+
self.check_lvalue(out, vt);
1632+
(vt.visit_expr)(out, self, vt);
1633+
}
1634+
1635+
visit::visit_expr(expr, self, vt);
1636+
}
1637+
16161638
// no correctness conditions related to liveness
16171639
expr_call(*) | expr_method_call(*) | expr_if(*) | expr_match(*) |
16181640
expr_while(*) | expr_loop(*) | expr_index(*) | expr_field(*) |
@@ -1621,7 +1643,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
16211643
expr_cast(*) | expr_unary(*) | expr_ret(*) | expr_break(*) |
16221644
expr_again(*) | expr_lit(_) | expr_block(*) | expr_swap(*) |
16231645
expr_mac(*) | expr_addr_of(*) | expr_struct(*) | expr_repeat(*) |
1624-
expr_paren(*) | expr_inline_asm(*) => {
1646+
expr_paren(*) => {
16251647
visit::visit_expr(expr, self, vt);
16261648
}
16271649
}

branches/try2/src/librustc/middle/moves.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,10 @@ pub impl VisitContext {
558558
self.use_expr(base, Read, visitor);
559559
}
560560

561+
expr_inline_asm(*) |
561562
expr_break(*) |
562563
expr_again(*) |
563-
expr_lit(*) |
564-
expr_inline_asm(*) => {}
564+
expr_lit(*) => {}
565565

566566
expr_loop(ref blk, _) => {
567567
self.consume_block(blk, visitor);

branches/try2/src/librustc/middle/trans/build.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ pub fn add_comment(bcx: block, text: &str) {
873873
}
874874
875875
pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
876+
inputs: &[ValueRef], output: TypeRef,
876877
volatile: bool, alignstack: bool,
877878
dia: AsmDialect) -> ValueRef {
878879
unsafe {
@@ -883,11 +884,17 @@ pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
883884
let alignstack = if alignstack { lib::llvm::True }
884885
else { lib::llvm::False };
885886
886-
let llfty = T_fn(~[], T_void());
887+
let argtys = do inputs.map |v| {
888+
debug!("Asm Input Type: %?", val_str(cx.ccx().tn, *v));
889+
val_ty(*v)
890+
};
891+
892+
debug!("Asm Output Type: %?", ty_str(cx.ccx().tn, output));
893+
let llfty = T_fn(argtys, output);
887894
let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile,
888895
alignstack, dia as c_uint);
889896
890-
Call(cx, v, ~[])
897+
Call(cx, v, inputs)
891898
}
892899
}
893900

0 commit comments

Comments
 (0)