fuzzbug fix
This commit is contained in:
parent
110fe11fa8
commit
d6c6c70965
|
@ -27,6 +27,7 @@ impl<'a, FT: FuncTypeSink> WasmContext<'a, FT> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn translate(&mut self, op: &SerializedOperator, locations: &Locations) {
|
fn translate(&mut self, op: &SerializedOperator, locations: &Locations) {
|
||||||
|
log::trace!("translate: {:?}", op);
|
||||||
match op {
|
match op {
|
||||||
SerializedOperator::StartBlock {
|
SerializedOperator::StartBlock {
|
||||||
ref params,
|
ref params,
|
||||||
|
@ -129,6 +130,7 @@ impl<'a, FT: FuncTypeSink> WasmContext<'a, FT> {
|
||||||
target: &SerializedBlockTarget,
|
target: &SerializedBlockTarget,
|
||||||
locations: &Locations,
|
locations: &Locations,
|
||||||
) {
|
) {
|
||||||
|
log::trace!("translate_target: {:?}", target);
|
||||||
match target {
|
match target {
|
||||||
&SerializedBlockTarget::Fallthrough(ref ops) => {
|
&SerializedBlockTarget::Fallthrough(ref ops) => {
|
||||||
for op in ops {
|
for op in ops {
|
||||||
|
|
|
@ -246,12 +246,14 @@ impl<'a> SerializedBodyContext<'a> {
|
||||||
let targets = targets
|
let targets = targets
|
||||||
.iter()
|
.iter()
|
||||||
.map(|target| {
|
.map(|target| {
|
||||||
|
log::trace!("target: {:?}", target);
|
||||||
let mut rev_ops = vec![];
|
let mut rev_ops = vec![];
|
||||||
for &value in target.args.iter().rev() {
|
for &value in target.args.iter().rev() {
|
||||||
let value = self.f.resolve_alias(value);
|
let value = self.f.resolve_alias(value);
|
||||||
self.push_value(value, &mut rev_ops);
|
self.push_value(value, &mut rev_ops);
|
||||||
}
|
}
|
||||||
rev_ops.reverse();
|
rev_ops.reverse();
|
||||||
|
log::trace!(" -> ops: {:?}", rev_ops);
|
||||||
match target.relative_branch {
|
match target.relative_branch {
|
||||||
Some(branch) => SerializedBlockTarget::Branch(branch, rev_ops),
|
Some(branch) => SerializedBlockTarget::Branch(branch, rev_ops),
|
||||||
None => SerializedBlockTarget::Fallthrough(rev_ops),
|
None => SerializedBlockTarget::Fallthrough(rev_ops),
|
||||||
|
|
|
@ -310,7 +310,15 @@ impl BlockOrder {
|
||||||
pub fn compute(f: &FunctionBody, cfg: &CFGInfo, wasm_region: &WasmRegion) -> BlockOrder {
|
pub fn compute(f: &FunctionBody, cfg: &CFGInfo, wasm_region: &WasmRegion) -> BlockOrder {
|
||||||
let mut target_stack = vec![];
|
let mut target_stack = vec![];
|
||||||
let mut entries = vec![];
|
let mut entries = vec![];
|
||||||
Self::generate_region(f, cfg, &mut target_stack, &mut entries, wasm_region, None);
|
Self::generate_region(
|
||||||
|
f,
|
||||||
|
cfg,
|
||||||
|
&mut target_stack,
|
||||||
|
&mut entries,
|
||||||
|
wasm_region,
|
||||||
|
None,
|
||||||
|
true,
|
||||||
|
);
|
||||||
log::trace!("entries: {:?}", entries);
|
log::trace!("entries: {:?}", entries);
|
||||||
BlockOrder { entries }
|
BlockOrder { entries }
|
||||||
}
|
}
|
||||||
|
@ -322,6 +330,7 @@ impl BlockOrder {
|
||||||
entries: &mut Vec<BlockOrderEntry>,
|
entries: &mut Vec<BlockOrderEntry>,
|
||||||
region: &WasmRegion,
|
region: &WasmRegion,
|
||||||
fallthrough: Option<BlockId>,
|
fallthrough: Option<BlockId>,
|
||||||
|
toplevel: bool,
|
||||||
) {
|
) {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
"BlockOrder::generate_region: stack {:?} region {:?} fallthrough {:?}",
|
"BlockOrder::generate_region: stack {:?} region {:?} fallthrough {:?}",
|
||||||
|
@ -345,7 +354,7 @@ impl BlockOrder {
|
||||||
target_stack.push(target);
|
target_stack.push(target);
|
||||||
}
|
}
|
||||||
let params = f.blocks[header].params.clone();
|
let params = f.blocks[header].params.clone();
|
||||||
let results = if header == 0 {
|
let results = if toplevel {
|
||||||
f.rets.clone()
|
f.rets.clone()
|
||||||
} else {
|
} else {
|
||||||
match fallthrough {
|
match fallthrough {
|
||||||
|
@ -370,7 +379,15 @@ impl BlockOrder {
|
||||||
} else {
|
} else {
|
||||||
Some(subregions[i + 1].header())
|
Some(subregions[i + 1].header())
|
||||||
};
|
};
|
||||||
Self::generate_region(f, cfg, target_stack, entries, subregion, fallthrough);
|
Self::generate_region(
|
||||||
|
f,
|
||||||
|
cfg,
|
||||||
|
target_stack,
|
||||||
|
entries,
|
||||||
|
subregion,
|
||||||
|
fallthrough,
|
||||||
|
false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.push(BlockOrderEntry::End);
|
entries.push(BlockOrderEntry::End);
|
||||||
|
|
|
@ -945,6 +945,7 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> {
|
||||||
};
|
};
|
||||||
// Get the frame we're branching to.
|
// Get the frame we're branching to.
|
||||||
let frame = self.relative_frame(*relative_depth).clone();
|
let frame = self.relative_frame(*relative_depth).clone();
|
||||||
|
log::trace!("Br/BrIf: dest frame {:?}", frame);
|
||||||
// Finally, generate the branch itself.
|
// Finally, generate the branch itself.
|
||||||
match cond {
|
match cond {
|
||||||
None => {
|
None => {
|
||||||
|
|
Loading…
Reference in a new issue