Skip to content

Commit 95abec4

Browse files
authored
More Load instructions including LoadLocals, LoadFastBorrow (#6886)
* fix stdlib_io * more scpell dict * LoadLocals * LoadFastBorrow * more ops
1 parent e363b14 commit 95abec4

File tree

12 files changed

+430
-30
lines changed

12 files changed

+430
-30
lines changed

.cspell.dict/cpython.txt

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,184 @@
1+
ADDOP
2+
aftersign
3+
argdefs
14
argtypes
25
asdl
36
asname
47
attro
58
augassign
69
badcert
710
badsyntax
11+
baseinfo
812
basetype
913
boolop
14+
BUILDSTDLIB
1015
bxor
16+
byteswap
1117
cached_tsver
1218
cadata
1319
cafile
20+
calldepth
21+
callinfo
22+
callproc
23+
capath
24+
carg
1425
cellarg
1526
cellvar
1627
cellvars
28+
cfield
1729
CLASSDEREF
30+
classdict
1831
cmpop
32+
codedepth
33+
CODEUNIT
34+
CONVFUNC
35+
convparam
36+
copyslot
37+
cpucount
38+
defaultdict
1939
denom
40+
dictbytype
2041
DICTFLAG
2142
dictoffset
2243
distpoint
44+
dynload
2345
elts
46+
eofs
47+
evalloop
2448
excepthandler
49+
exceptiontable
50+
fblock
51+
fblocks
52+
fdescr
53+
ffi_argtypes
54+
fielddesc
55+
fieldlist
2556
fileutils
2657
finalbody
58+
flowgraph
2759
formatfloat
2860
freevar
2961
freevars
3062
fromlist
63+
getdict
64+
getfunc
65+
getiter
66+
getsets
67+
getslice
68+
globalgetvar
69+
HASARRAY
70+
HASBITFIELD
71+
HASPOINTER
72+
HASSTRUCT
73+
HASUNION
3174
heaptype
3275
HIGHRES
76+
IFUNC
3377
IMMUTABLETYPE
3478
INCREF
79+
inlinedepth
3580
inplace
3681
ismine
82+
ISPOINTER
83+
iteminfo
3784
Itertool
3885
keeped
3986
kwnames
4087
kwonlyarg
4188
kwonlyargs
4289
lasti
90+
libffi
4391
linearise
92+
lineiterator
93+
linetable
94+
loadfast
95+
localsplus
4496
Lshift
4597
lsprof
98+
MAXBLOCKS
4699
maxdepth
100+
metavars
101+
miscompiles
47102
mult
48103
multibytecodec
104+
nameop
105+
nconsts
106+
newargs
107+
newfree
108+
NEWLOCALS
49109
newsemlockobject
110+
nfrees
50111
nkwargs
51112
nkwelts
113+
Nondescriptor
114+
noninteger
115+
nops
52116
noraise
117+
nseen
118+
NSIGNALS
53119
numer
120+
opname
121+
opnames
54122
orelse
123+
outparam
124+
outparm
125+
paramfunc
126+
parg
55127
pathconfig
56128
patma
129+
peepholer
57130
phcount
58131
platstdlib
59132
posonlyarg
60133
posonlyargs
61134
prec
62135
preinitialized
136+
pybuilddir
137+
pycore
63138
pydecimal
139+
Pyfunc
64140
pymain
65141
pyrepl
142+
PYTHONTRACEMALLOC
66143
pythonw
67144
PYTHREAD_NAME
68145
releasebuffer
69146
repr
147+
resinfo
70148
Rshift
71149
SA_ONSTACK
150+
scls
151+
setdict
152+
setfunc
153+
SETREF
154+
setresult
155+
setslice
156+
SLOTDEFINED
72157
SOABI
158+
SSLEOF
73159
stackdepth
160+
staticbase
74161
stginfo
162+
storefast
75163
stringlib
76164
structseq
77165
subkwargs
78166
subparams
79167
subscr
168+
sval
80169
swappedbytes
170+
templatelib
81171
ticketer
172+
tmptype
82173
tok_oldval
83174
tvars
175+
typeobject
176+
typeparam
177+
Typeparam
178+
typeparams
179+
typeslots
84180
unaryop
181+
Unhandle
85182
unparse
86183
unparser
87184
VARKEYWORDS

.cspell.dict/python-more.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,29 @@ xmlcharrefreplace
272272
xoptions
273273
xopts
274274
yieldfrom
275+
addcompare
276+
altzone
277+
classmethods
278+
ctype
279+
ctypes
280+
genexpressions
281+
getargs
282+
getopt
283+
getweakref
284+
getweakrefs
285+
inittab
286+
Inittab
287+
interpchannels
288+
interpqueues
289+
markupbase
290+
mymodule
291+
pydatetime
292+
pyio
293+
pymain
294+
setprofileallthreads
295+
settraceallthreads
296+
sitebuiltins
297+
subclassing
298+
subpatterns
299+
sysdict
300+
weakrefset

.cspell.dict/rust-more.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ hexf
2828
hexversion
2929
idents
3030
illumos
31+
ilog
3132
indexmap
3233
insta
3334
keccak
@@ -86,4 +87,7 @@ wasmer
8687
wasmtime
8788
widestring
8889
winapi
90+
winresource
8991
winsock
92+
bitvec
93+
Bitvec

.cspell.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@
6969
"GetSet",
7070
"groupref",
7171
"internable",
72+
"interps",
7273
"jitted",
7374
"jitting",
7475
"lossily",
7576
"makeunicodedata",
77+
"microbenchmark",
78+
"microbenchmarks",
7679
"miri",
7780
"notrace",
7881
"oparg",
@@ -121,6 +124,7 @@
121124
"uninit",
122125
"unraisable",
123126
"unresizable",
127+
"varint",
124128
"wasi",
125129
"zelf",
126130
// unix

Lib/test/test_peepholer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,6 @@ def f():
10021002
self.assertInBytecode(f, 'LOAD_FAST_CHECK', "a73")
10031003
self.assertInBytecode(f, 'LOAD_FAST_BORROW', "a73")
10041004

1005-
@unittest.expectedFailure # TODO: RUSTPYTHON
10061005
def test_setting_lineno_no_undefined(self):
10071006
code = textwrap.dedent("""\
10081007
def f():
@@ -1123,7 +1122,6 @@ def f():
11231122
self.assertNotInBytecode(f, "LOAD_FAST_CHECK")
11241123
return f
11251124

1126-
@unittest.expectedFailure # TODO: RUSTPYTHON
11271125
def test_modifying_local_does_not_add_check(self):
11281126
f = self.make_function_with_no_checks()
11291127
def trace(frame, event, arg):
@@ -1137,7 +1135,6 @@ def trace(frame, event, arg):
11371135
self.assertInBytecode(f, "LOAD_FAST_BORROW")
11381136
self.assertNotInBytecode(f, "LOAD_FAST_CHECK")
11391137

1140-
@unittest.expectedFailure # TODO: RUSTPYTHON
11411138
def test_initializing_local_does_not_add_check(self):
11421139
f = self.make_function_with_no_checks()
11431140
def trace(frame, event, arg):

crates/codegen/src/compile.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2048,8 +2048,14 @@ impl Compiler {
20482048

20492049
let op = match usage {
20502050
NameUsage::Load => {
2051-
// Special case for class scope
2051+
// ClassBlock (not inlined comp): LOAD_LOCALS first, then LOAD_FROM_DICT_OR_DEREF
20522052
if self.ctx.in_class && !self.ctx.in_func() {
2053+
emit!(self, Instruction::LoadLocals);
2054+
Instruction::LoadFromDictOrDeref
2055+
// can_see_class_scope: LOAD_DEREF(__classdict__) first
2056+
} else if can_see_class_scope {
2057+
let classdict_idx = self.get_free_var_index("__classdict__")?;
2058+
self.emit_arg(classdict_idx, Instruction::LoadDeref);
20532059
Instruction::LoadFromDictOrDeref
20542060
} else {
20552061
Instruction::LoadDeref

0 commit comments

Comments
 (0)