0
0
mirror of https://github.com/python/cpython.git synced 2024-11-24 00:38:00 +01:00

gh-121554: remove unnecessary internal functions in compile.c (#121555)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
This commit is contained in:
Irit Katriel 2024-07-10 23:48:37 +01:00 committed by GitHub
parent ef10110cd7
commit 6557af6698
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 12 additions and 105 deletions

View File

@ -76,15 +76,6 @@ int _PyCompile_ConstCacheMergeOne(PyObject *const_cache, PyObject **obj);
// Export for '_opcode' extension module // Export for '_opcode' extension module
PyAPI_FUNC(int) _PyCompile_OpcodeIsValid(int opcode);
PyAPI_FUNC(int) _PyCompile_OpcodeHasArg(int opcode);
PyAPI_FUNC(int) _PyCompile_OpcodeHasConst(int opcode);
PyAPI_FUNC(int) _PyCompile_OpcodeHasName(int opcode);
PyAPI_FUNC(int) _PyCompile_OpcodeHasJump(int opcode);
PyAPI_FUNC(int) _PyCompile_OpcodeHasFree(int opcode);
PyAPI_FUNC(int) _PyCompile_OpcodeHasLocal(int opcode);
PyAPI_FUNC(int) _PyCompile_OpcodeHasExc(int opcode);
PyAPI_FUNC(PyObject*) _PyCompile_GetUnaryIntrinsicName(int index); PyAPI_FUNC(PyObject*) _PyCompile_GetUnaryIntrinsicName(int index);
PyAPI_FUNC(PyObject*) _PyCompile_GetBinaryIntrinsicName(int index); PyAPI_FUNC(PyObject*) _PyCompile_GetBinaryIntrinsicName(int index);

View File

@ -30,6 +30,7 @@ _weakref _weakref.c
_abc _abc.c _abc _abc.c
_functools _functoolsmodule.c _functools _functoolsmodule.c
_locale _localemodule.c _locale _localemodule.c
_opcode _opcode.c
_operator _operator.c _operator _operator.c
_stat _stat.c _stat _stat.c
_symtable symtablemodule.c _symtable symtablemodule.c

View File

@ -36,7 +36,6 @@
@MODULE__HEAPQ_TRUE@_heapq _heapqmodule.c @MODULE__HEAPQ_TRUE@_heapq _heapqmodule.c
@MODULE__JSON_TRUE@_json _json.c @MODULE__JSON_TRUE@_json _json.c
@MODULE__LSPROF_TRUE@_lsprof _lsprof.c rotatingtree.c @MODULE__LSPROF_TRUE@_lsprof _lsprof.c rotatingtree.c
@MODULE__OPCODE_TRUE@_opcode _opcode.c
@MODULE__PICKLE_TRUE@_pickle _pickle.c @MODULE__PICKLE_TRUE@_pickle _pickle.c
@MODULE__QUEUE_TRUE@_queue _queuemodule.c @MODULE__QUEUE_TRUE@_queue _queuemodule.c
@MODULE__RANDOM_TRUE@_random _randommodule.c @MODULE__RANDOM_TRUE@_random _randommodule.c

View File

@ -10,6 +10,8 @@
#include "pycore_compile.h" #include "pycore_compile.h"
#include "pycore_intrinsics.h" #include "pycore_intrinsics.h"
#include "pycore_optimizer.h" // _Py_GetExecutor() #include "pycore_optimizer.h" // _Py_GetExecutor()
#include "pycore_opcode_metadata.h" // IS_VALID_OPCODE, OPCODE_HAS_*, etc
#include "pycore_opcode_utils.h"
/*[clinic input] /*[clinic input]
module _opcode module _opcode
@ -81,7 +83,7 @@ static int
_opcode_is_valid_impl(PyObject *module, int opcode) _opcode_is_valid_impl(PyObject *module, int opcode)
/*[clinic end generated code: output=b0d918ea1d073f65 input=fe23e0aa194ddae0]*/ /*[clinic end generated code: output=b0d918ea1d073f65 input=fe23e0aa194ddae0]*/
{ {
return _PyCompile_OpcodeIsValid(opcode); return IS_VALID_OPCODE(opcode);
} }
/*[clinic input] /*[clinic input]
@ -97,8 +99,7 @@ static int
_opcode_has_arg_impl(PyObject *module, int opcode) _opcode_has_arg_impl(PyObject *module, int opcode)
/*[clinic end generated code: output=7a062d3b2dcc0815 input=93d878ba6361db5f]*/ /*[clinic end generated code: output=7a062d3b2dcc0815 input=93d878ba6361db5f]*/
{ {
return _PyCompile_OpcodeIsValid(opcode) && return IS_VALID_OPCODE(opcode) && OPCODE_HAS_ARG(opcode);
_PyCompile_OpcodeHasArg(opcode);
} }
/*[clinic input] /*[clinic input]
@ -114,8 +115,7 @@ static int
_opcode_has_const_impl(PyObject *module, int opcode) _opcode_has_const_impl(PyObject *module, int opcode)
/*[clinic end generated code: output=c646d5027c634120 input=a6999e4cf13f9410]*/ /*[clinic end generated code: output=c646d5027c634120 input=a6999e4cf13f9410]*/
{ {
return _PyCompile_OpcodeIsValid(opcode) && return IS_VALID_OPCODE(opcode) && OPCODE_HAS_CONST(opcode);
_PyCompile_OpcodeHasConst(opcode);
} }
/*[clinic input] /*[clinic input]
@ -131,8 +131,7 @@ static int
_opcode_has_name_impl(PyObject *module, int opcode) _opcode_has_name_impl(PyObject *module, int opcode)
/*[clinic end generated code: output=b49a83555c2fa517 input=448aa5e4bcc947ba]*/ /*[clinic end generated code: output=b49a83555c2fa517 input=448aa5e4bcc947ba]*/
{ {
return _PyCompile_OpcodeIsValid(opcode) && return IS_VALID_OPCODE(opcode) && OPCODE_HAS_NAME(opcode);
_PyCompile_OpcodeHasName(opcode);
} }
/*[clinic input] /*[clinic input]
@ -148,9 +147,7 @@ static int
_opcode_has_jump_impl(PyObject *module, int opcode) _opcode_has_jump_impl(PyObject *module, int opcode)
/*[clinic end generated code: output=e9c583c669f1c46a input=35f711274357a0c3]*/ /*[clinic end generated code: output=e9c583c669f1c46a input=35f711274357a0c3]*/
{ {
return _PyCompile_OpcodeIsValid(opcode) && return IS_VALID_OPCODE(opcode) && OPCODE_HAS_JUMP(opcode);
_PyCompile_OpcodeHasJump(opcode);
} }
/*[clinic input] /*[clinic input]
@ -171,9 +168,7 @@ static int
_opcode_has_free_impl(PyObject *module, int opcode) _opcode_has_free_impl(PyObject *module, int opcode)
/*[clinic end generated code: output=d81ae4d79af0ee26 input=117dcd5c19c1139b]*/ /*[clinic end generated code: output=d81ae4d79af0ee26 input=117dcd5c19c1139b]*/
{ {
return _PyCompile_OpcodeIsValid(opcode) && return IS_VALID_OPCODE(opcode) && OPCODE_HAS_FREE(opcode);
_PyCompile_OpcodeHasFree(opcode);
} }
/*[clinic input] /*[clinic input]
@ -189,8 +184,7 @@ static int
_opcode_has_local_impl(PyObject *module, int opcode) _opcode_has_local_impl(PyObject *module, int opcode)
/*[clinic end generated code: output=da5a8616b7a5097b input=9a798ee24aaef49d]*/ /*[clinic end generated code: output=da5a8616b7a5097b input=9a798ee24aaef49d]*/
{ {
return _PyCompile_OpcodeIsValid(opcode) && return IS_VALID_OPCODE(opcode) && OPCODE_HAS_LOCAL(opcode);
_PyCompile_OpcodeHasLocal(opcode);
} }
/*[clinic input] /*[clinic input]
@ -206,8 +200,7 @@ static int
_opcode_has_exc_impl(PyObject *module, int opcode) _opcode_has_exc_impl(PyObject *module, int opcode)
/*[clinic end generated code: output=41b68dff0ec82a52 input=db0e4bdb9bf13fa5]*/ /*[clinic end generated code: output=41b68dff0ec82a52 input=db0e4bdb9bf13fa5]*/
{ {
return _PyCompile_OpcodeIsValid(opcode) && return IS_VALID_OPCODE(opcode) && IS_BLOCK_PUSH_OPCODE(opcode);
_PyCompile_OpcodeHasExc(opcode);
} }
/*[clinic input] /*[clinic input]
@ -424,7 +417,7 @@ opcode_functions[] = {
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
int static int
_opcode_exec(PyObject *m) { _opcode_exec(PyObject *m) {
if (PyModule_AddIntMacro(m, ENABLE_SPECIALIZATION) < 0) { if (PyModule_AddIntMacro(m, ENABLE_SPECIALIZATION) < 0) {
return -1; return -1;

View File

@ -665,54 +665,6 @@ compiler_set_qualname(struct compiler *c)
return SUCCESS; return SUCCESS;
} }
int
_PyCompile_OpcodeIsValid(int opcode)
{
return IS_VALID_OPCODE(opcode);
}
int
_PyCompile_OpcodeHasArg(int opcode)
{
return OPCODE_HAS_ARG(opcode);
}
int
_PyCompile_OpcodeHasConst(int opcode)
{
return OPCODE_HAS_CONST(opcode);
}
int
_PyCompile_OpcodeHasName(int opcode)
{
return OPCODE_HAS_NAME(opcode);
}
int
_PyCompile_OpcodeHasJump(int opcode)
{
return OPCODE_HAS_JUMP(opcode);
}
int
_PyCompile_OpcodeHasFree(int opcode)
{
return OPCODE_HAS_FREE(opcode);
}
int
_PyCompile_OpcodeHasLocal(int opcode)
{
return OPCODE_HAS_LOCAL(opcode);
}
int
_PyCompile_OpcodeHasExc(int opcode)
{
return IS_BLOCK_PUSH_OPCODE(opcode);
}
static int static int
codegen_addop_noarg(instr_sequence *seq, int opcode, location loc) codegen_addop_noarg(instr_sequence *seq, int opcode, location loc)
{ {

28
configure generated vendored
View File

@ -795,8 +795,6 @@ MODULE__POSIXSUBPROCESS_FALSE
MODULE__POSIXSUBPROCESS_TRUE MODULE__POSIXSUBPROCESS_TRUE
MODULE__PICKLE_FALSE MODULE__PICKLE_FALSE
MODULE__PICKLE_TRUE MODULE__PICKLE_TRUE
MODULE__OPCODE_FALSE
MODULE__OPCODE_TRUE
MODULE__LSPROF_FALSE MODULE__LSPROF_FALSE
MODULE__LSPROF_TRUE MODULE__LSPROF_TRUE
MODULE__JSON_FALSE MODULE__JSON_FALSE
@ -29231,28 +29229,6 @@ then :
fi
if test "$py_cv_module__opcode" != "n/a"
then :
py_cv_module__opcode=yes
fi
if test "$py_cv_module__opcode" = yes; then
MODULE__OPCODE_TRUE=
MODULE__OPCODE_FALSE='#'
else
MODULE__OPCODE_TRUE='#'
MODULE__OPCODE_FALSE=
fi
as_fn_append MODULE_BLOCK "MODULE__OPCODE_STATE=$py_cv_module__opcode$as_nl"
if test "x$py_cv_module__opcode" = xyes
then :
fi fi
@ -31784,10 +31760,6 @@ if test -z "${MODULE__LSPROF_TRUE}" && test -z "${MODULE__LSPROF_FALSE}"; then
as_fn_error $? "conditional \"MODULE__LSPROF\" was never defined. as_fn_error $? "conditional \"MODULE__LSPROF\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi fi
if test -z "${MODULE__OPCODE_TRUE}" && test -z "${MODULE__OPCODE_FALSE}"; then
as_fn_error $? "conditional \"MODULE__OPCODE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${MODULE__PICKLE_TRUE}" && test -z "${MODULE__PICKLE_FALSE}"; then if test -z "${MODULE__PICKLE_TRUE}" && test -z "${MODULE__PICKLE_FALSE}"; then
as_fn_error $? "conditional \"MODULE__PICKLE\" was never defined. as_fn_error $? "conditional \"MODULE__PICKLE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5

View File

@ -7689,7 +7689,6 @@ PY_STDLIB_MOD_SIMPLE([_csv])
PY_STDLIB_MOD_SIMPLE([_heapq]) PY_STDLIB_MOD_SIMPLE([_heapq])
PY_STDLIB_MOD_SIMPLE([_json]) PY_STDLIB_MOD_SIMPLE([_json])
PY_STDLIB_MOD_SIMPLE([_lsprof]) PY_STDLIB_MOD_SIMPLE([_lsprof])
PY_STDLIB_MOD_SIMPLE([_opcode])
PY_STDLIB_MOD_SIMPLE([_pickle]) PY_STDLIB_MOD_SIMPLE([_pickle])
PY_STDLIB_MOD_SIMPLE([_posixsubprocess]) PY_STDLIB_MOD_SIMPLE([_posixsubprocess])
PY_STDLIB_MOD_SIMPLE([_queue]) PY_STDLIB_MOD_SIMPLE([_queue])