Skip to content

Commit c0c6e4c

Browse files
committed
---
yaml --- r: 73311 b: refs/heads/dist-snap c: 474d998 h: refs/heads/master i: 73309: 1809725 73307: 915319d 73303: 64efb41 73295: d71f87d 73279: 4ff2b52 v: v3
1 parent 5285d4c commit c0c6e4c

File tree

12 files changed

+80
-77
lines changed

12 files changed

+80
-77
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 24609675ebeff66f6299e98e4687618a48cf47e7
10+
refs/heads/dist-snap: 474d9983beb8a5770a202c552f36c14fa52917a2
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/cast.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,26 @@
1212
1313
use sys;
1414
use unstable;
15-
use unstable::intrinsics;
15+
16+
pub mod rusti {
17+
#[abi = "rust-intrinsic"]
18+
#[link_name = "rusti"]
19+
pub extern "rust-intrinsic" {
20+
fn forget<T>(x: T);
21+
22+
fn transmute<T,U>(e: T) -> U;
23+
}
24+
}
1625

1726
/// Casts the value at `src` to U. The two types must have the same length.
1827
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
19-
let mut dest: U = intrinsics::init();
28+
let mut dest: U = unstable::intrinsics::init();
2029
{
21-
let dest_ptr: *mut u8 = transmute(&mut dest);
22-
let src_ptr: *u8 = transmute(src);
23-
intrinsics::memmove64(dest_ptr,
24-
src_ptr,
25-
sys::size_of::<U>() as u64);
30+
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
31+
let src_ptr: *u8 = rusti::transmute(src);
32+
unstable::intrinsics::memmove64(dest_ptr,
33+
src_ptr,
34+
sys::size_of::<U>() as u64);
2635
}
2736
dest
2837
}
@@ -36,7 +45,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
3645
* reinterpret_cast on pointer types.
3746
*/
3847
#[inline(always)]
39-
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
48+
pub unsafe fn forget<T>(thing: T) { rusti::forget(thing); }
4049

4150
/**
4251
* Force-increment the reference count on a shared box. If used
@@ -56,7 +65,7 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
5665
*/
5766
#[inline(always)]
5867
pub unsafe fn transmute<L, G>(thing: L) -> G {
59-
intrinsics::transmute(thing)
68+
rusti::transmute(thing)
6069
}
6170

6271
/// Coerce an immutable reference to be mutable.

branches/dist-snap/src/libcore/clone.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ by convention implementing the `Clone` trait and calling the
2525
use core::kinds::Const;
2626

2727
pub trait Clone {
28-
/// Returns a copy of the value. The contents of owned pointers
29-
/// are copied to maintain uniqueness, while the contents of
30-
/// managed pointers are not copied.
28+
/// Return a deep copy of the owned object tree. Types with shared ownership like managed boxes
29+
/// are cloned with a shallow copy.
3130
fn clone(&self) -> Self;
3231
}
3332

@@ -86,9 +85,8 @@ clone_impl!(bool)
8685
clone_impl!(char)
8786

8887
pub trait DeepClone {
89-
/// Return a deep copy of the value. Unlike `Clone`, the contents of shared pointer types
90-
/// *are* copied. Note that this is currently unimplemented for managed boxes, as
91-
/// it would need to handle cycles, but it is implemented for other smart-pointer types.
88+
/// Return a deep copy of the object tree. Types with shared ownership are also copied via a
89+
/// deep copy, unlike `Clone`.
9290
fn deep_clone(&self) -> Self;
9391
}
9492

branches/dist-snap/src/libcore/stackwalk.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#[doc(hidden)]; // FIXME #3538
1212

1313
use cast::transmute;
14-
use unstable::intrinsics;
1514

1615
pub type Word = uint;
1716

@@ -76,6 +75,13 @@ fn test_simple_deep() {
7675

7776
fn frame_address(f: &fn(x: *u8)) {
7877
unsafe {
79-
intrinsics::frame_address(f)
78+
rusti::frame_address(f)
79+
}
80+
}
81+
82+
pub mod rusti {
83+
#[abi = "rust-intrinsic"]
84+
pub extern "rust-intrinsic" {
85+
pub fn frame_address(f: &once fn(x: *u8));
8086
}
8187
}

branches/dist-snap/src/libcore/sys.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use libc;
1919
use libc::{c_void, c_char, size_t};
2020
use repr;
2121
use str;
22-
use unstable::intrinsics;
2322

2423
pub type FreeGlue<'self> = &'self fn(*TypeDesc, *c_void);
2524

@@ -39,6 +38,16 @@ pub struct Closure {
3938
env: *(),
4039
}
4140

41+
pub mod rusti {
42+
#[abi = "rust-intrinsic"]
43+
pub extern "rust-intrinsic" {
44+
fn get_tydesc<T>() -> *();
45+
fn size_of<T>() -> uint;
46+
fn pref_align_of<T>() -> uint;
47+
fn min_align_of<T>() -> uint;
48+
}
49+
}
50+
4251
pub mod rustrt {
4352
use libc::{c_char, size_t};
4453

@@ -72,7 +81,7 @@ pub fn shape_le<T:Ord>(x1: &T, x2: &T) -> bool {
7281
*/
7382
#[inline(always)]
7483
pub fn get_type_desc<T>() -> *TypeDesc {
75-
unsafe { intrinsics::get_tydesc::<T>() as *TypeDesc }
84+
unsafe { rusti::get_tydesc::<T>() as *TypeDesc }
7685
}
7786

7887
/// Returns a pointer to a type descriptor.
@@ -84,7 +93,7 @@ pub fn get_type_desc_val<T>(_val: &T) -> *TypeDesc {
8493
/// Returns the size of a type
8594
#[inline(always)]
8695
pub fn size_of<T>() -> uint {
87-
unsafe { intrinsics::size_of::<T>() }
96+
unsafe { rusti::size_of::<T>() }
8897
}
8998

9099
/// Returns the size of the type that `_val` points to
@@ -119,7 +128,7 @@ pub fn nonzero_size_of_val<T>(_val: &T) -> uint {
119128
*/
120129
#[inline(always)]
121130
pub fn min_align_of<T>() -> uint {
122-
unsafe { intrinsics::min_align_of::<T>() }
131+
unsafe { rusti::min_align_of::<T>() }
123132
}
124133

125134
/// Returns the ABI-required minimum alignment of the type of the value that
@@ -132,7 +141,7 @@ pub fn min_align_of_val<T>(_val: &T) -> uint {
132141
/// Returns the preferred alignment of a type
133142
#[inline(always)]
134143
pub fn pref_align_of<T>() -> uint {
135-
unsafe { intrinsics::pref_align_of::<T>() }
144+
unsafe { rusti::pref_align_of::<T>() }
136145
}
137146

138147
/// Returns the preferred alignment of the type of the value that

branches/dist-snap/src/libcore/unstable/intrinsics.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,15 @@ pub extern "rust-intrinsic" {
114114
/// `forget` is unsafe because the caller is responsible for
115115
/// ensuring the argument is deallocated already.
116116
pub unsafe fn forget<T>(_: T) -> ();
117-
pub fn transmute<T,U>(e: T) -> U;
118117

119118
/// Returns `true` if a type requires drop glue.
120119
pub fn needs_drop<T>() -> bool;
121120

122121
// XXX: intrinsic uses legacy modes and has reference to TyDesc
123122
// and TyVisitor which are in librustc
124123
//fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor) -> ();
125-
126-
pub fn frame_address(f: &once fn(*u8));
124+
// XXX: intrinsic uses legacy modes
125+
//fn frame_address(f: &once fn(*u8));
127126

128127
/// Get the address of the `__morestack` stack growth function.
129128
pub fn morestack_addr() -> *();

branches/dist-snap/src/librustc/lib/llvm.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,13 +1571,15 @@ pub mod llvm {
15711571
pub unsafe fn LLVMBuildAtomicLoad(B: BuilderRef,
15721572
PointerVal: ValueRef,
15731573
Name: *c_char,
1574-
Order: AtomicOrdering)
1574+
Order: AtomicOrdering,
1575+
Alignment: c_uint)
15751576
-> ValueRef;
15761577

15771578
pub unsafe fn LLVMBuildAtomicStore(B: BuilderRef,
15781579
Val: ValueRef,
15791580
Ptr: ValueRef,
1580-
Order: AtomicOrdering)
1581+
Order: AtomicOrdering,
1582+
Alignment: c_uint)
15811583
-> ValueRef;
15821584

15831585
pub unsafe fn LLVMBuildAtomicCmpXchg(B: BuilderRef,

branches/dist-snap/src/librustc/middle/trans/build.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use lib::llvm::{Opcode, IntPredicate, RealPredicate, False};
1414
use lib::llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, ModuleRef};
1515
use lib;
1616
use middle::trans::common::*;
17+
use middle::trans::machine::llalign_of_min;
1718
use syntax::codemap::span;
1819

1920
use core::hashmap::HashMap;
@@ -544,7 +545,8 @@ pub fn AtomicLoad(cx: block, PointerVal: ValueRef, order: AtomicOrdering) -> Val
544545
return llvm::LLVMGetUndef(ccx.int_type);
545546
}
546547
count_insn(cx, "load.atomic");
547-
return llvm::LLVMBuildAtomicLoad(B(cx), PointerVal, noname(), order);
548+
let align = llalign_of_min(*ccx, ccx.int_type);
549+
return llvm::LLVMBuildAtomicLoad(B(cx), PointerVal, noname(), order, align as c_uint);
548550
}
549551
}
550552
@@ -558,7 +560,6 @@ pub fn LoadRangeAssert(cx: block, PointerVal: ValueRef, lo: c_ulonglong,
558560
let min = llvm::LLVMConstInt(t, lo, signed);
559561
let max = llvm::LLVMConstInt(t, hi, signed);
560562
561-
562563
do vec::as_imm_buf([min, max]) |ptr, len| {
563564
llvm::LLVMSetMetadata(value, lib::llvm::MD_range as c_uint,
564565
llvm::LLVMMDNode(ptr, len as c_uint));
@@ -586,7 +587,8 @@ pub fn AtomicStore(cx: block, Val: ValueRef, Ptr: ValueRef, order: AtomicOrderin
586587
val_str(cx.ccx().tn, Val),
587588
val_str(cx.ccx().tn, Ptr));
588589
count_insn(cx, "store.atomic");
589-
llvm::LLVMBuildAtomicStore(B(cx), Val, Ptr, order);
590+
let align = llalign_of_min(cx.ccx(), cx.ccx().int_type);
591+
llvm::LLVMBuildAtomicStore(B(cx), Val, Ptr, order, align as c_uint);
590592
}
591593
}
592594

branches/dist-snap/src/libstd/arc.rs

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,33 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/*!
11+
/**
1212
* Concurrency-enabled mechanisms for sharing mutable and/or immutable state
1313
* between tasks.
14-
*
15-
* # Example
16-
*
17-
* In this example, a large vector of floats is shared between several tasks.
18-
* With simple pipes, without ARC, a copy would have to be made for each task.
19-
*
20-
* ~~~
21-
* extern mod std;
22-
* use std::arc;
23-
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
24-
* let shared_numbers=arc::ARC(numbers);
25-
*
26-
* for 10.times {
27-
* let (port, chan) = stream();
28-
* chan.send(shared_numbers.clone());
29-
*
30-
* do spawn {
31-
* let shared_numbers=port.recv();
32-
* let local_numbers=shared_numbers.get();
33-
*
34-
* // Work with the local numbers
35-
* }
36-
* }
37-
* ~~~
3814
*/
3915

4016
use sync;
@@ -45,7 +21,7 @@ use core::unstable::sync::UnsafeAtomicRcBox;
4521
use core::ptr;
4622
use core::task;
4723

48-
/// As sync::condvar, a mechanism for unlock-and-descheduling and signaling.
24+
/// As sync::condvar, a mechanism for unlock-and-descheduling and signalling.
4925
pub struct Condvar<'self> {
5026
is_mutex: bool,
5127
failed: &'self mut bool,
@@ -117,14 +93,9 @@ pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
11793
* wrapper.
11894
*/
11995
pub fn get<'a, T:Const + Owned>(rc: &'a ARC<T>) -> &'a T {
120-
rc.get()
96+
unsafe { &*rc.x.get_immut() }
12197
}
12298

123-
impl<T:Const+Owned> ARC<T> {
124-
pub fn get<'a>(&'a self) -> &'a T {
125-
unsafe { &*self.x.get_immut() }
126-
}
127-
}
12899
/**
129100
* Duplicate an atomically reference counted wrapper.
130101
*
@@ -537,7 +508,6 @@ mod tests {
537508
c.send(arc::clone(&arc_v));
538509

539510
assert_eq!((*arc::get(&arc_v))[2], 3);
540-
assert_eq!(arc_v.get()[4], 5);
541511

542512
info!(arc_v);
543513
}

branches/dist-snap/src/libstd/arena.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ use core::sys::TypeDesc;
4343
use core::sys;
4444
use core::uint;
4545
use core::vec;
46-
use core::unstable::intrinsics;
46+
47+
pub mod rusti {
48+
#[abi = "rust-intrinsic"]
49+
pub extern "rust-intrinsic" {
50+
fn move_val_init<T>(dst: &mut T, src: T);
51+
fn needs_drop<T>() -> bool;
52+
}
53+
}
4754

4855
pub mod rustrt {
4956
use core::libc::size_t;
@@ -201,7 +208,7 @@ pub impl Arena {
201208
let tydesc = sys::get_type_desc::<T>();
202209
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
203210
let ptr: *mut T = transmute(ptr);
204-
intrinsics::move_val_init(&mut (*ptr), op());
211+
rusti::move_val_init(&mut (*ptr), op());
205212
return transmute(ptr);
206213
}
207214
}
@@ -254,7 +261,7 @@ pub impl Arena {
254261
// has *not* been initialized yet.
255262
*ty_ptr = transmute(tydesc);
256263
// Actually initialize it
257-
intrinsics::move_val_init(&mut(*ptr), op());
264+
rusti::move_val_init(&mut(*ptr), op());
258265
// Now that we are done, update the tydesc to indicate that
259266
// the object is there.
260267
*ty_ptr = bitpack_tydesc_ptr(tydesc, true);
@@ -269,7 +276,7 @@ pub impl Arena {
269276
unsafe {
270277
// XXX: Borrow check
271278
let this = transmute_mut_region(self);
272-
if !intrinsics::needs_drop::<T>() {
279+
if !rusti::needs_drop::<T>() {
273280
return this.alloc_pod(op);
274281
}
275282
// XXX: Borrow check

branches/dist-snap/src/libstd/priority_queue.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
//! A priority queue implemented with a binary heap
1212
1313
use core::old_iter::BaseIter;
14-
use core::unstable::intrinsics::{move_val_init, init};
15-
use core::unstable::intrinsics::uninit;
1614
use core::util::{replace, swap};
15+
use core::unstable::intrinsics::{init, move_val_init};
1716

1817
pub struct PriorityQueue<T> {
1918
priv data: ~[T],

0 commit comments

Comments
 (0)