Skip to content

Commit 4d978a9

Browse files
committed
---
yaml --- r: 80635 b: refs/heads/auto c: 77bbf23 h: refs/heads/master i: 80633: d188f2a 80631: b295d8d v: v3
1 parent cd3361d commit 4d978a9

File tree

31 files changed

+527
-1958
lines changed

31 files changed

+527
-1958
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: a5275ffd5c3fe22228b23f602ae4e7169df55d82
16+
refs/heads/auto: 77bbf23b4a6782b3e460c7eea339b858d98ae676
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/doc/tutorial-tasks.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ concurrency at this writing:
4747

4848
* [`std::task`] - All code relating to tasks and task scheduling,
4949
* [`std::comm`] - The message passing interface,
50-
* [`extra::comm`] - Additional messaging types based on `std::comm`,
50+
* [`std::pipes`] - The underlying messaging infrastructure,
51+
* [`extra::comm`] - Additional messaging types based on `std::pipes`,
5152
* [`extra::sync`] - More exotic synchronization tools, including locks,
5253
* [`extra::arc`] - The Arc (atomically reference counted) type,
5354
for safely sharing immutable data,
5455
* [`extra::future`] - A type representing values that may be computed concurrently and retrieved at a later time.
5556

5657
[`std::task`]: std/task.html
5758
[`std::comm`]: std/comm.html
59+
[`std::pipes`]: std/pipes.html
5860
[`extra::comm`]: extra/comm.html
5961
[`extra::sync`]: extra/sync.html
6062
[`extra::arc`]: extra/arc.html
@@ -123,7 +125,7 @@ receiving messages. Pipes are low-level communication building-blocks and so
123125
come in a variety of forms, each one appropriate for a different use case. In
124126
what follows, we cover the most commonly used varieties.
125127

126-
The simplest way to create a pipe is to use the `comm::stream`
128+
The simplest way to create a pipe is to use the `pipes::stream`
127129
function to create a `(Port, Chan)` pair. In Rust parlance, a *channel*
128130
is a sending endpoint of a pipe, and a *port* is the receiving
129131
endpoint. Consider the following example of calculating two results

branches/auto/src/libextra/json.rs

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,18 @@ impl serialize::Encoder for Encoder {
135135
_id: uint,
136136
cnt: uint,
137137
f: &fn(&mut Encoder)) {
138-
// enums are encoded as strings or objects
138+
// enums are encoded as strings or vectors:
139139
// Bunny => "Bunny"
140-
// Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
140+
// Kangaroo(34,"William") => ["Kangaroo",[34,"William"]]
141+
141142
if cnt == 0 {
142143
self.wr.write_str(escape_str(name));
143144
} else {
144-
self.wr.write_char('{');
145-
self.wr.write_str("\"variant\"");
146-
self.wr.write_char(':');
145+
self.wr.write_char('[');
147146
self.wr.write_str(escape_str(name));
148147
self.wr.write_char(',');
149-
self.wr.write_str("\"fields\"");
150-
self.wr.write_str(":[");
151148
f(self);
152-
self.wr.write_str("]}");
149+
self.wr.write_char(']');
153150
}
154151
}
155152

@@ -950,20 +947,14 @@ impl serialize::Decoder for Decoder {
950947
debug!("read_enum_variant(names=%?)", names);
951948
let name = match self.stack.pop() {
952949
String(s) => s,
953-
Object(o) => {
954-
let n = match o.find(&~"variant").expect("invalidly encoded json") {
955-
&String(ref s) => s.clone(),
956-
_ => fail!("invalidly encoded json"),
957-
};
958-
match o.find(&~"fields").expect("invalidly encoded json") {
959-
&List(ref l) => {
960-
for field in l.rev_iter() {
961-
self.stack.push(field.clone());
962-
}
963-
},
964-
_ => fail!("invalidly encoded json")
950+
List(list) => {
951+
for v in list.move_rev_iter() {
952+
self.stack.push(v);
953+
}
954+
match self.stack.pop() {
955+
String(s) => s,
956+
value => fail!("invalid variant name: %?", value),
965957
}
966-
n
967958
}
968959
ref json => fail!("invalid variant: %?", *json),
969960
};
@@ -1526,7 +1517,7 @@ mod tests {
15261517
let mut encoder = Encoder(wr);
15271518
animal.encode(&mut encoder);
15281519
},
1529-
~"{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}"
1520+
~"[\"Frog\",\"Henry\",349]"
15301521
);
15311522
assert_eq!(
15321523
do io::with_str_writer |wr| {
@@ -1930,14 +1921,14 @@ mod tests {
19301921
assert_eq!(value, Dog);
19311922

19321923
let mut decoder =
1933-
Decoder(from_str("{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}").unwrap());
1924+
Decoder(from_str("[\"Frog\",\"Henry\",349]").unwrap());
19341925
let value: Animal = Decodable::decode(&mut decoder);
19351926
assert_eq!(value, Frog(~"Henry", 349));
19361927
}
19371928
19381929
#[test]
19391930
fn test_decode_map() {
1940-
let s = ~"{\"a\": \"Dog\", \"b\": {\"variant\":\"Frog\",\"fields\":[\"Henry\", 349]}}";
1931+
let s = ~"{\"a\": \"Dog\", \"b\": [\"Frog\", \"Henry\", 349]}";
19411932
let mut decoder = Decoder(from_str(s).unwrap());
19421933
let mut map: TreeMap<~str, Animal> = Decodable::decode(&mut decoder);
19431934

branches/auto/src/librustc/middle/trans/base.rs

Lines changed: 62 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ impl<'self> Drop for StatRecorder<'self> {
174174
}
175175
}
176176

177-
// only use this for foreign function ABIs and glue, use `decl_rust_fn` for Rust functions
178177
pub fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv, ty: Type) -> ValueRef {
179178
let llfn: ValueRef = do name.with_c_str |buf| {
180179
unsafe {
@@ -186,12 +185,18 @@ pub fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv, ty: Type)
186185
return llfn;
187186
}
188187

189-
// only use this for foreign function ABIs and glue, use `decl_rust_fn` for Rust functions
190188
pub fn decl_cdecl_fn(llmod: ModuleRef, name: &str, ty: Type) -> ValueRef {
191189
return decl_fn(llmod, name, lib::llvm::CCallConv, ty);
192190
}
193191

194-
// only use this for foreign function ABIs and glue, use `get_extern_rust_fn` for Rust functions
192+
// Only use this if you are going to actually define the function. It's
193+
// not valid to simply declare a function as internal.
194+
pub fn decl_internal_cdecl_fn(llmod: ModuleRef, name: &str, ty: Type) -> ValueRef {
195+
let llfn = decl_cdecl_fn(llmod, name, ty);
196+
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
197+
return llfn;
198+
}
199+
195200
pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str,
196201
cc: lib::llvm::CallConv, ty: Type) -> ValueRef {
197202
match externs.find_equiv(&name) {
@@ -200,73 +205,7 @@ pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str,
200205
}
201206
let f = decl_fn(llmod, name, cc, ty);
202207
externs.insert(name.to_owned(), f);
203-
f
204-
}
205-
206-
pub fn get_extern_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
207-
name: &str) -> ValueRef {
208-
match ccx.externs.find_equiv(&name) {
209-
Some(n) => return *n,
210-
None => ()
211-
}
212-
let f = decl_rust_fn(ccx, inputs, output, name);
213-
ccx.externs.insert(name.to_owned(), f);
214-
f
215-
}
216-
217-
pub fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
218-
name: &str) -> ValueRef {
219-
let llfty = type_of_rust_fn(ccx, inputs, output);
220-
let llfn = decl_cdecl_fn(ccx.llmod, name, llfty);
221-
222-
match ty::get(output).sty {
223-
// `~` pointer return values never alias because ownership is transferred
224-
ty::ty_uniq(*) |
225-
ty::ty_evec(_, ty::vstore_uniq) => {
226-
unsafe {
227-
llvm::LLVMAddReturnAttribute(llfn, lib::llvm::NoAliasAttribute as c_uint);
228-
}
229-
}
230-
_ => ()
231-
}
232-
233-
let uses_outptr = type_of::return_uses_outptr(ccx.tcx, output);
234-
let offset = if uses_outptr { 2 } else { 1 };
235-
236-
for (i, &arg_ty) in inputs.iter().enumerate() {
237-
let llarg = unsafe { llvm::LLVMGetParam(llfn, (offset + i) as c_uint) };
238-
match ty::get(arg_ty).sty {
239-
// `~` pointer parameters never alias because ownership is transferred
240-
ty::ty_uniq(*) |
241-
ty::ty_evec(_, ty::vstore_uniq) |
242-
ty::ty_closure(ty::ClosureTy {sigil: ast::OwnedSigil, _}) => {
243-
unsafe {
244-
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
245-
}
246-
}
247-
_ => ()
248-
}
249-
}
250-
251-
// The out pointer will never alias with any other pointers, as the object only exists at a
252-
// language level after the call. It can also be tagged with SRet to indicate that it is
253-
// guaranteed to point to a usable block of memory for the type.
254-
if uses_outptr {
255-
unsafe {
256-
let outptr = llvm::LLVMGetParam(llfn, 0);
257-
llvm::LLVMAddAttribute(outptr, lib::llvm::StructRetAttribute as c_uint);
258-
llvm::LLVMAddAttribute(outptr, lib::llvm::NoAliasAttribute as c_uint);
259-
}
260-
}
261-
262-
llfn
263-
}
264-
265-
pub fn decl_internal_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
266-
name: &str) -> ValueRef {
267-
let llfn = decl_rust_fn(ccx, inputs, output, name);
268-
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
269-
llfn
208+
return f;
270209
}
271210

272211
pub fn get_extern_const(externs: &mut ExternMap, llmod: ModuleRef,
@@ -870,30 +809,33 @@ pub fn null_env_ptr(ccx: &CrateContext) -> ValueRef {
870809
C_null(Type::opaque_box(ccx).ptr_to())
871810
}
872811
873-
pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) -> ValueRef {
812+
pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t)
813+
-> ValueRef {
874814
let name = csearch::get_symbol(ccx.sess.cstore, did);
875815
match ty::get(t).sty {
876816
ty::ty_bare_fn(ref fn_ty) => {
877-
match fn_ty.abis.for_arch(ccx.sess.targ_cfg.arch) {
878-
Some(Rust) | Some(RustIntrinsic) => {
879-
get_extern_rust_fn(ccx, fn_ty.sig.inputs, fn_ty.sig.output, name)
880-
}
817+
// Currently llvm_calling_convention triggers unimpl/bug on
818+
// Rust/RustIntrinsic, so those two are handled specially here.
819+
let cconv = match fn_ty.abis.for_arch(ccx.sess.targ_cfg.arch) {
820+
Some(Rust) | Some(RustIntrinsic) => lib::llvm::CCallConv,
881821
Some(*) | None => {
882822
let c = foreign::llvm_calling_convention(ccx, fn_ty.abis);
883-
let cconv = c.unwrap_or(lib::llvm::CCallConv);
884-
let llty = type_of_fn_from_ty(ccx, t);
885-
get_extern_fn(&mut ccx.externs, ccx.llmod, name, cconv, llty)
823+
c.unwrap_or(lib::llvm::CCallConv)
886824
}
887-
}
825+
};
826+
let llty = type_of_fn_from_ty(ccx, t);
827+
return get_extern_fn(&mut ccx.externs, ccx.llmod, name, cconv, llty);
888828
}
889-
ty::ty_closure(ref f) => {
890-
get_extern_rust_fn(ccx, f.sig.inputs, f.sig.output, name)
829+
ty::ty_closure(_) => {
830+
let llty = type_of_fn_from_ty(ccx, t);
831+
return get_extern_fn(&mut ccx.externs, ccx.llmod, name,
832+
lib::llvm::CCallConv, llty);
891833
}
892834
_ => {
893835
let llty = type_of(ccx, t);
894-
get_extern_const(&mut ccx.externs, ccx.llmod, name, llty)
836+
return get_extern_const(&mut ccx.externs, ccx.llmod, name, llty);
895837
}
896-
}
838+
};
897839
}
898840
899841
pub fn invoke(bcx: @mut Block, llfn: ValueRef, llargs: ~[ValueRef],
@@ -926,8 +868,7 @@ pub fn invoke(bcx: @mut Block, llfn: ValueRef, llargs: ~[ValueRef],
926868
llfn,
927869
llargs,
928870
normal_bcx.llbb,
929-
get_landing_pad(bcx),
930-
attributes);
871+
get_landing_pad(bcx));
931872
return (llresult, normal_bcx);
932873
} else {
933874
unsafe {
@@ -1766,7 +1707,8 @@ pub fn new_fn_ctxt(ccx: @mut CrateContext,
17661707
// field of the fn_ctxt with
17671708
pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
17681709
self_arg: self_arg,
1769-
args: &[ast::arg])
1710+
args: &[ast::arg],
1711+
arg_tys: &[ty::t])
17701712
-> ~[ValueRef] {
17711713
let _icx = push_ctxt("create_llargs_for_fn_args");
17721714

@@ -1784,7 +1726,23 @@ pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
17841726
// Return an array containing the ValueRefs that we get from
17851727
// llvm::LLVMGetParam for each argument.
17861728
do vec::from_fn(args.len()) |i| {
1787-
unsafe { llvm::LLVMGetParam(cx.llfn, cx.arg_pos(i) as c_uint) }
1729+
let arg_n = cx.arg_pos(i);
1730+
let arg_ty = arg_tys[i];
1731+
let llarg = unsafe {llvm::LLVMGetParam(cx.llfn, arg_n as c_uint) };
1732+
1733+
match ty::get(arg_ty).sty {
1734+
// `~` pointer parameters never alias because ownership is transferred
1735+
ty::ty_uniq(*) |
1736+
ty::ty_evec(_, ty::vstore_uniq) |
1737+
ty::ty_closure(ty::ClosureTy {sigil: ast::OwnedSigil, _}) => {
1738+
unsafe {
1739+
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
1740+
}
1741+
}
1742+
_ => ()
1743+
}
1744+
1745+
llarg
17881746
}
17891747
}
17901748

@@ -1938,7 +1896,8 @@ pub fn trans_closure(ccx: @mut CrateContext,
19381896

19391897
// Set up arguments to the function.
19401898
let arg_tys = ty::ty_fn_args(node_id_type(bcx, id));
1941-
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg, decl.inputs);
1899+
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg,
1900+
decl.inputs, arg_tys);
19421901

19431902
// Set the fixed stack segment flag if necessary.
19441903
if attr::contains_name(attributes, "fixed_stack_segment") {
@@ -2002,6 +1961,18 @@ pub fn trans_fn(ccx: @mut CrateContext,
20021961
param_substs.repr(ccx.tcx));
20031962
let _icx = push_ctxt("trans_fn");
20041963
let output_type = ty::ty_fn_ret(ty::node_id_to_type(ccx.tcx, id));
1964+
1965+
match ty::get(output_type).sty {
1966+
// `~` pointer return values never alias because ownership is transferred
1967+
ty::ty_uniq(*) |
1968+
ty::ty_evec(_, ty::vstore_uniq) => {
1969+
unsafe {
1970+
llvm::LLVMAddReturnAttribute(llfndecl, lib::llvm::NoAliasAttribute as c_uint);
1971+
}
1972+
}
1973+
_ => ()
1974+
}
1975+
20051976
trans_closure(ccx,
20061977
path.clone(),
20071978
decl,
@@ -2149,7 +2120,7 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
21492120

21502121
let arg_tys = ty::ty_fn_args(ctor_ty);
21512122

2152-
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args);
2123+
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args, arg_tys);
21532124

21542125
let bcx = fcx.entry_bcx.unwrap();
21552126

@@ -2327,28 +2298,10 @@ pub fn register_fn(ccx: @mut CrateContext,
23272298
node_id: ast::NodeId,
23282299
node_type: ty::t)
23292300
-> ValueRef {
2330-
let f = match ty::get(node_type).sty {
2331-
ty::ty_bare_fn(ref f) => {
2332-
assert!(f.abis.is_rust() || f.abis.is_intrinsic());
2333-
f
2334-
}
2335-
_ => fail!("expected bare rust fn or an intrinsic")
2336-
};
2337-
2338-
let llfn = decl_rust_fn(ccx, f.sig.inputs, f.sig.output, sym);
2339-
ccx.item_symbols.insert(node_id, sym);
2340-
2341-
// FIXME #4404 android JNI hacks
2342-
let is_entry = is_entry_fn(&ccx.sess, node_id) && (!*ccx.sess.building_library ||
2343-
(*ccx.sess.building_library &&
2344-
ccx.sess.targ_cfg.os == session::OsAndroid));
2345-
if is_entry {
2346-
create_entry_wrapper(ccx, sp, llfn);
2347-
}
2348-
llfn
2301+
let llfty = type_of_fn_from_ty(ccx, node_type);
2302+
register_fn_llvmty(ccx, sp, sym, node_id, lib::llvm::CCallConv, llfty)
23492303
}
23502304

2351-
// only use this for foreign function ABIs and glue, use `register_fn` for Rust functions
23522305
pub fn register_fn_llvmty(ccx: @mut CrateContext,
23532306
sp: Span,
23542307
sym: ~str,

0 commit comments

Comments
 (0)