Skip to content

Commit 5dbf850

Browse files
committed
WIP run analyses in parallel rayon fork/join tasks
1 parent 492714c commit 5dbf850

15 files changed

+506
-322
lines changed

Cargo.lock

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ quasi_codegen = "0.32"
4545
cexpr = "0.2"
4646
cfg-if = "0.1.0"
4747
clang-sys = { version = "0.19.0", features = ["runtime", "clang_3_9"] }
48+
lazy-init = "0.1.1"
4849
lazy_static = "0.2.1"
4950
peeking_take_while = "0.1.2"
5051
syntex_syntax = "0.58"
52+
rayon = "0.8.2"
5153
regex = "0.2"
5254
# This kinda sucks: https://github.com/rust-lang/cargo/issues/1982
5355
clap = "2"

src/codegen/struct_layout.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use syntax::ast;
1515

1616
/// Trace the layout of struct.
1717
#[derive(Debug)]
18-
pub struct StructLayoutTracker<'a, 'ctx: 'a> {
18+
pub struct StructLayoutTracker<'a> {
1919
name: &'a str,
20-
ctx: &'a BindgenContext<'ctx>,
20+
ctx: &'a BindgenContext,
2121
comp: &'a CompInfo,
2222
latest_offset: usize,
2323
padding_count: usize,
@@ -80,8 +80,8 @@ fn test_bytes_from_bits_pow2() {
8080
}
8181
}
8282

83-
impl<'a, 'ctx> StructLayoutTracker<'a, 'ctx> {
84-
pub fn new(ctx: &'a BindgenContext<'ctx>, comp: &'a CompInfo, name: &'a str) -> Self {
83+
impl<'a> StructLayoutTracker<'a> {
84+
pub fn new(ctx: &'a BindgenContext, comp: &'a CompInfo, name: &'a str) -> Self {
8585
StructLayoutTracker {
8686
name: name,
8787
ctx: ctx,

src/ir/analysis/derive_copy.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ use ir::template::TemplateParameters;
3131
/// derived copy if any of the template arguments or template definition
3232
/// cannot derive copy.
3333
#[derive(Debug, Clone)]
34-
pub struct CannotDeriveCopy<'ctx, 'gen>
35-
where 'gen: 'ctx
36-
{
37-
ctx: &'ctx BindgenContext<'gen>,
34+
pub struct CannotDeriveCopy<'ctx> {
35+
ctx: &'ctx BindgenContext,
3836

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

53-
impl<'ctx, 'gen> CannotDeriveCopy<'ctx, 'gen> {
51+
impl<'ctx> CannotDeriveCopy<'ctx> {
5452
fn consider_edge(kind: EdgeKind) -> bool {
5553
match kind {
5654
// These are the only edges that can affect whether a type can derive
@@ -89,12 +87,12 @@ impl<'ctx, 'gen> CannotDeriveCopy<'ctx, 'gen> {
8987
}
9088
}
9189

92-
impl<'ctx, 'gen> MonotoneFramework for CannotDeriveCopy<'ctx, 'gen> {
90+
impl<'ctx> MonotoneFramework for CannotDeriveCopy<'ctx> {
9391
type Node = ItemId;
94-
type Extra = &'ctx BindgenContext<'gen>;
92+
type Extra = &'ctx BindgenContext;
9593
type Output = HashSet<ItemId>;
9694

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

@@ -302,8 +300,8 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveCopy<'ctx, 'gen> {
302300
}
303301
}
304302

305-
impl<'ctx, 'gen> From<CannotDeriveCopy<'ctx, 'gen>> for HashSet<ItemId> {
306-
fn from(analysis: CannotDeriveCopy<'ctx, 'gen>) -> Self {
303+
impl<'ctx> From<CannotDeriveCopy<'ctx>> for HashSet<ItemId> {
304+
fn from(analysis: CannotDeriveCopy<'ctx>) -> Self {
307305
analysis.cannot_derive_copy
308306
}
309307
}

src/ir/analysis/derive_debug.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ use ir::comp::CompKind;
3333
/// derived debug if any of the template arguments or template definition
3434
/// cannot derive debug.
3535
#[derive(Debug, Clone)]
36-
pub struct CannotDeriveDebug<'ctx, 'gen>
37-
where 'gen: 'ctx
38-
{
39-
ctx: &'ctx BindgenContext<'gen>,
36+
pub struct CannotDeriveDebug<'ctx> {
37+
ctx: &'ctx BindgenContext,
4038

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

55-
impl<'ctx, 'gen> CannotDeriveDebug<'ctx, 'gen> {
53+
impl<'ctx> CannotDeriveDebug<'ctx> {
5654
fn consider_edge(kind: EdgeKind) -> bool {
5755
match kind {
5856
// These are the only edges that can affect whether a type can derive
@@ -91,12 +89,12 @@ impl<'ctx, 'gen> CannotDeriveDebug<'ctx, 'gen> {
9189
}
9290
}
9391

94-
impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
92+
impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
9593
type Node = ItemId;
96-
type Extra = &'ctx BindgenContext<'gen>;
94+
type Extra = &'ctx BindgenContext;
9795
type Output = HashSet<ItemId>;
9896

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

@@ -315,8 +313,8 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
315313
}
316314
}
317315

318-
impl<'ctx, 'gen> From<CannotDeriveDebug<'ctx, 'gen>> for HashSet<ItemId> {
319-
fn from(analysis: CannotDeriveDebug<'ctx, 'gen>) -> Self {
316+
impl<'ctx> From<CannotDeriveDebug<'ctx>> for HashSet<ItemId> {
317+
fn from(analysis: CannotDeriveDebug<'ctx>) -> Self {
320318
analysis.cannot_derive_debug
321319
}
322320
}

0 commit comments

Comments
 (0)