Skip to content

Commit 04172ad

Browse files
committed
---
yaml --- r: 139047 b: refs/heads/try2 c: ebba8b4 h: refs/heads/master i: 139045: 7364a99 139043: f1060a5 139039: 9d52971 v: v3
1 parent 1cc4379 commit 04172ad

Some content is hidden

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

62 files changed

+352
-124
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: d856215b925441a4889cb23cab5758c36e4a4746
8+
refs/heads/try2: ebba8b4e3591c95508a4c1121784e768272a574a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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/thread_local_storage.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type pthread_key_t = c_ulong;
4040

4141
#[cfg(target_os="linux")]
4242
#[cfg(target_os="freebsd")]
43+
#[cfg(target_os="android")]
4344
#[allow(non_camel_case_types)] // foreign type
4445
type pthread_key_t = c_uint;
4546

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/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

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

Lines changed: 103 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,109 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
557557
ast::expr_paren(a) => {
558558
return trans_rvalue_stmt_unadjusted(bcx, a);
559559
}
560+
ast::expr_inline_asm(asm, ref ins, ref outs,
561+
clobs, volatile, alignstack) => {
562+
let mut constraints = ~[];
563+
let mut cleanups = ~[];
564+
let mut aoutputs = ~[];
565+
566+
let outputs = do outs.map |&(c, out)| {
567+
constraints.push(copy *c);
568+
569+
let aoutty = ty::arg {
570+
mode: ast::expl(ast::by_copy),
571+
ty: expr_ty(bcx, out)
572+
};
573+
aoutputs.push(unpack_result!(bcx, {
574+
callee::trans_arg_expr(bcx, aoutty, out, &mut cleanups,
575+
None, callee::DontAutorefArg)
576+
}));
577+
578+
let e = match out.node {
579+
ast::expr_addr_of(_, e) => e,
580+
_ => fail!(~"Expression must be addr of")
581+
};
582+
583+
let outty = ty::arg {
584+
mode: ast::expl(ast::by_copy),
585+
ty: expr_ty(bcx, e)
586+
};
587+
588+
unpack_result!(bcx, {
589+
callee::trans_arg_expr(bcx, outty, e, &mut cleanups,
590+
None, callee::DontAutorefArg)
591+
})
592+
593+
};
594+
595+
for cleanups.each |c| {
596+
revoke_clean(bcx, *c);
597+
}
598+
cleanups = ~[];
599+
600+
let inputs = do ins.map |&(c, in)| {
601+
constraints.push(copy *c);
602+
603+
let inty = ty::arg {
604+
mode: ast::expl(ast::by_copy),
605+
ty: expr_ty(bcx, in)
606+
};
607+
608+
unpack_result!(bcx, {
609+
callee::trans_arg_expr(bcx, inty, in, &mut cleanups,
610+
None, callee::DontAutorefArg)
611+
})
612+
613+
};
614+
615+
for cleanups.each |c| {
616+
revoke_clean(bcx, *c);
617+
}
618+
619+
let mut constraints = str::connect(constraints, ",");
620+
621+
// Add the clobbers
622+
if *clobs != ~"" {
623+
if constraints == ~"" {
624+
constraints += *clobs;
625+
} else {
626+
constraints += ~"," + *clobs;
627+
}
628+
} else {
629+
constraints += *clobs;
630+
}
631+
632+
debug!("Asm Constraints: %?", constraints);
633+
634+
let output = if outputs.len() == 0 {
635+
T_void()
636+
} else if outputs.len() == 1 {
637+
val_ty(outputs[0])
638+
} else {
639+
T_struct(outputs.map(|o| val_ty(*o)))
640+
};
641+
642+
let r = do str::as_c_str(*asm) |a| {
643+
do str::as_c_str(constraints) |c| {
644+
InlineAsmCall(bcx, a, c, inputs, output, volatile,
645+
alignstack, lib::llvm::AD_ATT)
646+
}
647+
};
648+
649+
if outputs.len() == 1 {
650+
let op = PointerCast(bcx, aoutputs[0],
651+
T_ptr(val_ty(outputs[0])));
652+
Store(bcx, r, op);
653+
} else {
654+
for aoutputs.eachi |i, o| {
655+
let v = ExtractValue(bcx, r, i);
656+
let op = PointerCast(bcx, *o, T_ptr(val_ty(outputs[i])));
657+
Store(bcx, v, op);
658+
}
659+
}
660+
661+
return bcx;
662+
}
560663
_ => {
561664
bcx.tcx().sess.span_bug(
562665
expr.span,
@@ -691,17 +794,6 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
691794
ast::expr_assign_op(op, dst, src) => {
692795
return trans_assign_op(bcx, expr, op, dst, src);
693796
}
694-
ast::expr_inline_asm(asm, cons, volatile, alignstack) => {
695-
// XXX: cons doesn't actual contain ALL the stuff we should
696-
// be passing since the constraints for in/outputs aren't included
697-
do str::as_c_str(*asm) |a| {
698-
do str::as_c_str(*cons) |c| {
699-
InlineAsmCall(bcx, a, c, volatile, alignstack,
700-
lib::llvm::AD_ATT);
701-
}
702-
}
703-
return bcx;
704-
}
705797
_ => {
706798
bcx.tcx().sess.span_bug(
707799
expr.span,

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,22 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
348348
}
349349
mark_for_method_call(cx, e.id, e.callee_id);
350350
}
351+
352+
expr_inline_asm(_, ref ins, ref outs, _, _, _) => {
353+
for ins.each |&(_, in)| {
354+
node_type_needs(cx, use_repr, in.id);
355+
}
356+
for outs.each |&(_, out)| {
357+
node_type_needs(cx, use_repr, out.id);
358+
}
359+
}
360+
351361
expr_paren(e) => mark_for_expr(cx, e),
352362

353363
expr_match(*) | expr_block(_) | expr_if(*) | expr_while(*) |
354364
expr_break(_) | expr_again(_) | expr_unary(_, _) | expr_lit(_) |
355365
expr_mac(_) | expr_addr_of(_, _) | expr_ret(_) | expr_loop(_, _) |
356-
expr_loop_body(_) | expr_do_body(_) | expr_inline_asm(*) => ()
366+
expr_loop_body(_) | expr_do_body(_) => ()
357367
}
358368
}
359369

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3102,7 +3102,6 @@ pub fn expr_kind(tcx: ctxt,
31023102
ast::expr_block(*) |
31033103
ast::expr_copy(*) |
31043104
ast::expr_repeat(*) |
3105-
ast::expr_inline_asm(*) |
31063105
ast::expr_lit(@codemap::spanned {node: lit_str(_), _}) |
31073106
ast::expr_vstore(_, ast::expr_vstore_slice) |
31083107
ast::expr_vstore(_, ast::expr_vstore_mut_slice) |
@@ -3145,6 +3144,7 @@ pub fn expr_kind(tcx: ctxt,
31453144
ast::expr_loop(*) |
31463145
ast::expr_assign(*) |
31473146
ast::expr_swap(*) |
3147+
ast::expr_inline_asm(*) |
31483148
ast::expr_assign_op(*) => {
31493149
RvalueStmtExpr
31503150
}

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2317,8 +2317,15 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
23172317
let region_lb = ty::re_scope(expr.id);
23182318
instantiate_path(fcx, pth, tpt, expr.span, expr.id, region_lb);
23192319
}
2320-
ast::expr_inline_asm(*) => {
2320+
ast::expr_inline_asm(_, ins, outs, _, _, _) => {
23212321
fcx.require_unsafe(expr.span, ~"use of inline assembly");
2322+
2323+
for ins.each |&(_, in)| {
2324+
check_expr(fcx, in);
2325+
}
2326+
for outs.each |&(_, out)| {
2327+
check_expr(fcx, out);
2328+
}
23222329
fcx.write_nil(id);
23232330
}
23242331
ast::expr_mac(_) => tcx.sess.bug(~"unexpanded macro"),

0 commit comments

Comments
 (0)