Skip to content

Commit

Permalink
WIP run analyses in parallel rayon fork/join tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen committed Aug 14, 2017
1 parent 492714c commit 5dbf850
Show file tree
Hide file tree
Showing 15 changed files with 506 additions and 322 deletions.
118 changes: 118 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ quasi_codegen = "0.32"
cexpr = "0.2"
cfg-if = "0.1.0"
clang-sys = { version = "0.19.0", features = ["runtime", "clang_3_9"] }
lazy-init = "0.1.1"
lazy_static = "0.2.1"
peeking_take_while = "0.1.2"
syntex_syntax = "0.58"
rayon = "0.8.2"
regex = "0.2"
# This kinda sucks: https://github.com/rust-lang/cargo/issues/1982
clap = "2"
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/struct_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use syntax::ast;

/// Trace the layout of struct.
#[derive(Debug)]
pub struct StructLayoutTracker<'a, 'ctx: 'a> {
pub struct StructLayoutTracker<'a> {
name: &'a str,
ctx: &'a BindgenContext<'ctx>,
ctx: &'a BindgenContext,
comp: &'a CompInfo,
latest_offset: usize,
padding_count: usize,
Expand Down Expand Up @@ -80,8 +80,8 @@ fn test_bytes_from_bits_pow2() {
}
}

impl<'a, 'ctx> StructLayoutTracker<'a, 'ctx> {
pub fn new(ctx: &'a BindgenContext<'ctx>, comp: &'a CompInfo, name: &'a str) -> Self {
impl<'a> StructLayoutTracker<'a> {
pub fn new(ctx: &'a BindgenContext, comp: &'a CompInfo, name: &'a str) -> Self {
StructLayoutTracker {
name: name,
ctx: ctx,
Expand Down
18 changes: 8 additions & 10 deletions src/ir/analysis/derive_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ use ir::template::TemplateParameters;
/// derived copy if any of the template arguments or template definition
/// cannot derive copy.
#[derive(Debug, Clone)]
pub struct CannotDeriveCopy<'ctx, 'gen>
where 'gen: 'ctx
{
ctx: &'ctx BindgenContext<'gen>,
pub struct CannotDeriveCopy<'ctx> {
ctx: &'ctx BindgenContext,

// The incremental result of this analysis's computation. Everything in this
// set cannot derive copy.
Expand All @@ -50,7 +48,7 @@ pub struct CannotDeriveCopy<'ctx, 'gen>
dependencies: HashMap<ItemId, Vec<ItemId>>,
}

impl<'ctx, 'gen> CannotDeriveCopy<'ctx, 'gen> {
impl<'ctx> CannotDeriveCopy<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type can derive
Expand Down Expand Up @@ -89,12 +87,12 @@ impl<'ctx, 'gen> CannotDeriveCopy<'ctx, 'gen> {
}
}

impl<'ctx, 'gen> MonotoneFramework for CannotDeriveCopy<'ctx, 'gen> {
impl<'ctx> MonotoneFramework for CannotDeriveCopy<'ctx> {
type Node = ItemId;
type Extra = &'ctx BindgenContext<'gen>;
type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;

fn new(ctx: &'ctx BindgenContext<'gen>) -> CannotDeriveCopy<'ctx, 'gen> {
fn new(ctx: &'ctx BindgenContext) -> CannotDeriveCopy<'ctx> {
let cannot_derive_copy = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);

Expand Down Expand Up @@ -302,8 +300,8 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveCopy<'ctx, 'gen> {
}
}

impl<'ctx, 'gen> From<CannotDeriveCopy<'ctx, 'gen>> for HashSet<ItemId> {
fn from(analysis: CannotDeriveCopy<'ctx, 'gen>) -> Self {
impl<'ctx> From<CannotDeriveCopy<'ctx>> for HashSet<ItemId> {
fn from(analysis: CannotDeriveCopy<'ctx>) -> Self {
analysis.cannot_derive_copy
}
}
18 changes: 8 additions & 10 deletions src/ir/analysis/derive_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ use ir::comp::CompKind;
/// derived debug if any of the template arguments or template definition
/// cannot derive debug.
#[derive(Debug, Clone)]
pub struct CannotDeriveDebug<'ctx, 'gen>
where 'gen: 'ctx
{
ctx: &'ctx BindgenContext<'gen>,
pub struct CannotDeriveDebug<'ctx> {
ctx: &'ctx BindgenContext,

// The incremental result of this analysis's computation. Everything in this
// set cannot derive debug.
Expand All @@ -52,7 +50,7 @@ pub struct CannotDeriveDebug<'ctx, 'gen>
dependencies: HashMap<ItemId, Vec<ItemId>>,
}

impl<'ctx, 'gen> CannotDeriveDebug<'ctx, 'gen> {
impl<'ctx> CannotDeriveDebug<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type can derive
Expand Down Expand Up @@ -91,12 +89,12 @@ impl<'ctx, 'gen> CannotDeriveDebug<'ctx, 'gen> {
}
}

impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
type Node = ItemId;
type Extra = &'ctx BindgenContext<'gen>;
type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;

fn new(ctx: &'ctx BindgenContext<'gen>) -> CannotDeriveDebug<'ctx, 'gen> {
fn new(ctx: &'ctx BindgenContext) -> CannotDeriveDebug<'ctx> {
let cannot_derive_debug = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);

Expand Down Expand Up @@ -315,8 +313,8 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
}
}

impl<'ctx, 'gen> From<CannotDeriveDebug<'ctx, 'gen>> for HashSet<ItemId> {
fn from(analysis: CannotDeriveDebug<'ctx, 'gen>) -> Self {
impl<'ctx> From<CannotDeriveDebug<'ctx>> for HashSet<ItemId> {
fn from(analysis: CannotDeriveDebug<'ctx>) -> Self {
analysis.cannot_derive_debug
}
}
Loading

0 comments on commit 5dbf850

Please sign in to comment.