Skip to content

Commit 4beef2c

Browse files
committed
Remove currently unused Nop,Swap op
1 parent 8e78c6d commit 4beef2c

File tree

3 files changed

+1
-20
lines changed

3 files changed

+1
-20
lines changed

compiler/codegen/src/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ impl Compiler {
18801880
emit!(self, Instruction::Pop);
18811881
} else {
18821882
// Show line coverage for default case (it doesn't create bytecode)
1883-
emit!(self, Instruction::Nop);
1883+
// emit!(self, Instruction::Nop);
18841884
}
18851885
self.compile_statements(&m.body)?;
18861886
}

compiler/core/src/bytecode.rs

-11
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,6 @@ pub type NameIdx = u32;
370370
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
371371
#[repr(u8)]
372372
pub enum Instruction {
373-
/// No-op, don't do anything at all
374-
///
375-
/// Equivalent to `NOP` in cpython bytecode
376-
Nop,
377373
/// Importing by name
378374
ImportName {
379375
idx: Arg<NameIdx>,
@@ -432,9 +428,6 @@ pub enum Instruction {
432428
op: Arg<ComparisonOperator>,
433429
},
434430
Pop,
435-
Swap {
436-
index: Arg<u32>,
437-
},
438431
Rotate2,
439432
Rotate3,
440433
Duplicate,
@@ -1184,7 +1177,6 @@ impl Instruction {
11841177
///
11851178
pub fn stack_effect(&self, arg: OpArg, jump: bool) -> i32 {
11861179
match self {
1187-
Nop => 0,
11881180
ImportName { .. } | ImportNameless => -1,
11891181
ImportStar => -1,
11901182
ImportFrom { .. } => 1,
@@ -1205,7 +1197,6 @@ impl Instruction {
12051197
| TestOperation { .. }
12061198
| CompareOperation { .. } => -1,
12071199
Pop => -1,
1208-
Swap { .. } => 0,
12091200
Rotate2 | Rotate3 => 0,
12101201
Duplicate => 1,
12111202
Duplicate2 => 2,
@@ -1370,7 +1361,6 @@ impl Instruction {
13701361
};
13711362

13721363
match self {
1373-
Nop => w!(Nop),
13741364
ImportName { idx } => w!(ImportName, name = idx),
13751365
ImportNameless => w!(ImportNameless),
13761366
ImportStar => w!(ImportStar),
@@ -1402,7 +1392,6 @@ impl Instruction {
14021392
TestOperation { op } => w!(TestOperation, ?op),
14031393
CompareOperation { op } => w!(CompareOperation, ?op),
14041394
Pop => w!(Pop),
1405-
Swap { index } => w!(Swap, index),
14061395
Rotate2 => w!(Rotate2),
14071396
Rotate3 => w!(Rotate3),
14081397
Duplicate => w!(Duplicate),

vm/src/frame.rs

-8
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ impl ExecutingFrame<'_> {
517517
}
518518

519519
match instruction {
520-
bytecode::Instruction::Nop => Ok(None),
521520
bytecode::Instruction::LoadConst { idx } => {
522521
self.push_value(self.code.constants[idx.get(arg) as usize].clone().into());
523522
Ok(None)
@@ -673,13 +672,6 @@ impl ExecutingFrame<'_> {
673672
self.pop_value();
674673
Ok(None)
675674
}
676-
bytecode::Instruction::Swap { index } => {
677-
let len = self.state.stack.len();
678-
self.state
679-
.stack
680-
.swap(len - 1, len - 1 - index.get(arg) as usize);
681-
Ok(None)
682-
}
683675
bytecode::Instruction::Duplicate => {
684676
// Duplicate top of stack
685677
let value = self.top_value();

0 commit comments

Comments
 (0)