8000 [mypyc] Inline increfs and decrefs in commonly executed blocks by JukkaL · Pull Request #11540 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

[mypyc] Inline increfs and decrefs in commonly executed blocks #11540

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Minor refactoring
  • Loading branch information
JukkaL committed Nov 13, 2021
commit 620f82d8a7ccc04530b6cee06061dd6b9efc68e9
4 changes: 2 additions & 2 deletions mypyc/analysis/blockfreq.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Find basic blocks that are likely to be executed commonly.
"""Find basic blocks that are likely to be executed frequently.

For example, this would not include blocks that have exception handlers.

Expand All @@ -12,7 +12,7 @@
from mypyc.ir.ops import BasicBlock, Goto, Branch


def commonly_executed_blocks(entry_point: BasicBlock) -> Set[BasicBlock]:
def frequently_executed_blocks(entry_point: BasicBlock) -> Set[BasicBlock]:
result: Set[BasicBlock] = set()
worklist = [entry_point]
while worklist:
Expand Down
4 changes: 2 additions & 2 deletions mypyc/codegen/emitfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from mypyc.ir.func_ir import FuncIR, FuncDecl, FUNC_STATICMETHOD, FUNC_CLASSMETHOD, all_values
from mypyc.ir.class_ir import ClassIR
from mypyc.ir.pprint import generate_names_for_ir
from mypyc.analysis.blockfreq import commonly_executed_blocks
from mypyc.analysis.blockfreq import frequently_executed_blocks

# Whether to insert debug asserts for all error handling, to quickly
# catch errors propagating without exceptions set.
Expand Down Expand Up @@ -78,7 +78,7 @@ def generate_native_function(fn: FuncIR,
for i, block in enumerate(blocks):
block.label = i

common = commonly_executed_blocks(fn.blocks[0])
common = frequently_executed_blocks(fn.blocks[0])

for i in range(len(blocks)):
block = blocks[i]
Expand Down
4 changes: 2 additions & 2 deletions mypyc/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ICODE_GEN_BUILTINS, use_custom_builtins, MypycDataSuite, build_ir_for_single_file,
assert_test_output, remove_comment_lines
)
from mypyc.analysis.blockfreq import commonly_executed_blocks
from mypyc.analysis.blockfreq import frequently_executed_blocks

files = [
'exceptions.test',
Expand Down Expand Up @@ -49,7 +49,7 @@ def run_case(self, testcase: DataDrivenTestCase) -> None:
insert_ref_count_opcodes(fn)
actual.extend(format_func(fn))
if testcase.name.endswith('_freq'):
common = commonly_executed_blocks(fn.blocks[0])< 4ACB /td>
common = frequently_executed_blocks(fn.blocks[0])
actual.append('hot blocks: %s' % sorted(b.label for b in common))

assert_test_output(testcase, actual, 'Invalid source code output',
Expand Down
0