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

librustc: Get rid of structural records save for front/test.rs. #5030

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/back/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use session::sess_os_to_meta_os;
use metadata::loader::meta_section_name;

pub fn get_target_strs(target_os: session::os) -> target_strs::t {
return {
return target_strs::t {
module_asm: ~"",

meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)),
Expand Down
57 changes: 36 additions & 21 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use lib::llvm::llvm;
use lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False};
use lib::llvm::{PassManagerRef, FileType};
use lib;
use metadata::common::link_meta;
use metadata::common::LinkMeta;
use metadata::filesearch;
use metadata::{encoder, cstore};
use middle::trans::common::crate_ctxt;
use middle::trans::common::CrateContext;
use middle::ty;
use session::Session;
use session;
Expand Down Expand Up @@ -451,15 +451,16 @@ pub mod write {
*/

pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
symbol_hasher: &hash::State) -> link_meta {
symbol_hasher: &hash::State) -> LinkMeta {

type provided_metas =
{name: Option<@str>,
vers: Option<@str>,
cmh_items: ~[@ast::meta_item]};
struct ProvidedMetas {
name: Option<@str>,
vers: Option<@str>,
cmh_items: ~[@ast::meta_item]
}

fn provided_link_metas(sess: Session, c: &ast::crate) ->
provided_metas {
ProvidedMetas {
let mut name = None;
let mut vers = None;
let mut cmh_items = ~[];
Expand All @@ -480,7 +481,12 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
}
} else { cmh_items.push(*meta); }
}
return {name: name, vers: vers, cmh_items: cmh_items};

ProvidedMetas {
name: name,
vers: vers,
cmh_items: cmh_items
}
}

// This calculates CMH as defined above
Expand Down Expand Up @@ -563,16 +569,23 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
};
}

let {name: opt_name, vers: opt_vers,
cmh_items: cmh_items} = provided_link_metas(sess, c);
let ProvidedMetas {
name: opt_name,
vers: opt_vers,
cmh_items: cmh_items
} = provided_link_metas(sess, c);
let name = crate_meta_name(sess, output, opt_name);
let vers = crate_meta_vers(sess, opt_vers);
let dep_hashes = cstore::get_dep_hashes(sess.cstore);
let extras_hash =
crate_meta_extras_hash(symbol_hasher, cmh_items,
dep_hashes);

return {name: name, vers: vers, extras_hash: extras_hash};
LinkMeta {
name: name,
vers: vers,
extras_hash: extras_hash
}
}

pub fn truncated_hash_result(symbol_hasher: &hash::State) -> ~str {
Expand All @@ -584,7 +597,7 @@ pub fn truncated_hash_result(symbol_hasher: &hash::State) -> ~str {

// This calculates STH for a symbol, as defined above
pub fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t,
link_meta: link_meta) -> @str {
link_meta: LinkMeta) -> @str {
// NB: do *not* use abbrevs here as we want the symbol names
// to be independent of one another in the crate.

Expand All @@ -601,7 +614,7 @@ pub fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t,
hash.to_managed()
}

pub fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> @str {
pub fn get_symbol_hash(ccx: @CrateContext, t: ty::t) -> @str {
match ccx.type_hashcodes.find(&t) {
Some(h) => h,
None => {
Expand Down Expand Up @@ -673,14 +686,16 @@ pub fn exported_name(sess: Session,
path_name(sess.ident_of(vers.to_owned()))));
}

pub fn mangle_exported_name(ccx: @crate_ctxt, +path: path, t: ty::t) -> ~str {
pub fn mangle_exported_name(ccx: @CrateContext,
+path: path,
t: ty::t) -> ~str {
let hash = get_symbol_hash(ccx, t);
return exported_name(ccx.sess, path,
hash,
ccx.link_meta.vers);
}

pub fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
pub fn mangle_internal_name_by_type_only(ccx: @CrateContext,
t: ty::t,
name: &str) -> ~str {
let s = ppaux::ty_to_short_str(ccx.tcx, t);
Expand All @@ -691,23 +706,23 @@ pub fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
path_name(ccx.sess.ident_of(hash.to_owned()))]);
}

pub fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt,
pub fn mangle_internal_name_by_path_and_seq(ccx: @CrateContext,
+path: path,
+flav: ~str) -> ~str {
return mangle(ccx.sess,
vec::append_one(path, path_name((ccx.names)(flav))));
}

pub fn mangle_internal_name_by_path(ccx: @crate_ctxt, +path: path) -> ~str {
pub fn mangle_internal_name_by_path(ccx: @CrateContext, +path: path) -> ~str {
return mangle(ccx.sess, path);
}

pub fn mangle_internal_name_by_seq(ccx: @crate_ctxt, +flav: ~str) -> ~str {
pub fn mangle_internal_name_by_seq(ccx: @CrateContext, +flav: ~str) -> ~str {
return fmt!("%s_%u", flav, (ccx.names)(flav).repr);
}


pub fn output_dll_filename(os: session::os, lm: link_meta) -> ~str {
pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str {
let libname = fmt!("%s-%s-%s", lm.name, lm.extras_hash, lm.vers);
let (dll_prefix, dll_suffix) = match os {
session::os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
Expand All @@ -725,7 +740,7 @@ pub fn output_dll_filename(os: session::os, lm: link_meta) -> ~str {
pub fn link_binary(sess: Session,
obj_filename: &Path,
out_filename: &Path,
lm: link_meta) {
lm: LinkMeta) {
// Converts a library file-stem into a cc -l argument
fn unlib(config: @session::config, +stem: ~str) -> ~str {
if stem.starts_with("lib") &&
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/back/target_strs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
// except according to those terms.


pub type t = {
pub struct t {
module_asm: ~str,
meta_sect_name: ~str,
data_layout: ~str,
target_triple: ~str,
cc_args: ~[~str]
};
}
46 changes: 24 additions & 22 deletions src/librustc/back/upcall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ use middle::trans::common::{T_fn, T_i1, T_i8, T_i32,
T_int, T_nil,
T_opaque_vec, T_ptr, T_unique_ptr,
T_size_t, T_void, T_vec2};
use lib::llvm::{type_names, ModuleRef, ValueRef, TypeRef};
use lib::llvm::{TypeNames, ModuleRef, ValueRef, TypeRef};

pub type upcalls =
{trace: ValueRef,
call_shim_on_c_stack: ValueRef,
call_shim_on_rust_stack: ValueRef,
rust_personality: ValueRef,
reset_stack_limit: ValueRef};
pub struct Upcalls {
trace: ValueRef,
call_shim_on_c_stack: ValueRef,
call_shim_on_rust_stack: ValueRef,
rust_personality: ValueRef,
reset_stack_limit: ValueRef
}

pub fn declare_upcalls(targ_cfg: @session::config,
llmod: ModuleRef) -> @upcalls {
llmod: ModuleRef) -> @Upcalls {
fn decl(llmod: ModuleRef, prefix: ~str, name: ~str,
tys: ~[TypeRef], rv: TypeRef) ->
ValueRef {
Expand All @@ -43,22 +44,23 @@ pub fn declare_upcalls(targ_cfg: @session::config,

let int_t = T_int(targ_cfg);

return @{trace: dv(~"trace", ~[T_ptr(T_i8()),
@Upcalls {
trace: dv(~"trace", ~[T_ptr(T_i8()),
T_ptr(T_i8()),
int_t]),
call_shim_on_c_stack:
d(~"call_shim_on_c_stack",
// arguments: void *args, void *fn_ptr
~[T_ptr(T_i8()), T_ptr(T_i8())],
int_t),
call_shim_on_rust_stack:
d(~"call_shim_on_rust_stack",
~[T_ptr(T_i8()), T_ptr(T_i8())], int_t),
rust_personality:
nothrow(d(~"rust_personality", ~[], T_i32())),
reset_stack_limit:
nothrow(dv(~"reset_stack_limit", ~[]))
};
call_shim_on_c_stack:
d(~"call_shim_on_c_stack",
// arguments: void *args, void *fn_ptr
~[T_ptr(T_i8()), T_ptr(T_i8())],
int_t),
call_shim_on_rust_stack:
d(~"call_shim_on_rust_stack",
~[T_ptr(T_i8()), T_ptr(T_i8())], int_t),
rust_personality:
nothrow(d(~"rust_personality", ~[], T_i32())),
reset_stack_limit:
nothrow(dv(~"reset_stack_limit", ~[]))
}
}
//
// Local Variables:
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/back/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use metadata::loader::meta_section_name;
use session::sess_os_to_meta_os;

pub fn get_target_strs(target_os: session::os) -> target_strs::t {
return {
return target_strs::t {
module_asm: ~"",

meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/back/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use metadata::loader::meta_section_name;
use session::sess_os_to_meta_os;

pub fn get_target_strs(target_os: session::os) -> target_strs::t {
return {
return target_strs::t {
module_asm: ~"",

meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)),
Expand Down
Loading