Skip to content

Commit

Permalink
Auto merge of #28176 - arielb1:fast-index, r=eddyb
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Sep 3, 2015
2 parents 1661947 + cde09e7 commit 9e9c83b
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 287 deletions.
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Expand Up @@ -51,7 +51,6 @@
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(scoped_tls)]
#![feature(slice_bytes)]
#![feature(slice_splits)]
#![feature(slice_patterns)]
#![feature(staged_api)]
Expand Down
8 changes: 1 addition & 7 deletions src/librustc/metadata/common.rs
Expand Up @@ -45,13 +45,7 @@ pub const tag_items_data_item_is_tuple_struct_ctor: usize = 0x29;

pub const tag_index: usize = 0x2a;

pub const tag_index_buckets: usize = 0x2b;

pub const tag_index_buckets_bucket: usize = 0x2c;

pub const tag_index_buckets_bucket_elt: usize = 0x2d;

pub const tag_index_table: usize = 0x2e;
// GAP 0x2b, 0x2c, 0x2d, 0x2e

pub const tag_meta_item_name_value: usize = 0x2f;

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/creader.rs
Expand Up @@ -304,6 +304,7 @@ impl<'a> CrateReader<'a> {
let cmeta = Rc::new(cstore::crate_metadata {
name: name.to_string(),
local_path: RefCell::new(SmallVector::zero()),
index: decoder::load_index(metadata.as_slice()),
data: metadata,
cnum_map: RefCell::new(cnum_map),
cnum: cnum,
Expand Down Expand Up @@ -521,7 +522,7 @@ impl<'a> CrateReader<'a> {
}

let registrar = decoder::get_plugin_registrar_fn(ekrate.metadata.as_slice())
.map(|id| decoder::get_symbol(ekrate.metadata.as_slice(), id));
.map(|id| decoder::get_symbol_from_buf(ekrate.metadata.as_slice(), id));

match (ekrate.dylib.as_ref(), registrar) {
(Some(dylib), Some(reg)) => Some((dylib.to_path_buf(), reg)),
Expand Down
36 changes: 3 additions & 33 deletions src/librustc/metadata/csearch.rs
Expand Up @@ -11,23 +11,18 @@
// Searching for information from the cstore

use front::map as ast_map;
use metadata::common::*;
use metadata::cstore;
use metadata::decoder;
use metadata::inline::InlinedItem;
use middle::def_id::DefId;
use middle::lang_items;
use middle::ty;
use util::nodemap::FnvHashMap;

use rbml;
use rbml::reader;
use std::rc::Rc;
use syntax::ast;
use rustc_front::attr;
use rustc_front::hir;
use syntax::diagnostic::expect;

use std::collections::hash_map::HashMap;

#[derive(Copy, Clone)]
pub struct MethodInfo {
Expand All @@ -38,7 +33,7 @@ pub struct MethodInfo {

pub fn get_symbol(cstore: &cstore::CStore, def: DefId) -> String {
let cdata = cstore.get_crate_data(def.krate);
decoder::get_symbol(cdata.data(), def.node)
decoder::get_symbol(&cdata, def.node)
}

/// Iterates over all the language items in the given crate.
Expand Down Expand Up @@ -201,7 +196,7 @@ pub fn get_struct_field_names(cstore: &cstore::CStore, def: DefId) -> Vec<ast::N
decoder::get_struct_field_names(&cstore.intr, &*cdata, def.node)
}

pub fn get_struct_field_attrs(cstore: &cstore::CStore, def: DefId) -> HashMap<ast::NodeId,
pub fn get_struct_field_attrs(cstore: &cstore::CStore, def: DefId) -> FnvHashMap<ast::NodeId,
Vec<hir::Attribute>> {
let cdata = cstore.get_crate_data(def.krate);
decoder::get_struct_field_attrs(&*cdata)
Expand Down Expand Up @@ -243,31 +238,6 @@ pub fn get_super_predicates<'tcx>(tcx: &ty::ctxt<'tcx>, def: DefId)
decoder::get_super_predicates(&*cdata, def.node, tcx)
}

pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: DefId,
def: DefId) -> ty::TypeScheme<'tcx> {
let cstore = &tcx.sess.cstore;
let cdata = cstore.get_crate_data(class_id.krate);
let all_items = reader::get_doc(rbml::Doc::new(cdata.data()), tag_items);
let class_doc = expect(tcx.sess.diagnostic(),
decoder::maybe_find_item(class_id.node, all_items),
|| {
(format!("get_field_type: class ID {:?} not found",
class_id)).to_string()
});
let the_field = expect(tcx.sess.diagnostic(),
decoder::maybe_find_item(def.node, class_doc),
|| {
(format!("get_field_type: in class {:?}, field ID {:?} not found",
class_id,
def)).to_string()
});
let ty = decoder::item_type(def, the_field, tcx, &*cdata);
ty::TypeScheme {
generics: ty::Generics::empty(),
ty: ty,
}
}

pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
def: DefId)
-> Option<hir::ImplPolarity>
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/cstore.rs
Expand Up @@ -18,7 +18,7 @@ pub use self::LinkagePreference::*;
pub use self::NativeLibraryKind::*;

use back::svh::Svh;
use metadata::{creader, decoder, loader};
use metadata::{creader, decoder, index, loader};
use session::search_paths::PathKind;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};

Expand Down Expand Up @@ -65,6 +65,7 @@ pub struct crate_metadata {
pub codemap_import_info: RefCell<Vec<ImportedFileMap>>,
pub span: codemap::Span,
pub staged_api: bool,
pub index: index::Index,

/// Flag if this crate is required by an rlib version of this crate, or in
/// other words whether it was explicitly linked to. An example of a crate
Expand Down

0 comments on commit 9e9c83b

Please sign in to comment.