Skip to content

Commit a3f48d3

Browse files
committed
Merge branch 'master' of github.com:graydon/rust
2 parents 1652b92 + 6c95e40 commit a3f48d3

25 files changed

+509
-152
lines changed

Makefile.in

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,24 @@ $(foreach build,$(CFG_TARGET_TRIPLES), \
353353
# Builds a functional Rustc for the given host.
354354
######################################################################
355355

356-
define DEF_RUSTC_TARGET
356+
define DEF_RUSTC_STAGE_TARGET
357357
# $(1) == architecture
358+
# $(2) == stage
358359

359-
rustc-H-$(1): \
360+
rustc-stage$(2)-H-$(1): \
360361
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
361-
$$(SREQ3_T_$$(target)_H_$(1)))
362+
$$(SREQ$(2)_T_$$(target)_H_$(1)))
363+
364+
endef
365+
366+
$(foreach host,$(CFG_TARGET_TRIPLES), \
367+
$(eval $(foreach stage,1 2 3, \
368+
$(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
369+
370+
define DEF_RUSTC_TARGET
371+
# $(1) == architecture
372+
373+
rustc-H-$(1): rustc-stage3-H-$(1)
362374
endef
363375

364376
$(foreach host,$(CFG_TARGET_TRIPLES), \

src/comp/back/upcall.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ type upcalls =
2727
dynastack_free: ValueRef,
2828
alloc_c_stack: ValueRef,
2929
call_shim_on_c_stack: ValueRef,
30-
rust_personality: ValueRef};
30+
rust_personality: ValueRef,
31+
reset_stack_limit: ValueRef};
3132

3233
fn declare_upcalls(targ_cfg: @session::config,
3334
_tn: type_names,
@@ -89,7 +90,8 @@ fn declare_upcalls(targ_cfg: @session::config,
8990
// arguments: void *args, void *fn_ptr
9091
[T_ptr(T_i8()), T_ptr(T_i8())],
9192
int_t),
92-
rust_personality: d("rust_personality", [], T_i32())
93+
rust_personality: d("rust_personality", [], T_i32()),
94+
reset_stack_limit: dv("reset_stack_limit", [])
9395
};
9496
}
9597
//

src/comp/middle/mut.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ fn visit_decl(cx: @ctx, d: @decl, &&e: (), v: visit::vt<()>) {
150150
fn visit_expr(cx: @ctx, ex: @expr, &&e: (), v: visit::vt<()>) {
151151
alt ex.node {
152152
expr_call(f, args, _) { check_call(cx, f, args); }
153+
expr_bind(f, args) { check_bind(cx, f, args); }
153154
expr_swap(lhs, rhs) {
154155
check_lval(cx, lhs, msg_assign);
155156
check_lval(cx, rhs, msg_assign);
@@ -230,6 +231,30 @@ fn check_call(cx: @ctx, f: @expr, args: [@expr]) {
230231
}
231232
}
232233

234+
fn check_bind(cx: @ctx, f: @expr, args: [option::t<@expr>]) {
235+
let arg_ts = ty::ty_fn_args(cx.tcx, ty::expr_ty(cx.tcx, f));
236+
let i = 0u;
237+
for arg in args {
238+
alt arg {
239+
some(expr) {
240+
alt (alt arg_ts[i].mode {
241+
by_mut_ref. { some("by mutable reference") }
242+
by_move. { some("by move") }
243+
_ { none }
244+
}) {
245+
some(name) {
246+
cx.tcx.sess.span_err(
247+
expr.span, "can not bind an argument passed " + name);
248+
}
249+
none. {}
250+
}
251+
}
252+
_ {}
253+
}
254+
i += 1u;
255+
}
256+
}
257+
233258
fn is_immutable_def(def: def) -> option::t<str> {
234259
alt def {
235260
def_fn(_, _) | def_mod(_) | def_native_mod(_) | def_const(_) |

src/comp/middle/trans.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3462,6 +3462,12 @@ fn trans_bind_thunk(cx: @local_ctxt, sp: span, incoming_fty: ty::t,
34623462
bcx = bound_arg.bcx;
34633463
let val = bound_arg.val;
34643464
if out_arg.mode == ast::by_val { val = Load(bcx, val); }
3465+
if out_arg.mode == ast::by_copy {
3466+
let {bcx: cx, val: alloc} = alloc_ty(bcx, out_arg.ty);
3467+
bcx = memmove_ty(cx, alloc, val, out_arg.ty);
3468+
bcx = take_ty(bcx, alloc, out_arg.ty);
3469+
val = alloc;
3470+
}
34653471
// If the type is parameterized, then we need to cast the
34663472
// type we actually have to the parameterized out type.
34673473
if ty::type_contains_params(cx.ccx.tcx, out_arg.ty) {
@@ -3904,6 +3910,11 @@ fn trans_landing_pad(bcx: @block_ctxt,
39043910
// The landing pad block is a cleanup
39053911
SetCleanup(bcx, llpad);
39063912

3913+
// Because we may have unwound across a stack boundary, we must call into
3914+
// the runtime to figure out which stack segment we are on and place the
3915+
// stack limit back into the TLS.
3916+
Call(bcx, bcx_ccx(bcx).upcalls.reset_stack_limit, []);
3917+
39073918
// FIXME: This seems like a very naive and redundant way to generate the
39083919
// landing pads, as we're re-generating all in-scope cleanups for each
39093920
// function call. Probably good optimization opportunities here.
@@ -4531,7 +4542,9 @@ fn zero_alloca(cx: @block_ctxt, llptr: ValueRef, t: ty::t)
45314542
fn trans_stmt(cx: @block_ctxt, s: ast::stmt) -> @block_ctxt {
45324543
// FIXME Fill in cx.sp
45334544

4534-
add_span_comment(cx, s.span, stmt_to_str(s));
4545+
if (!bcx_ccx(cx).sess.get_opts().no_asm_comments) {
4546+
add_span_comment(cx, s.span, stmt_to_str(s));
4547+
}
45354548

45364549
let bcx = cx;
45374550
alt s.node {

src/comp/middle/trans_build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,9 @@ fn add_span_comment(bcx: @block_ctxt, sp: span, text: str) {
515515
fn add_comment(bcx: @block_ctxt, text: str) {
516516
let ccx = bcx_ccx(bcx);
517517
if (!ccx.sess.get_opts().no_asm_comments) {
518-
let comment_text = "; " + text;
518+
check str::is_not_empty("$");
519+
let sanitized = str::replace(text, "$", "");
520+
let comment_text = "; " + sanitized;
519521
let asm = str::as_buf(comment_text, { |c|
520522
str::as_buf("", { |e|
521523
llvm::LLVMConstInlineAsm(T_fn([], T_void()), c, e, 0, 0)})});

src/comp/middle/tstate/pre_post_conditions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
452452
expr_alt(ex, alts) {
453453
find_pre_post_expr(fcx, ex);
454454
fn do_an_alt(fcx: fn_ctxt, an_alt: arm) -> pre_and_post {
455+
alt an_alt.guard {
456+
some(e) { find_pre_post_expr(fcx, e); }
457+
_ {}
458+
}
455459
find_pre_post_block(fcx, an_alt.body);
456460
ret block_pp(fcx.ccx, an_alt.body);
457461
}

src/comp/middle/tstate/states.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
530530
if vec::len(alts) > 0u {
531531
a_post = false_postcond(num_constrs);
532532
for an_alt: arm in alts {
533+
alt an_alt.guard {
534+
some(e) {
535+
changed |= find_pre_post_state_expr(fcx, e_post, e);
536+
}
537+
_ {}
538+
}
533539
changed |=
534540
find_pre_post_state_block(fcx, e_post, an_alt.body);
535541
intersect(a_post, block_poststate(fcx.ccx, an_alt.body));

src/comp/middle/ty.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,23 +1299,23 @@ fn type_autoderef(cx: ctxt, t: ty::t) -> ty::t {
12991299
fn hash_type_structure(st: sty) -> uint {
13001300
fn hash_uint(id: uint, n: uint) -> uint {
13011301
let h = id;
1302-
h += h << 5u + n;
1302+
h += (h << 5u) + n;
13031303
ret h;
13041304
}
13051305
fn hash_def(id: uint, did: ast::def_id) -> uint {
13061306
let h = id;
1307-
h += h << 5u + (did.crate as uint);
1308-
h += h << 5u + (did.node as uint);
1307+
h += (h << 5u) + (did.crate as uint);
1308+
h += (h << 5u) + (did.node as uint);
13091309
ret h;
13101310
}
13111311
fn hash_subty(id: uint, subty: t) -> uint {
13121312
let h = id;
1313-
h += h << 5u + hash_ty(subty);
1313+
h += (h << 5u) + hash_ty(subty);
13141314
ret h;
13151315
}
13161316
fn hash_type_constr(id: uint, c: @type_constr) -> uint {
13171317
let h = id;
1318-
h += h << 5u + hash_def(h, c.node.id);
1318+
h += (h << 5u) + hash_def(h, c.node.id);
13191319
ret hash_type_constr_args(h, c.node.args);
13201320
}
13211321
fn hash_type_constr_args(id: uint, args: [@ty_constr_arg]) -> uint {
@@ -1338,8 +1338,8 @@ fn hash_type_structure(st: sty) -> uint {
13381338

13391339
fn hash_fn(id: uint, args: [arg], rty: t) -> uint {
13401340
let h = id;
1341-
for a: arg in args { h += h << 5u + hash_ty(a.ty); }
1342-
h += h << 5u + hash_ty(rty);
1341+
for a: arg in args { h += (h << 5u) + hash_ty(a.ty); }
1342+
h += (h << 5u) + hash_ty(rty);
13431343
ret h;
13441344
}
13451345
alt st {
@@ -1366,19 +1366,19 @@ fn hash_type_structure(st: sty) -> uint {
13661366
ty_str. { ret 17u; }
13671367
ty_tag(did, tys) {
13681368
let h = hash_def(18u, did);
1369-
for typ: t in tys { h += h << 5u + hash_ty(typ); }
1369+
for typ: t in tys { h += (h << 5u) + hash_ty(typ); }
13701370
ret h;
13711371
}
13721372
ty_box(mt) { ret hash_subty(19u, mt.ty); }
13731373
ty_vec(mt) { ret hash_subty(21u, mt.ty); }
13741374
ty_rec(fields) {
13751375
let h = 26u;
1376-
for f: field in fields { h += h << 5u + hash_ty(f.mt.ty); }
1376+
for f: field in fields { h += (h << 5u) + hash_ty(f.mt.ty); }
13771377
ret h;
13781378
}
13791379
ty_tup(ts) {
13801380
let h = 25u;
1381-
for tt in ts { h += h << 5u + hash_ty(tt); }
1381+
for tt in ts { h += (h << 5u) + hash_ty(tt); }
13821382
ret h;
13831383
}
13841384

@@ -1389,7 +1389,7 @@ fn hash_type_structure(st: sty) -> uint {
13891389
ty_native_fn(args, rty) { ret hash_fn(28u, args, rty); }
13901390
ty_obj(methods) {
13911391
let h = 29u;
1392-
for m: method in methods { h += h << 5u + str::hash(m.ident); }
1392+
for m: method in methods { h += (h << 5u) + str::hash(m.ident); }
13931393
ret h;
13941394
}
13951395
ty_var(v) { ret hash_uint(30u, v as uint); }
@@ -1400,23 +1400,23 @@ fn hash_type_structure(st: sty) -> uint {
14001400
ty_ptr(mt) { ret hash_subty(35u, mt.ty); }
14011401
ty_res(did, sub, tps) {
14021402
let h = hash_subty(hash_def(18u, did), sub);
1403-
for tp: t in tps { h += h << 5u + hash_ty(tp); }
1403+
for tp: t in tps { h += (h << 5u) + hash_ty(tp); }
14041404
ret h;
14051405
}
14061406
ty_constr(t, cs) {
14071407
let h = 36u;
1408-
for c: @type_constr in cs { h += h << 5u + hash_type_constr(h, c); }
1408+
for c: @type_constr in cs { h += (h << 5u) + hash_type_constr(h, c); }
14091409
ret h;
14101410
}
1411-
ty_uniq(mt) { let h = 37u; h += h << 5u + hash_ty(mt.ty); ret h; }
1411+
ty_uniq(mt) { let h = 37u; h += (h << 5u) + hash_ty(mt.ty); ret h; }
14121412
}
14131413
}
14141414

14151415
fn hash_type_info(st: sty, cname_opt: option::t<str>) -> uint {
14161416
let h = hash_type_structure(st);
14171417
alt cname_opt {
14181418
none. {/* no-op */ }
1419-
some(s) { h += h << 5u + str::hash(s); }
1419+
some(s) { h += (h << 5u) + str::hash(s); }
14201420
}
14211421
ret h;
14221422
}

src/comp/syntax/ast_util.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,13 @@ fn is_constraint_arg(e: @expr) -> bool {
193193

194194
fn eq_ty(&&a: @ty, &&b: @ty) -> bool { ret std::box::ptr_eq(a, b); }
195195

196-
fn hash_ty(&&t: @ty) -> uint { ret t.span.lo << 16u + t.span.hi; }
196+
fn hash_ty(&&t: @ty) -> uint {
197+
let res = (t.span.lo << 16u) + t.span.hi;
198+
ret res;
199+
}
197200

198201
fn hash_def_id(&&id: def_id) -> uint {
199-
id.crate as uint << 16u + (id.node as uint)
202+
(id.crate as uint << 16u) + (id.node as uint)
200203
}
201204

202205
fn eq_def_id(&&a: def_id, &&b: def_id) -> bool {

src/etc/gen-intrinsics

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ do
1717
-Isrc/rt/arch/$ARCH -fno-stack-protector \
1818
-o src/rt/intrinsics/intrinsics.$ARCH.ll.in \
1919
src/rt/intrinsics/intrinsics.cpp
20-
sed -i \
20+
sed -i .orig \
2121
-e 's/^target datalayout =/; target datalayout =/' \
2222
src/rt/intrinsics/intrinsics.$ARCH.ll.in
23-
sed -i \
23+
sed -i .orig \
2424
-e 's/^target triple = "[^"]*"/target triple = "@CFG_TARGET_TRIPLE@"/' \
2525
src/rt/intrinsics/intrinsics.$ARCH.ll.in
26-
done
26+
rm src/rt/intrinsics/intrinsics.$ARCH.ll.in.orig
27+
done

src/libstd/map.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,25 @@ fn mk_hashmap<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>)
137137
// is always a power of 2), so that all buckets are probed for a
138138
// fixed key.
139139

140-
fn hashl(n: uint, _nbkts: uint) -> uint { ret (n >>> 16u) * 2u + 1u; }
141-
fn hashr(n: uint, _nbkts: uint) -> uint { ret 0x0000_ffff_u & n; }
142-
fn hash(h: uint, nbkts: uint, i: uint) -> uint {
143-
ret (hashl(h, nbkts) * i + hashr(h, nbkts)) % nbkts;
140+
fn hashl(n: u32) -> u32 { ret (n >>> 16u32) * 2u32 + 1u32; }
141+
fn hashr(n: u32) -> u32 { ret 0x0000_ffff_u32 & n; }
142+
fn hash(h: u32, nbkts: uint, i: uint) -> uint {
143+
ret ((hashl(h) as uint) * i + (hashr(h) as uint)) % nbkts;
144144
}
145+
146+
fn to_u64(h: uint) -> u32 {
147+
ret (h as u32) ^ ((h >>> 16u) as u32);
148+
}
149+
145150
/**
146151
* We attempt to never call this with a full table. If we do, it
147152
* will fail.
148153
*/
149-
150154
fn insert_common<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>,
151155
bkts: [mutable bucket<K, V>],
152156
nbkts: uint, key: K, val: V) -> bool {
153157
let i: uint = 0u;
154-
let h: uint = hasher(key);
158+
let h = to_u64(hasher(key));
155159
while i < nbkts {
156160
let j: uint = hash(h, nbkts, i);
157161
alt bkts[j] {
@@ -171,7 +175,7 @@ fn mk_hashmap<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>)
171175
bkts: [mutable bucket<K, V>],
172176
nbkts: uint, key: K) -> option::t<V> {
173177
let i: uint = 0u;
174-
let h: uint = hasher(key);
178+
let h = to_u64(hasher(key));
175179
while i < nbkts {
176180
let j: uint = hash(h, nbkts, i);
177181
alt bkts[j] {
@@ -244,7 +248,7 @@ fn mk_hashmap<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>)
244248
}
245249
fn remove(key: K) -> option::t<V> {
246250
let i: uint = 0u;
247-
let h: uint = hasher(key);
251+
let h = to_u64(hasher(key));
248252
while i < nbkts {
249253
let j: uint = hash(h, nbkts, i);
250254
alt bkts[j] {

src/libstd/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ fn char_range_at(s: str, i: uint) -> {ch: char, next: uint} {
324324
// Clunky way to get the right bits from the first byte. Uses two shifts,
325325
// the first to clip off the marker bits at the left of the byte, and then
326326
// a second (as uint) to get it to the right position.
327-
val += (b0 << (w + 1u as u8) as uint) << (w - 1u) * 6u - w - 1u;
327+
val += (b0 << (w + 1u as u8) as uint) << ((w - 1u) * 6u - w - 1u);
328328
ret {ch: val as char, next: i};
329329
}
330330

src/libstd/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ fn spawn_inner<send T>(-data: T, f: fn(T),
288288
notify: option<comm::chan<task_notification>>)
289289
-> task unsafe {
290290

291-
fn wrapper<send T>(-data: *u8, f: fn(T)) unsafe {
291+
fn wrapper<send T>(data: *u8, f: fn(T)) unsafe {
292292
let data: ~T = unsafe::reinterpret_cast(data);
293293
f(*data);
294294
}

src/rt/arch/i386/record_sp.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
#if defined(__APPLE__) || defined(_WIN32)
44
#define RECORD_SP _record_sp
5+
#define GET_SP _get_sp
56
#else
67
#define RECORD_SP record_sp
8+
#define GET_SP get_sp
79
#endif
810

911
.globl RECORD_SP
12+
.globl GET_SP
1013

1114
#if defined(__linux__)
1215
RECORD_SP:
@@ -25,3 +28,7 @@ RECORD_SP:
2528
ret
2629
#endif
2730
#endif
31+
32+
GET_SP:
33+
movl %esp, %eax
34+
ret

src/rt/arch/x86_64/morestack.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ MORESTACK:
132132

133133
addq $8, %rsp
134134
popq %rbp
135+
#ifdef __linux__
136+
.cfi_restore %rbp
137+
.cfi_def_cfa %rsp, 8
138+
#endif
135139
ret
136140

137141
#if defined(__ELF__)

0 commit comments

Comments
 (0)