Skip to content
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

Experimental JIT compiler #3292

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Add a morestack_addr (temporary) intrinsic
  • Loading branch information
brson committed Aug 28, 2012
commit b74e62506c8dd767c616291b832b38fae04f59cf
10 changes: 10 additions & 0 deletions src/rustc/middle/trans/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,16 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
lv_temporary),
arg_vals(~[frameaddress_val]), ignore);
}
~"morestack_addr" => {
// XXX This is a hack to grab the address of this particular
// native function. There should be a general in-language
// way to do this
let llfty = type_of_fn(bcx.ccx(), ~[], ty::mk_nil(bcx.tcx()));
let morestack_addr = decl_cdecl_fn(
bcx.ccx().llmod, ~"__morestack", llfty);
let morestack_addr = PointerCast(bcx, morestack_addr, T_ptr(T_nil()));
Store(bcx, morestack_addr, fcx.llretptr);
}
_ => {
// Could we make this an enum rather than a string? does it get
// checked earlier?
Expand Down
3 changes: 3 additions & 0 deletions src/rustc/middle/typeck/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,9 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
});
(0u, ~[arg(ast::by_ref, fty)], ty::mk_nil(tcx))
}
~"morestack_addr" => {
(0u, ~[], ty::mk_nil_ptr(tcx))
}
other => {
tcx.sess.span_err(it.span, ~"unrecognized intrinsic function: `" +
other + ~"`");
Expand Down
11 changes: 11 additions & 0 deletions src/test/run-pass/morestack-address.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#[nolink]
#[abi = "rust-intrinsic"]
extern mod rusti {
fn morestack_addr() -> *();
}

fn main() {
let addr = rusti::morestack_addr();
assert addr.is_not_null();
error!("%?", addr);
}