Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-105481: Generate the opcode lists in dis from data extracted from bytecodes.c#106758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
iritkatriel merged 30 commits intopython:mainfromiritkatriel:opcode_py
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
30 commits
Select commitHold shift + click to select a range
36a7d56
gh-105481: add haslocal to _opcode.py. Generate most oplists in opcod…
iritkatrielJul 14, 2023
75019ca
added HAS_FREE flag. Removed HAS_FREE from the HAS_LOCAL list
iritkatrielJul 14, 2023
494680a
add hasjump, soft deprecate hasjrel and hasjabs. Fix build bug
iritkatrielJul 15, 2023
24786fb
generate hasexc from the C macros instead of defining it again
iritkatrielJul 15, 2023
563b431
typo
iritkatrielJul 15, 2023
227756f
Merge remote-tracking branch 'upstream/main' into opcode_py
iritkatrielJul 17, 2023
1b13b96
ascii quotes
iritkatrielJul 17, 2023
0f5ae32
make clinic
iritkatrielJul 17, 2023
289fad1
remove oplists
iritkatrielJul 17, 2023
598ba2a
import less from opcode in build script. _opcode.has_* don't exist pr…
iritkatrielJul 17, 2023
d2d355e
hascompare in old versions as well
iritkatrielJul 17, 2023
27eb2cc
remove redundant init
iritkatrielJul 17, 2023
998024a
📜🤖 Added by blurb_it.
blurb-it[bot]Jul 17, 2023
ffa4ee3
Merge branch 'main' into opcode_py
iritkatrielJul 17, 2023
ce76a60
remove unnecessary comment
iritkatrielJul 17, 2023
4194a12
make the tests more precise
iritkatrielJul 17, 2023
6b8c46b
sort the lists
iritkatrielJul 17, 2023
e15f7d5
address some of the code review comments
iritkatrielJul 18, 2023
21fe0a4
remove hard-coded lists from the tests
iritkatrielJul 18, 2023
75795db
remove opcode metadata file from generated files list so diff are vis…
iritkatrielJul 18, 2023
1a0a2b2
import _opcode directly into dis, rather than via opcode
iritkatrielJul 18, 2023
f530469
add stack effect to dis.__all__
iritkatrielJul 18, 2023
71ffe34
Merge branch 'main' into opcode_py
iritkatrielJul 18, 2023
d525c53
import _specializations, _specialized_instructions directly from _opc…
iritkatrielJul 18, 2023
5e1c4a4
update Tools/scripts/summarize_stats.py to use _opcode_metadata inste…
iritkatrielJul 18, 2023
6077263
Revert "update Tools/scripts/summarize_stats.py to use _opcode_metada…
iritkatrielJul 18, 2023
98ba11f
Revert "import _specializations, _specialized_instructions directly f…
iritkatrielJul 18, 2023
cc8e5e1
Revert "add stack effect to dis.__all__"
iritkatrielJul 18, 2023
31dbfec
Revert "import _opcode directly into dis, rather than via opcode"
iritkatrielJul 18, 2023
1abf6ca
Merge branch 'main' into opcode_py
iritkatrielJul 18, 2023
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
PrevPrevious commit
NextNext commit
Revert "import _specializations, _specialized_instructions directly f…
…rom _opcode_metadata rather than via opcode"This reverts commitd525c53.
  • Loading branch information
@iritkatriel
iritkatriel committedJul 18, 2023
commit98ba11f545483d3ec3984531ef37849d64877e31
4 changes: 2 additions & 2 deletionsLib/dis.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,10 +15,10 @@
_nb_ops,
_intrinsic_1_descs,
_intrinsic_2_descs,
_specializations,
_specialized_instructions,
)

from _opcode_metadata import _specializations, _specialized_instructions

__all__ = ["hasarg", "hasconst", "hasname", "hasjump", "hasjrel",
"hasjabs", "hasfree", "haslocal", "hasexc", "hascompare",
"stack_effect", "code_info", "dis", "disassemble", "distb",
Expand Down
5 changes: 5 additions & 0 deletionsLib/opcode.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,11 @@

__all__ = ["cmp_op", "opname", "opmap", "HAVE_ARGUMENT", "EXTENDED_ARG"]

import sys
# The build uses older versions of Python which do not have _opcode_metadata
if sys.version_info[:2] >= (3, 13):
from _opcode_metadata import _specializations, _specialized_instructions

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


Expand Down
3 changes: 1 addition & 2 deletionsLib/test/test__opcode.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@
from test.support.import_helper import import_module
import unittest
import opcode
import _opcode_metadata

_opcode = import_module("_opcode")
from _opcode import stack_effect
Expand DownExpand Up@@ -106,7 +105,7 @@ def test_specialization_stats(self):
stat_names = ["success", "failure", "hit", "deferred", "miss", "deopt"]
specialized_opcodes = [
op.lower()
for op in_opcode_metadata._specializations
for op inopcode._specializations
if opcode._inline_cache_entries[opcode.opmap[op]]
]
self.assertIn('load_attr', specialized_opcodes)
Expand Down
5 changes: 2 additions & 3 deletionsLib/test/test_dis.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,6 @@
from test.support.bytecode_helper import BytecodeTestCase

import opcode
import _opcode_metadata


def get_tb():
Expand DownExpand Up@@ -1940,12 +1939,12 @@ def test_baseopname_and_baseopcode(self):
self.assertEqual(code, baseopcode)

# Specialized instructions
for name in_opcode_metadata._specialized_instructions:
for name inopcode._specialized_instructions:
instruction = Instruction(opname=name, opcode=dis._all_opmap[name], arg=None, argval=None, argrepr='',
offset=0, start_offset=0, starts_line=1, is_jump_target=False, positions=None)
baseopname = instruction.baseopname
baseopcode = instruction.baseopcode
self.assertIn(name,_opcode_metadata._specializations[baseopname])
self.assertIn(name,opcode._specializations[baseopname])
self.assertEqual(opcode.opmap[baseopname], baseopcode)

def test_jump_target(self):
Expand Down
4 changes: 2 additions & 2 deletionsLib/test/test_embed.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -354,14 +354,14 @@ def test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE(self):
code = textwrap.dedent("""\
import dis
import importlib._bootstrap
import_opcode_metadata
importopcode
import test.test_dis

def is_specialized(f):
for instruction in dis.get_instructions(f, adaptive=True):
opname = instruction.opname
if (
opname in_opcode_metadata._specialized_instructions
opname inopcode._specialized_instructions
# Exclude superinstructions:
and "__" not in opname
):
Expand Down

[8]ページ先頭

©2009-2026 Movatter.jp