Skip to content

Commit 07e7f46

Browse files
committed
LoadClassDeref -> LoadFromDictOrDeref
1 parent 9e225f5 commit 07e7f46

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

Lib/_opcode_metadata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
'JUMP_IF_FALSE_OR_POP': 129,
137137
'JUMP_IF_TRUE_OR_POP': 130,
138138
'JUMP_IF_NOT_EXC_MATCH': 131,
139-
'LOAD_CLASS_DEREF': 132,
140139
'SET_EXC_INFO': 134,
141140
'SUBSCRIPT': 135,
142141
'RESUME': 149,

crates/codegen/src/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ impl Compiler {
15611561
NameUsage::Load => {
15621562
// Special case for class scope
15631563
if self.ctx.in_class && !self.ctx.in_func() {
1564-
Instruction::LoadClassDeref
1564+
Instruction::LoadFromDictOrDeref
15651565
} else {
15661566
Instruction::LoadDeref
15671567
}

crates/compiler-core/src/bytecode.rs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ pub enum Instruction {
842842
LoadFastLoadFast {
843843
arg: Arg<u32>,
844844
} = 88, // Placeholder
845-
LoadFromDictOrDeref(Arg<NameIdx>) = 89, // Placeholder
845+
LoadFromDictOrDeref(Arg<NameIdx>) = 89,
846846
LoadFromDictOrGlobals(Arg<NameIdx>) = 90, // Placeholder
847847
LoadGlobal(Arg<NameIdx>) = 91,
848848
LoadName(Arg<NameIdx>) = 92,
@@ -945,7 +945,6 @@ pub enum Instruction {
945945
target: Arg<Label>,
946946
} = 130,
947947
JumpIfNotExcMatch(Arg<Label>) = 131,
948-
LoadClassDeref(Arg<NameIdx>) = 132,
949948
SetExcInfo = 134,
950949
Subscript = 135,
951950
// ===== Pseudo Opcodes (252+) ======
@@ -1010,7 +1009,6 @@ impl TryFrom<u8> for Instruction {
10101009
target: Arg::marker(),
10111010
}),
10121011
u8::from(Self::JumpIfNotExcMatch(Arg::marker())),
1013-
u8::from(Self::LoadClassDeref(Arg::marker())),
10141012
u8::from(Self::SetExcInfo),
10151013
u8::from(Self::Subscript),
10161014
];
@@ -1805,14 +1803,14 @@ impl Instruction {
18051803
Nop => 0,
18061804
ImportName { .. } => -1,
18071805
ImportFrom { .. } => 1,
1808-
LoadFast(_) | LoadFastAndClear(_) | LoadName(_) | LoadGlobal(_) | LoadDeref(_)
1809-
| LoadClassDeref(_) => 1,
1806+
LoadFast(_) | LoadFastAndClear(_) | LoadName(_) | LoadGlobal(_) | LoadDeref(_) => 1,
18101807
StoreFast(_) | StoreName(_) | StoreGlobal(_) | StoreDeref(_) => -1,
18111808
StoreFastLoadFast { .. } => 0, // pop 1, push 1
18121809
DeleteFast(_) | DeleteName(_) | DeleteGlobal(_) | DeleteDeref(_) => 0,
18131810
LoadClosure(_) => 1,
18141811
Subscript => -1,
18151812
StoreSubscr => -3,
1813+
LoadFromDictOrDeref(_) => 1,
18161814
DeleteSubscr => -2,
18171815
LoadAttr { .. } => 0,
18181816
// LoadAttrMethod: pop obj, push method + self_or_null
@@ -1950,7 +1948,33 @@ impl Instruction {
19501948
UnaryNot => 0,
19511949
GetYieldFromIter => 0,
19521950
PushNull => 1, // Push NULL for call protocol
1953-
_ => 0,
1951+
Cache => 0,
1952+
BinarySlice => 0,
1953+
BinaryOpInplaceAddUnicode => 0,
1954+
EndFor => 0,
1955+
ExitInitCheck => 0,
1956+
InterpreterExit => 0,
1957+
LoadAssertionError => 0,
1958+
LoadLocals => 0,
1959+
ReturnGenerator => 0,
1960+
StoreSlice => 0,
1961+
DictMerge { .. } => 0,
1962+
BuildConstKeyMap { .. } => 0,
1963+
CopyFreeVars { .. } => 0,
1964+
EnterExecutor => 0,
1965+
JumpBackwardNoInterrupt { .. } => 0,
1966+
JumpBackward { .. } => 0,
1967+
JumpForward { .. } => 0,
1968+
ListExtend { .. } => 0,
1969+
LoadFastCheck(_) => 0,
1970+
LoadFastLoadFast { .. } => 0,
1971+
LoadFromDictOrGlobals(_) => 0,
1972+
SetUpdate { .. } => 0,
1973+
MakeCell(_) => 0,
1974+
LoadSuperAttr { .. } => 0,
1975+
StoreFastStoreFast { .. } => 0,
1976+
PopJumpIfNone { .. } => 0,
1977+
PopJumpIfNotNone { .. } => 0,
19541978
}
19551979
}
19561980

@@ -2096,7 +2120,7 @@ impl Instruction {
20962120
}
20972121
LoadAttrMethod { idx } => w!(LOAD_ATTR_METHOD, name = idx),
20982122
LoadBuildClass => w!(LOAD_BUILD_CLASS),
2099-
LoadClassDeref(idx) => w!(LOAD_CLASSDEREF, cell_name = idx),
2123+
LoadFromDictOrDeref(i) => w!(LOAD_FROM_DICT_OR_DEREF, cell_name = i),
21002124
LoadClosure(i) => w!(LOAD_CLOSURE, cell_name = i),
21012125
LoadConst { idx } => fmt_const("LOAD_CONST", arg, f, idx),
21022126
LoadDeref(idx) => w!(LOAD_DEREF, cell_name = idx),

crates/stdlib/src/opcode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ mod opcode {
108108
&& matches!(
109109
Instruction::try_from(opcode as u8),
110110
Ok(Instruction::DeleteDeref(_)
111-
| Instruction::LoadClassDeref(_)
111+
| Instruction::LoadFromDictOrDeref(_)
112112
| Instruction::LoadClosure(_)
113113
| Instruction::LoadDeref(_)
114114
| Instruction::StoreDeref(_))

crates/vm/src/frame.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ impl ExecutingFrame<'_> {
11121112
self.push_value(vm.builtins.get_attr(identifier!(vm, __build_class__), vm)?);
11131113
Ok(None)
11141114
}
1115-
bytecode::Instruction::LoadClassDeref(i) => {
1115+
bytecode::Instruction::LoadFromDictOrDeref(i) => {
11161116
let i = i.get(arg) as usize;
11171117
let name = if i < self.code.cellvars.len() {
11181118
self.code.cellvars[i]

0 commit comments

Comments
 (0)