Skip to content

Commit 6fe0598

Browse files
ShaharNavehyouknowonegithub-actions[bot]
authored
Remove Reverse bytecode (RustPython#6675)
* Remove `Reverse` bytecode * Update crates/compiler-core/src/bytecode.rs Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com> * Gen * Remove Reverse * Auto-format: cargo fmt --all * Revert comment * Remove debug code * Fix CI --------- Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 9291178 commit 6fe0598

File tree

5 files changed

+1
-21
lines changed

5 files changed

+1
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ jobs:
334334
- name: Ensure Lib/_opcode_metadata is updated
335335
run: |
336336
python scripts/generate_opcode_metadata.py
337-
if [ -z "$(git status --porcelain)" ]; then
337+
if [ -n "$(git status --porcelain)" ]; then
338338
exit 1
339339
fi
340340

Lib/_opcode_metadata.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
_specializations = {}
66

7-
8-
9-
10-
117
_specialized_opmap = {}
128

139
opmap = {
@@ -141,7 +137,6 @@
141137
'JUMP_IF_TRUE_OR_POP': 130,
142138
'JUMP_IF_NOT_EXC_MATCH': 131,
143139
'LOAD_CLASS_DEREF': 132,
144-
'REVERSE': 133,
145140
'SET_EXC_INFO': 134,
146141
'SUBSCRIPT': 135,
147142
'RESUME': 149,

crates/compiler-core/src/bytecode.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -932,9 +932,6 @@ pub enum Instruction {
932932
} = 130,
933933
JumpIfNotExcMatch(Arg<Label>) = 131,
934934
LoadClassDeref(Arg<NameIdx>) = 132,
935-
Reverse {
936-
amount: Arg<u32>,
937-
} = 133,
938935
SetExcInfo = 134,
939936
Subscript = 135,
940937
// ===== Pseudo Opcodes (252+) ======
@@ -1000,9 +997,6 @@ impl TryFrom<u8> for Instruction {
1000997
}),
1001998
u8::from(Self::JumpIfNotExcMatch(Arg::marker())),
1002999
u8::from(Self::LoadClassDeref(Arg::marker())),
1003-
u8::from(Self::Reverse {
1004-
amount: Arg::marker(),
1005-
}),
10061000
u8::from(Self::SetExcInfo),
10071001
u8::from(Self::Subscript),
10081002
];
@@ -1922,7 +1916,6 @@ impl Instruction {
19221916
-1 + before as i32 + 1 + after as i32
19231917
}
19241918
PopExcept => 0,
1925-
Reverse { .. } => 0,
19261919
GetAwaitable => 0,
19271920
BeforeAsyncWith => 1,
19281921
GetAIter => 0,
@@ -2094,7 +2087,6 @@ impl Instruction {
20942087
Resume { arg } => w!(RESUME, arg),
20952088
ReturnConst { idx } => fmt_const("RETURN_CONST", arg, f, idx),
20962089
ReturnValue => w!(RETURN_VALUE),
2097-
Reverse { amount } => w!(REVERSE, amount),
20982090
Send { target } => w!(SEND, target),
20992091
SetAdd { i } => w!(SET_ADD, i),
21002092
SetExcInfo => w!(SET_EXC_INFO),

crates/vm/src/frame.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,11 +1458,6 @@ impl ExecutingFrame<'_> {
14581458
let value = self.pop_value();
14591459
self.unwind_blocks(vm, UnwindReason::Returning { value })
14601460
}
1461-
bytecode::Instruction::Reverse { amount } => {
1462-
let stack_len = self.state.stack.len();
1463-
self.state.stack[stack_len - amount.get(arg) as usize..stack_len].reverse();
1464-
Ok(None)
1465-
}
14661461
bytecode::Instruction::SetAdd { i } => {
14671462
let item = self.pop_value();
14681463
let obj = self.nth_value(i.get(arg));

scripts/generate_opcode_metadata.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ def cpython_name(self) -> str:
2525
name = self.rust_name
2626
name = re.sub(r"(?<=[a-z0-9])([A-Z])", r"_\1", name)
2727
return re.sub(r"(\D)(\d+)$", r"\1_\2", name).upper()
28-
return re.sub(r"(?<=[a-z0-9])([A-Z])", r"_\1", self.rust_name).upper()
29-
return re.sub(r"(?<!^)(?=[A-Z])", "_", self.rust_name).upper()
3028

3129
@classmethod
3230
def from_str(cls, body: str):

0 commit comments

Comments
 (0)