Skip to content

Commit

Permalink
Merge pull request #395 from philipc/unwind-context
Browse files Browse the repository at this point in the history
Change UninitializedUnwindContext::initialize to borrow
  • Loading branch information
fitzgen authored Mar 1, 2019
2 parents 7b828cb + 1ed925e commit 039e042
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 278 deletions.
25 changes: 9 additions & 16 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ mod cfi {
.set_got(0)
.set_text(0);

let mut ctx = Some(UninitializedUnwindContext::new());
let mut ctx = UninitializedUnwindContext::new();

b.iter(|| {
let mut entries = eh_frame.entries(&bases);
Expand All @@ -630,22 +630,18 @@ mod cfi {
.parse(|offset| eh_frame.cie_from_offset(&bases, offset))
.expect("Should be able to get CIE for FED");

let mut context = ctx
.take()
.unwrap()
let context = ctx
.initialize(fde.cie())
.expect("Should be able to initialize ctx");

{
let mut table = UnwindTable::new(&mut context, &fde);
let mut table = UnwindTable::new(context, &fde);
while let Some(row) =
table.next_row().expect("Should get next unwind table row")
{
test::black_box(row);
}
}

ctx = Some(context.reset());
}
};
}
Expand Down Expand Up @@ -715,11 +711,12 @@ mod cfi {
let fde = get_fde_with_longest_cfi_instructions(&eh_frame);

b.iter(|| {
let mut ctx = UninitializedUnwindContext::new()
let mut ctx = UninitializedUnwindContext::new();
let context = ctx
.initialize(fde.cie())
.expect("Should initialize the ctx OK");

let mut table = UnwindTable::new(&mut ctx, &fde);
let mut table = UnwindTable::new(context, &fde);
while let Some(row) = table.next_row().expect("Should get next unwind table row") {
test::black_box(row);
}
Expand All @@ -732,23 +729,19 @@ mod cfi {
let eh_frame = EhFrame::new(&eh_frame, LittleEndian);
let fde = get_fde_with_longest_cfi_instructions(&eh_frame);

let mut ctx = Some(UninitializedUnwindContext::new());
let mut ctx = UninitializedUnwindContext::new();

b.iter(|| {
let mut context = ctx
.take()
.unwrap()
let context = ctx
.initialize(fde.cie())
.expect("Should be able to initialize ctx");

{
let mut table = UnwindTable::new(&mut context, &fde);
let mut table = UnwindTable::new(context, &fde);
while let Some(row) = table.next_row().expect("Should get next unwind table row") {
test::black_box(row);
}
}

ctx = Some(context.reset());
});
}
}
Loading

0 comments on commit 039e042

Please sign in to comment.