mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-22 12:35:22 +00:00
Disable the unpack optimization
This commit is contained in:
parent
1e12aa8afe
commit
aba7359b36
2 changed files with 25 additions and 24 deletions
|
@ -92,7 +92,7 @@ impl<O: OutputStream> PeepholeOptimizer<O> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn optimize(&mut self) {
|
fn optimize(&mut self) {
|
||||||
apply_optimizations!(self, operator, unpack);
|
apply_optimizations!(self, operator /* , unpack */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,26 +73,27 @@ pub fn operator(buf: &mut impl OptimizationBuffer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unpack(buf: &mut impl OptimizationBuffer) {
|
// TODO: make a version of this that doesn't miscompile `a, b = (1, 2) if True else (3, 4)`
|
||||||
let (instruction, meta) = buf.pop();
|
// pub fn unpack(buf: &mut impl OptimizationBuffer) {
|
||||||
if let Instruction::UnpackSequence { size } = instruction {
|
// let (instruction, meta) = buf.pop();
|
||||||
let (arg, arg_meta) = buf.pop();
|
// if let Instruction::UnpackSequence { size } = instruction {
|
||||||
match arg {
|
// let (arg, arg_meta) = buf.pop();
|
||||||
Instruction::BuildTuple {
|
// match arg {
|
||||||
size: tup_size,
|
// Instruction::BuildTuple {
|
||||||
unpack,
|
// size: tup_size,
|
||||||
} if !unpack && tup_size == size => {
|
// unpack,
|
||||||
buf.emit(
|
// } if !unpack && tup_size == size => {
|
||||||
Instruction::Reverse { amount: size },
|
// buf.emit(
|
||||||
vec![arg_meta, meta].into(),
|
// Instruction::Reverse { amount: size },
|
||||||
);
|
// vec![arg_meta, meta].into(),
|
||||||
}
|
// );
|
||||||
arg => {
|
// }
|
||||||
buf.emit(arg, arg_meta);
|
// arg => {
|
||||||
buf.emit(instruction, meta);
|
// buf.emit(arg, arg_meta);
|
||||||
}
|
// buf.emit(instruction, meta);
|
||||||
}
|
// }
|
||||||
} else {
|
// }
|
||||||
buf.emit(instruction, meta)
|
// } else {
|
||||||
}
|
// buf.emit(instruction, meta)
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue