Skip to content

gh-115999: Introduce helpers for (un)specializing instructions - #126414

Merged
mpage merged 1 commit into
python:mainfrom
mpage:gh-115999-refactor-spec-helpers
Nov 6, 2024
Merged

mpage merged 1 commit into
python:mainfrom
mpage:gh-115999-refactor-spec-helpers

Conversation

@mpage

@mpage mpage commented Nov 4, 2024 •

Copy link
Copy Markdown
Contributor

Consolidate the code to specialize/unspecialize instructions into two helper functions and use them in _Py_Specialize_BinaryOp. The result is more concise and keeps all of the logic at the point where we decide to specialize/unspecialize an instruction.

If folks are amenable to this change, we can incrementally introduce their use as we work through making each specialization family thread-safe.

Consolidate the code to specialize/unspecialize instructions into
two helper functions and use them in `_Py_Specialize_BinaryOp`.
The resulting code is more concise and keeps all of the logic at
the point where we decide to specialize/unspecialize an instruction.

If folks are amenable to this change, we can incrementally introduce
their use as we work through making each specialization family
thread-safe.

@markshannon 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.

Looks good

@mpage
mpage merged commit 9ce4fa0 into python:main Nov 6, 2024
@mpage
mpage deleted the gh-115999-refactor-spec-helpers branch November 6, 2024 20:04
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Nov 6, 2024
@freakboy3742

Copy link
Copy Markdown
Contributor

Not sure what is going on here, but this has caused a mass failure of buildbots... I'm seeing it on the iOS buildbot, where it's failing to build the macOS host build, before it even gets to the iOS build:

gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall    -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden  -I../../Include/internal -I../../Include/internal/mimalloc -IObjects -IInclude -IPython -I. -I../../Include    -DPy_BUILD_CORE -o Python/specialize.o ../../Python/specialize.c
../../Python/specialize.c:2801:5: error: call to undeclared function 'SET_OPCODE_OR_RETURN'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    SET_OPCODE_OR_RETURN(instr, CONTAINS_OP);
    ^
1 error generated.
make: *** [Python/specialize.o] Error 1
program finished with exit code 2
elapsedTime=28.356593
@colesbury

Copy link
Copy Markdown
Contributor

@freakboy3742 - it's fixed in main now (by @Eclips4)

@mpage

mpage commented Nov 6, 2024

Copy link
Copy Markdown
Contributor Author

Not sure what is going on here, but this has caused a mass failure of buildbots... I'm seeing it on the iOS buildbot, where it's failing to build the macOS host build, before it even gets to the iOS build:

gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall    -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden  -I../../Include/internal -I../../Include/internal/mimalloc -IObjects -IInclude -IPython -I. -I../../Include    -DPy_BUILD_CORE -o Python/specialize.o ../../Python/specialize.c
../../Python/specialize.c:2801:5: error: call to undeclared function 'SET_OPCODE_OR_RETURN'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    SET_OPCODE_OR_RETURN(instr, CONTAINS_OP);
    ^
1 error generated.
make: *** [Python/specialize.o] Error 1
program finished with exit code 2
elapsedTime=28.356593

Sorry this was my fault. I merged this after #126450 was merged, without merging main into this PR first. This should be fixed by #126517.

picnixz pushed a commit to picnixz/cpython that referenced this pull request Dec 8, 2024
…ython#126414)

Introduce helpers for (un)specializing instructions

Consolidate the code to specialize/unspecialize instructions into
two helper functions and use them in `_Py_Specialize_BinaryOp`.
The resulting code is more concise and keeps all of the logic at
the point where we decide to specialize/unspecialize an instruction.
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
…ython#126414)

Introduce helpers for (un)specializing instructions

Consolidate the code to specialize/unspecialize instructions into
two helper functions and use them in `_Py_Specialize_BinaryOp`.
The resulting code is more concise and keeps all of the logic at
the point where we decide to specialize/unspecialize an instruction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

5 participants