Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 131 additions & 48 deletions Lib/dis.py

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
"HAVE_ARGUMENT", "EXTENDED_ARG", "hasarg", "hasconst", "hasname",
"hasjump", "hasjrel", "hasjabs", "hasfree", "haslocal", "hasexc"]

import builtins
import _opcode
from _opcode import stack_effect

from _opcode_metadata import (_specializations, _specialized_opmap, opmap,
HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE)
from _opcode_metadata import (_specializations, _specialized_opmap, opmap, # noqa: F401
HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE) # noqa: F401
EXTENDED_ARG = opmap['EXTENDED_ARG']

opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)]
for op, i in opmap.items():
opname[i] = op
for m in (opmap, _specialized_opmap):
for op, i in m.items():
opname[i] = op

cmp_op = ('<', '<=', '==', '!=', '>', '>=')

Expand All @@ -36,6 +38,9 @@

_intrinsic_1_descs = _opcode.get_intrinsic1_descs()
_intrinsic_2_descs = _opcode.get_intrinsic2_descs()
_special_method_names = _opcode.get_special_method_names()
_common_constants = [builtins.AssertionError, builtins.NotImplementedError,
builtins.tuple, builtins.all, builtins.any]
_nb_ops = _opcode.get_nb_ops()

hascompare = [opmap["COMPARE_OP"]]
Expand All @@ -49,6 +54,7 @@
},
"BINARY_OP": {
"counter": 1,
"descr": 4,
},
"UNPACK_SEQUENCE": {
"counter": 1,
Expand All @@ -59,9 +65,6 @@
"CONTAINS_OP": {
"counter": 1,
},
"BINARY_SUBSCR": {
"counter": 1,
},
"FOR_ITER": {
"counter": 1,
},
Expand All @@ -83,6 +86,10 @@
"counter": 1,
"func_version": 2,
},
"CALL_KW": {
"counter": 1,
"func_version": 2,
},
"STORE_SUBSCR": {
"counter": 1,
},
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test__opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_is_valid(self):
opcodes = [dis.opmap[opname] for opname in names]
self.check_bool_function_result(_opcode.is_valid, opcodes, True)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON; KeyError: 'BINARY_OP_ADD_INT'
def test_opmaps(self):
def check_roundtrip(name, map):
return self.assertEqual(opcode.opname[map[name]], name)
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_stack_effect_jump(self):


class SpecializationStatsTests(unittest.TestCase):
@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: 'load_attr' not found in []
def test_specialization_stats(self):
stat_names = ["success", "failure", "hit", "deferred", "miss", "deopt"]
specialized_opcodes = [
Expand Down
4 changes: 0 additions & 4 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ def test_indentation(self):
pass"""
compile(s, "<string>", "exec")

# TODO: RUSTPYTHON
@unittest.expectedFailure
# This test is probably specific to CPython and may not generalize
# to other implementations. We are trying to ensure that when
# the first line of code starts after 256, correct line numbers
Expand Down Expand Up @@ -928,8 +926,6 @@ def save_caller_frame():
func(save_caller_frame)
self.assertEqual(frame.f_lineno-frame.f_code.co_firstlineno, lastline)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_lineno_after_no_code(self):
def no_code1():
"doc string"
Expand Down
Loading
Loading