Skip to content

Commit d04dbc7

Browse files
committed
---
yaml --- r: 16340 b: refs/heads/try c: 5f4837a h: refs/heads/master v: v3
1 parent 81f31fc commit d04dbc7

File tree

6 files changed

+95
-6
lines changed

6 files changed

+95
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 231097960c80e0968d90b5634b3f663989130bac
5+
refs/heads/try: 5f4837ad6ac5ceb7277796a817db35b137da4813
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libcore/core.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ mod extfmt;
201201
mod unicode;
202202
mod priv;
203203
mod cmath;
204-
204+
mod stackwalk;
205205

206206
// Local Variables:
207207
// mode: rust;

branches/try/src/libcore/stackwalk.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import libc::uintptr_t;
2+
3+
class frame {
4+
let fp: uintptr_t;
5+
6+
new(fp: uintptr_t) {
7+
self.fp = fp;
8+
}
9+
}
10+
11+
fn walk_stack(visit: fn(frame) -> bool) {
12+
frame_address { |frame_pointer|
13+
let frame_address = unsafe {
14+
unsafe::reinterpret_cast(frame_pointer)
15+
};
16+
visit(frame(frame_address));
17+
}
18+
}
19+
20+
#[test]
21+
fn test() {
22+
for walk_stack { |frame|
23+
#debug("frame: %x", frame.fp);
24+
// breakpoint();
25+
}
26+
}
27+
28+
fn breakpoint() {
29+
rustrt::rust_dbg_breakpoint()
30+
}
31+
32+
fn frame_address(f: fn(*u8)) {
33+
rusti::frame_address(f)
34+
}
35+
36+
native mod rustrt {
37+
fn rust_dbg_breakpoint();
38+
}
39+
40+
// FIXME: Unconditionalize after snapshot
41+
#[cfg(stage1)]
42+
#[cfg(stage2)]
43+
#[cfg(stage3)]
44+
#[abi = "rust-intrinsic"]
45+
native mod rusti {
46+
fn frame_address(f: fn(*u8));
47+
}
48+
49+
#[cfg(stage0)]
50+
mod rusti {
51+
fn frame_address(_f: fn(*u8)) {
52+
fail;
53+
}
54+
}

branches/try/src/rustc/middle/trans/native.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,27 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
875875
"frame_address" {
876876
let frameaddress = ccx.intrinsics.get("llvm.frameaddress");
877877
let frameaddress_val = Call(bcx, frameaddress, [C_i32(0i32)]);
878-
Store(bcx, frameaddress_val, fcx.llretptr);
878+
let fty = ty::mk_fn(bcx.tcx(), {
879+
purity: ast::impure_fn,
880+
proto: ast::proto_any,
881+
inputs: [{
882+
mode: ast::expl(ast::by_val),
883+
ty: ty::mk_imm_ptr(
884+
bcx.tcx(),
885+
ty::mk_mach_uint(bcx.tcx(), ast::ty_u8))
886+
}],
887+
output: ty::mk_nil(bcx.tcx()),
888+
ret_style: ast::return_val,
889+
constraints: []
890+
});
891+
bcx = trans_call_inner(bcx, none, fty, ty::mk_nil(bcx.tcx()),
892+
{ |bcx|
893+
lval_no_env(
894+
bcx,
895+
get_param(decl, first_real_arg),
896+
temporary)
897+
},
898+
arg_vals([frameaddress_val]), ignore);
879899
}
880900
}
881901
build_return(bcx);

branches/try/src/rustc/middle/typeck/check.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,20 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) {
23182318
(1u, [arg(ast::by_ref, visitor_iface)], ty::mk_nil(tcx))
23192319
}
23202320
"frame_address" {
2321-
(0u, [], ty::mk_imm_ptr(tcx, ty::mk_mach_uint(tcx, ast::ty_u8)))
2321+
let fty = ty::mk_fn(ccx.tcx, {
2322+
purity: ast::impure_fn,
2323+
proto: ast::proto_any,
2324+
inputs: [{
2325+
mode: ast::expl(ast::by_val),
2326+
ty: ty::mk_imm_ptr(
2327+
ccx.tcx,
2328+
ty::mk_mach_uint(ccx.tcx, ast::ty_u8))
2329+
}],
2330+
output: ty::mk_nil(ccx.tcx),
2331+
ret_style: ast::return_val,
2332+
constraints: []
2333+
});
2334+
(0u, [arg(ast::by_ref, fty)], ty::mk_nil(tcx))
23222335
}
23232336
other {
23242337
tcx.sess.span_err(it.span, "unrecognized intrinsic function: `" +
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#[abi = "rust-intrinsic"]
22
native mod rusti {
3-
fn frame_address() -> *u8;
3+
fn frame_address(f: fn(*u8));
44
}
55

66
fn main() {
7-
assert rusti::frame_address().is_not_null();
7+
rusti::frame_address {|addr|
8+
assert addr.is_not_null();
9+
}
810
}

0 commit comments

Comments
 (0)