FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-87092: refactor assemble() to a number of separate functions, which do not need the compiler struct by iritkatriel · Pull Request #102562 · python/cpython · GitHub

/ cpython Public

gh-87092: refactor assemble() to a number of separate functions, which do not need the compiler struct - #102562

Merged
iritkatriel merged 10 commits into
python:mainfrom
iritkatriel:decouple_assembler
Mar 13, 2023
Merged

gh-87092: refactor assemble() to a number of separate functions, which do not need the compiler struct#102562
iritkatriel merged 10 commits into
python:mainfrom
iritkatriel:decouple_assembler

Conversation

iritkatriel commented Mar 9, 2023
edited
Loading

Copy link
Copy Markdown
Member

This PR:

  1. further breaks up the assemble() function, and extracts out of it the optimize_code_unit(), assemble_code_unit(), assemble_emit() and resolve_line_numbers() steps into separate functions.
  2. passes less stuff around (namely, not passing the whole compiler struct but only what is needed).
  3. unit tests (_PyCompile_OptimizeCfg ) run all of optimize_code_unit(), not just optimize_cfg(), so we can test dead code removal, unused const removal, hot/cold code arrangements, etc.
  4. _PyCompile_CodeGen no longer constructs a cfg.

iritkatriel added skip news interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 9, 2023
iritkatriel changed the title gh-87092: refactor the optimization stage out assemble() to a separate function, which does not need the compiler struct gh-87092: refactor the optimization stage of assemble() to a separate function, which does not need the compiler struct Mar 9, 2023
iritkatriel changed the title gh-87092: refactor the optimization stage of assemble() to a separate function, which does not need the compiler struct gh-87092: refactor assemble() to a number of separate functions, which do not need the compiler struct Mar 10, 2023

markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks reasonable. A couple of questions.

Comment thread Lib/test/support/bytecode_helper.py Outdated
arg = oparg.value
else:
arg = oparg if opcode in self.HAS_ARG else None
arg = oparg if opcode in self.HAS_ARG else 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why? And why do some of the 'NOP's below in test_peepholer.py have a None operand and some have 0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yeah, that was just messy. I've tidied it up now. Thanks.

iritkatriel merged commit 634cb61 into python:main Mar 13, 2023
carljm added a commit to carljm/cpython that referenced this pull request Mar 14, 2023
* main: (50 commits)
  pythongh-102674: Remove _specialization_stats from Lib/opcode.py (python#102685)
  pythongh-102660: Handle m_copy Specially for the sys and builtins Modules (pythongh-102661)
  pythongh-102354: change python3 to python in docs examples (python#102696)
  pythongh-81057: Add a CI Check for New Unsupported C Global Variables (pythongh-102506)
  pythonGH-94851: check unicode consistency of static strings in debug mode (python#102684)
  pythongh-100315: clarification to `__slots__` docs. (python#102621)
  pythonGH-100227: cleanup initialization of global interned dict (python#102682)
  doc: Remove a duplicate 'versionchanged' in library/asyncio-task (pythongh-102677)
  pythongh-102013: Add PyUnstable_GC_VisitObjects (python#102014)
  pythonGH-102670: Use sumprod() to simplify, speed up, and improve accuracy of statistics functions (pythonGH-102649)
  pythongh-102627: Replace address pointing toward malicious web page (python#102630)
  pythongh-98831: Use DECREF_INPUTS() more (python#102409)
  pythongh-101659: Avoid Allocation for Shared Exceptions in the _xxsubinterpreters Module (pythongh-102659)
  pythongh-101524: Fix the ChannelID tp_name (pythongh-102655)
  pythongh-102069: Fix `__weakref__` descriptor generation for custom dataclasses (python#102075)
  pythongh-98169 dataclasses.astuple support DefaultDict (python#98170)
  pythongh-102650: Remove duplicate include directives from multiple source files (python#102651)
  pythonGH-100987: Don't cache references to the names and consts array in `_PyEval_EvalFrameDefault`. (python#102640)
  pythongh-87092: refactor assemble() to a number of separate functions, which do not need the compiler struct (python#102562)
  pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (python#102631)
  ...
iritkatriel deleted the decouple_assembler branch March 19, 2023 11:51
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL