Skip to content

Commit 148736b

Browse files
brsonalexcrichton
authored andcommitted
---
yaml --- r: 127003 b: refs/heads/snap-stage3 c: 4db68e6 h: refs/heads/master i: 127001: 397802c 126999: 73a05a8 v: v3
1 parent 86a4f4b commit 148736b

File tree

4 files changed

+41
-17
lines changed

4 files changed

+41
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 7be8f0af0393dcdb077c2f6b1653836fd3fba235
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 134946d06e6926e087a792ac13c7f4421591afed
4+
refs/heads/snap-stage3: 4db68e644e2e7bef55ed536ac77f87292260527c
55
refs/heads/try: 502e4c045236682e9728539dc0d2b3d0b237f55c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/failure.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use fmt;
3434
use intrinsics;
3535

36+
#[cfg(stage0)]
3637
#[cold] #[inline(never)] // this is the slow path, always
3738
#[lang="fail_"]
3839
fn fail_(expr: &'static str, file: &'static str, line: uint) -> ! {
@@ -43,6 +44,7 @@ fn fail_(expr: &'static str, file: &'static str, line: uint) -> ! {
4344
unsafe { intrinsics::abort() }
4445
}
4546

47+
#[cfg(stage0)]
4648
#[cold]
4749
#[lang="fail_bounds_check"]
4850
fn fail_bounds_check(file: &'static str, line: uint,
@@ -53,6 +55,30 @@ fn fail_bounds_check(file: &'static str, line: uint,
5355
unsafe { intrinsics::abort() }
5456
}
5557

58+
#[cfg(not(stage0))]
59+
#[cold] #[inline(never)] // this is the slow path, always
60+
#[lang="fail_"]
61+
fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
62+
let (expr, file, line) = *expr_file_line;
63+
let ref file_line = (file, line);
64+
format_args!(|args| -> () {
65+
begin_unwind(args, file_line);
66+
}, "{}", expr);
67+
68+
unsafe { intrinsics::abort() }
69+
}
70+
71+
#[cfg(not(stage0))]
72+
#[cold]
73+
#[lang="fail_bounds_check"]
74+
fn fail_bounds_check(file_line: &(&'static str, uint),
75+
index: uint, len: uint) -> ! {
76+
format_args!(|args| -> () {
77+
begin_unwind(args, file_line);
78+
}, "index out of bounds: the len is {} but the index is {}", len, index);
79+
unsafe { intrinsics::abort() }
80+
}
81+
5682
#[cold]
5783
pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
5884
#[allow(ctypes)]

branches/snap-stage3/src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn const_vec(cx: &CrateContext, e: &ast::Expr,
109109
(v, llunitty, inlineable.iter().fold(true, |a, &b| a && b))
110110
}
111111

112-
fn const_addr_of(cx: &CrateContext, cv: ValueRef) -> ValueRef {
112+
pub fn const_addr_of(cx: &CrateContext, cv: ValueRef) -> ValueRef {
113113
unsafe {
114114
let gv = "const".with_c_str(|name| {
115115
llvm::LLVMAddGlobal(cx.llmod, val_ty(cv).to_ref(), name)

branches/snap-stage3/src/librustc/middle/trans/controlflow.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use middle::trans::callee;
2020
use middle::trans::cleanup::CleanupMethods;
2121
use middle::trans::cleanup;
2222
use middle::trans::common::*;
23+
use middle::trans::consts;
2324
use middle::trans::datum;
2425
use middle::trans::debuginfo;
2526
use middle::trans::expr;
@@ -477,14 +478,6 @@ pub fn trans_ret<'a>(bcx: &'a Block<'a>,
477478
return bcx;
478479
}
479480

480-
fn str_slice_arg<'a>(bcx: &'a Block<'a>, s: InternedString) -> ValueRef {
481-
let ccx = bcx.ccx();
482-
let s = C_str_slice(ccx, s);
483-
let slot = alloca(bcx, val_ty(s), "__temp");
484-
Store(bcx, s, slot);
485-
slot
486-
}
487-
488481
pub fn trans_fail<'a>(
489482
bcx: &'a Block<'a>,
490483
sp: Span,
@@ -493,12 +486,14 @@ pub fn trans_fail<'a>(
493486
let ccx = bcx.ccx();
494487
let _icx = push_ctxt("trans_fail_value");
495488

496-
let v_str = str_slice_arg(bcx, fail_str);
489+
let v_str = C_str_slice(ccx, fail_str);
497490
let loc = bcx.sess().codemap().lookup_char_pos(sp.lo);
498491
let filename = token::intern_and_get_ident(loc.file.name.as_slice());
499-
let v_filename = str_slice_arg(bcx, filename);
500-
let v_line = loc.line as int;
501-
let args = vec!(v_str, v_filename, C_int(ccx, v_line));
492+
let filename = C_str_slice(ccx, filename);
493+
let line = C_int(ccx, loc.line as int);
494+
let expr_file_line_const = C_struct(ccx, &[v_str, filename, line], false);
495+
let expr_file_line = consts::const_addr_of(ccx, expr_file_line_const);
496+
let args = vec!(expr_file_line);
502497
let did = langcall(bcx, Some(sp), "", FailFnLangItem);
503498
let bcx = callee::trans_lang_call(bcx,
504499
did,
@@ -514,16 +509,19 @@ pub fn trans_fail_bounds_check<'a>(
514509
index: ValueRef,
515510
len: ValueRef)
516511
-> &'a Block<'a> {
512+
let ccx = bcx.ccx();
517513
let _icx = push_ctxt("trans_fail_bounds_check");
518514

519515
// Extract the file/line from the span
520516
let loc = bcx.sess().codemap().lookup_char_pos(sp.lo);
521517
let filename = token::intern_and_get_ident(loc.file.name.as_slice());
522518

523519
// Invoke the lang item
524-
let filename = str_slice_arg(bcx, filename);
525-
let line = C_int(bcx.ccx(), loc.line as int);
526-
let args = vec!(filename, line, index, len);
520+
let filename = C_str_slice(ccx, filename);
521+
let line = C_int(ccx, loc.line as int);
522+
let file_line_const = C_struct(ccx, &[filename, line], false);
523+
let file_line = consts::const_addr_of(ccx, file_line_const);
524+
let args = vec!(file_line, index, len);
527525
let did = langcall(bcx, Some(sp), "", FailBoundsCheckFnLangItem);
528526
let bcx = callee::trans_lang_call(bcx,
529527
did,

0 commit comments

Comments
 (0)