Skip to content

Remove Durable #6317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcore/core.rc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ they contained the following prologue:

/* Reexported core operators */

pub use kinds::{Const, Copy, Owned, Durable};
pub use kinds::{Const, Copy, Owned};
pub use ops::{Drop};
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
pub use ops::{BitAnd, BitOr, BitXor};
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/kinds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ The 4 kinds are
* Const - types that are deeply immutable. Const types are used for
freezable data structures.

* Durable - types that do not contain borrowed pointers.

`Copy` types include both implicitly copyable types that the compiler
will copy automatically and non-implicitly copyable types that require
the `copy` keyword to copy. Types that do not implement `Copy` may
Expand All @@ -55,6 +53,7 @@ pub trait Const {
}

#[lang="durable"]
#[cfg(stage0)]
pub trait Durable {
// Empty.
}
2 changes: 1 addition & 1 deletion src/libcore/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/* Reexported core operators */

pub use either::{Either, Left, Right};
pub use kinds::{Const, Copy, Owned, Durable};
pub use kinds::{Const, Copy, Owned};
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
pub use ops::{BitAnd, BitOr, BitXor};
pub use ops::{Drop};
Expand Down
17 changes: 13 additions & 4 deletions src/libcore/task/local_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub type LocalDataKey<'self,T> = &'self fn(v: @T);
* Remove a task-local data value from the table, returning the
* reference that was originally created to insert it.
*/
pub unsafe fn local_data_pop<T:Durable>(
pub unsafe fn local_data_pop<T: 'static>(
key: LocalDataKey<T>) -> Option<@T> {

local_pop(Handle::new(), key)
Expand All @@ -58,7 +58,7 @@ pub unsafe fn local_data_pop<T:Durable>(
* Retrieve a task-local data value. It will also be kept alive in the
* table until explicitly removed.
*/
pub unsafe fn local_data_get<T:Durable>(
pub unsafe fn local_data_get<T: 'static>(
key: LocalDataKey<T>) -> Option<@T> {

local_get(Handle::new(), key)
Expand All @@ -67,7 +67,7 @@ pub unsafe fn local_data_get<T:Durable>(
* Store a value in task-local data. If this key already has a value,
* that value is overwritten (and its destructor is run).
*/
pub unsafe fn local_data_set<T:Durable>(
pub unsafe fn local_data_set<T: 'static>(
key: LocalDataKey<T>, data: @T) {

local_set(Handle::new(), key, data)
Expand All @@ -76,7 +76,7 @@ pub unsafe fn local_data_set<T:Durable>(
* Modify a task-local data value. If the function returns 'None', the
* data is removed (and its reference dropped).
*/
pub unsafe fn local_data_modify<T:Durable>(
pub unsafe fn local_data_modify<T: 'static>(
key: LocalDataKey<T>,
modify_fn: &fn(Option<@T>) -> Option<@T>) {

Expand Down Expand Up @@ -215,3 +215,12 @@ fn test_tls_cleanup_on_failure() {
fail!();
}
}

#[test]
fn test_static_pointer() {
unsafe {
fn key(_x: @&'static int) { }
static VALUE: int = 0;
local_data_set(key, @&VALUE);
}
}
16 changes: 8 additions & 8 deletions src/libcore/task/local_data_priv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Handle {
}

pub trait LocalData { }
impl<T:Durable> LocalData for @T { }
impl<T: 'static> LocalData for @T { }

impl Eq for @LocalData {
fn eq(&self, other: &@LocalData) -> bool {
Expand Down Expand Up @@ -131,15 +131,15 @@ unsafe fn get_newsched_local_map(local: *mut LocalStorage) -> TaskLocalMap {
}
}

unsafe fn key_to_key_value<T:Durable>(key: LocalDataKey<T>) -> *libc::c_void {
unsafe fn key_to_key_value<T: 'static>(key: LocalDataKey<T>) -> *libc::c_void {
// Keys are closures, which are (fnptr,envptr) pairs. Use fnptr.
// Use reintepret_cast -- transmute would leak (forget) the closure.
let pair: (*libc::c_void, *libc::c_void) = cast::transmute_copy(&key);
pair.first()
}

// If returning Some(..), returns with @T with the map's reference. Careful!
unsafe fn local_data_lookup<T:Durable>(
unsafe fn local_data_lookup<T: 'static>(
map: TaskLocalMap, key: LocalDataKey<T>)
-> Option<(uint, *libc::c_void)> {

Expand All @@ -157,7 +157,7 @@ unsafe fn local_data_lookup<T:Durable>(
}
}

unsafe fn local_get_helper<T:Durable>(
unsafe fn local_get_helper<T: 'static>(
handle: Handle, key: LocalDataKey<T>,
do_pop: bool) -> Option<@T> {

Expand All @@ -179,21 +179,21 @@ unsafe fn local_get_helper<T:Durable>(
}


pub unsafe fn local_pop<T:Durable>(
pub unsafe fn local_pop<T: 'static>(
handle: Handle,
key: LocalDataKey<T>) -> Option<@T> {

local_get_helper(handle, key, true)
}

pub unsafe fn local_get<T:Durable>(
pub unsafe fn local_get<T: 'static>(
handle: Handle,
key: LocalDataKey<T>) -> Option<@T> {

local_get_helper(handle, key, false)
}

pub unsafe fn local_set<T:Durable>(
pub unsafe fn local_set<T: 'static>(
handle: Handle, key: LocalDataKey<T>, data: @T) {

let map = get_local_map(handle);
Expand Down Expand Up @@ -225,7 +225,7 @@ pub unsafe fn local_set<T:Durable>(
}
}

pub unsafe fn local_modify<T:Durable>(
pub unsafe fn local_modify<T: 'static>(
handle: Handle, key: LocalDataKey<T>,
modify_fn: &fn(Option<@T>) -> Option<@T>) {

Expand Down
164 changes: 79 additions & 85 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,56 +34,55 @@ pub enum LangItem {
ConstTraitLangItem, // 0
CopyTraitLangItem, // 1
OwnedTraitLangItem, // 2
DurableTraitLangItem, // 3

DropTraitLangItem, // 4

AddTraitLangItem, // 5
SubTraitLangItem, // 6
MulTraitLangItem, // 7
DivTraitLangItem, // 8
RemTraitLangItem, // 9
NegTraitLangItem, // 10
NotTraitLangItem, // 11
BitXorTraitLangItem, // 12
BitAndTraitLangItem, // 13
BitOrTraitLangItem, // 14
ShlTraitLangItem, // 15
ShrTraitLangItem, // 16
IndexTraitLangItem, // 17

EqTraitLangItem, // 18
OrdTraitLangItem, // 19

StrEqFnLangItem, // 20
UniqStrEqFnLangItem, // 21
AnnihilateFnLangItem, // 22
LogTypeFnLangItem, // 23
FailFnLangItem, // 24
FailBoundsCheckFnLangItem, // 25
ExchangeMallocFnLangItem, // 26
ExchangeFreeFnLangItem, // 27
MallocFnLangItem, // 28
FreeFnLangItem, // 29
BorrowAsImmFnLangItem, // 30
BorrowAsMutFnLangItem, // 31
ReturnToMutFnLangItem, // 32
CheckNotBorrowedFnLangItem, // 33
StrDupUniqFnLangItem, // 34
RecordBorrowFnLangItem, // 35
UnrecordBorrowFnLangItem, // 36

StartFnLangItem, // 37

DropTraitLangItem, // 3

AddTraitLangItem, // 4
SubTraitLangItem, // 5
MulTraitLangItem, // 6
DivTraitLangItem, // 7
RemTraitLangItem, // 8
NegTraitLangItem, // 9
NotTraitLangItem, // 10
BitXorTraitLangItem, // 11
BitAndTraitLangItem, // 12
BitOrTraitLangItem, // 13
ShlTraitLangItem, // 14
ShrTraitLangItem, // 15
IndexTraitLangItem, // 16

EqTraitLangItem, // 17
OrdTraitLangItem, // 18

StrEqFnLangItem, // 19
UniqStrEqFnLangItem, // 20
AnnihilateFnLangItem, // 21
LogTypeFnLangItem, // 22
FailFnLangItem, // 23
FailBoundsCheckFnLangItem, // 24
ExchangeMallocFnLangItem, // 25
ExchangeFreeFnLangItem, // 26
MallocFnLangItem, // 27
FreeFnLangItem, // 28
BorrowAsImmFnLangItem, // 29
BorrowAsMutFnLangItem, // 30
ReturnToMutFnLangItem, // 31
CheckNotBorrowedFnLangItem, // 32
StrDupUniqFnLangItem, // 33
RecordBorrowFnLangItem, // 34
UnrecordBorrowFnLangItem, // 35

StartFnLangItem, // 36
}

pub struct LanguageItems {
items: [Option<def_id>, ..38]
items: [Option<def_id>, ..37]
}

pub impl LanguageItems {
pub fn new() -> LanguageItems {
LanguageItems {
items: [ None, ..38 ]
items: [ None, ..37 ]
}
}

Expand All @@ -100,45 +99,44 @@ pub impl LanguageItems {
0 => "const",
1 => "copy",
2 => "owned",
3 => "durable",

4 => "drop",

5 => "add",
6 => "sub",
7 => "mul",
8 => "div",
9 => "rem",
10 => "neg",
11 => "not",
12 => "bitxor",
13 => "bitand",
14 => "bitor",
15 => "shl",
16 => "shr",
17 => "index",
18 => "eq",
19 => "ord",

20 => "str_eq",
21 => "uniq_str_eq",
22 => "annihilate",
23 => "log_type",
24 => "fail_",
25 => "fail_bounds_check",
26 => "exchange_malloc",
27 => "exchange_free",
28 => "malloc",
29 => "free",
30 => "borrow_as_imm",
31 => "borrow_as_mut",
32 => "return_to_mut",
33 => "check_not_borrowed",
34 => "strdup_uniq",
35 => "record_borrow",
36 => "unrecord_borrow",

37 => "start",

3 => "drop",

4 => "add",
5 => "sub",
6 => "mul",
7 => "div",
8 => "rem",
9 => "neg",
10 => "not",
11 => "bitxor",
12 => "bitand",
13 => "bitor",
14 => "shl",
15 => "shr",
16 => "index",
17 => "eq",
18 => "ord",

19 => "str_eq",
20 => "uniq_str_eq",
21 => "annihilate",
22 => "log_type",
23 => "fail_",
24 => "fail_bounds_check",
25 => "exchange_malloc",
26 => "exchange_free",
27 => "malloc",
28 => "free",
29 => "borrow_as_imm",
30 => "borrow_as_mut",
31 => "return_to_mut",
32 => "check_not_borrowed",
33 => "strdup_uniq",
34 => "record_borrow",
35 => "unrecord_borrow",

36 => "start",

_ => "???"
}
Expand All @@ -155,9 +153,6 @@ pub impl LanguageItems {
pub fn owned_trait(&const self) -> def_id {
self.items[OwnedTraitLangItem as uint].get()
}
pub fn durable_trait(&const self) -> def_id {
self.items[DurableTraitLangItem as uint].get()
}

pub fn drop_trait(&const self) -> def_id {
self.items[DropTraitLangItem as uint].get()
Expand Down Expand Up @@ -274,7 +269,6 @@ fn LanguageItemCollector(crate: @crate,
item_refs.insert(@~"const", ConstTraitLangItem as uint);
item_refs.insert(@~"copy", CopyTraitLangItem as uint);
item_refs.insert(@~"owned", OwnedTraitLangItem as uint);
item_refs.insert(@~"durable", DurableTraitLangItem as uint);

item_refs.insert(@~"drop", DropTraitLangItem as uint);

Expand Down
Loading