Skip to content

Commit bc4583c

Browse files
committed
Add _Py_uop_ prefix to all T2 symbols function names
1 parent 63d087c commit bc4583c

File tree

7 files changed

+307
-295
lines changed

7 files changed

+307
-295
lines changed

Include/internal/pycore_optimizer.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,32 +82,32 @@ struct _Py_UOpsAbstractInterpContext {
8282

8383
typedef struct _Py_UOpsAbstractInterpContext _Py_UOpsAbstractInterpContext;
8484

85-
extern bool sym_is_null(_Py_UOpsSymType *sym);
86-
extern bool sym_is_not_null(_Py_UOpsSymType *sym);
87-
extern bool sym_is_const(_Py_UOpsSymType *sym);
88-
extern PyObject *sym_get_const(_Py_UOpsSymType *sym);
89-
extern _Py_UOpsSymType *sym_new_unknown(_Py_UOpsAbstractInterpContext *ctx);
90-
extern _Py_UOpsSymType *sym_new_known_notnull(_Py_UOpsAbstractInterpContext *ctx);
91-
extern _Py_UOpsSymType *sym_new_known_type(
85+
extern bool _Py_uop_sym_is_null(_Py_UOpsSymType *sym);
86+
extern bool _Py_uop_sym_is_not_null(_Py_UOpsSymType *sym);
87+
extern bool _Py_uop_sym_is_const(_Py_UOpsSymType *sym);
88+
extern PyObject *_Py_uop_sym_get_const(_Py_UOpsSymType *sym);
89+
extern _Py_UOpsSymType *_Py_uop_sym_newunknown(_Py_UOpsAbstractInterpContext *ctx);
90+
extern _Py_UOpsSymType *_Py_uop_sym_new_notnull(_Py_UOpsAbstractInterpContext *ctx);
91+
extern _Py_UOpsSymType *_Py_uop_sym_new_type(
9292
_Py_UOpsAbstractInterpContext *ctx, PyTypeObject *typ);
93-
extern _Py_UOpsSymType *sym_new_const(_Py_UOpsAbstractInterpContext *ctx, PyObject *const_val);
94-
extern _Py_UOpsSymType *sym_new_null(_Py_UOpsAbstractInterpContext *ctx);
95-
extern bool sym_matches_type(_Py_UOpsSymType *sym, PyTypeObject *typ);
96-
extern void sym_set_null(_Py_UOpsSymType *sym);
97-
extern void sym_set_type(_Py_UOpsSymType *sym, PyTypeObject *tp);
93+
extern _Py_UOpsSymType *_Py_uop_sym_newconst(_Py_UOpsAbstractInterpContext *ctx, PyObject *const_val);
94+
extern _Py_UOpsSymType *_Py_uop_sym_newnull(_Py_UOpsAbstractInterpContext *ctx);
95+
extern bool _Py_uop_sym_matches_type(_Py_UOpsSymType *sym, PyTypeObject *typ);
96+
extern void _Py_uop_sym_set_null(_Py_UOpsSymType *sym);
97+
extern void _Py_uop_sym_set_type(_Py_UOpsSymType *sym, PyTypeObject *tp);
9898

99-
extern int abstractcontext_init(
99+
extern int _Py_uop_abstractcontext_init(
100100
_Py_UOpsAbstractInterpContext *ctx, PyCodeObject *co,
101101
int curr_stacklen, int ir_entries);
102-
extern void abstractcontext_fini(_Py_UOpsAbstractInterpContext *ctx);
102+
extern void _Py_uop_abstractcontext_fini(_Py_UOpsAbstractInterpContext *ctx);
103103

104-
extern _Py_UOpsAbstractFrame *ctx_frame_new(
104+
extern _Py_UOpsAbstractFrame *_Py_uop_ctx_frame_new(
105105
_Py_UOpsAbstractInterpContext *ctx,
106106
PyCodeObject *co,
107107
_Py_UOpsSymType **localsplus_start,
108108
int n_locals_already_filled,
109109
int curr_stackentries);
110-
extern int ctx_frame_pop(_Py_UOpsAbstractInterpContext *ctx);
110+
extern int _Py_uop_ctx_frame_pop(_Py_UOpsAbstractInterpContext *ctx);
111111

112112
#ifdef __cplusplus
113113
}

Lib/test/test_generated_cases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ def test_overridden_abstract_args(self):
900900
901901
case OP2: {
902902
_Py_UOpsSymType *out;
903-
out = sym_new_unknown(ctx);
903+
out = _Py_uop_sym_newunknown(ctx);
904904
if (out == NULL) goto out_of_space;
905905
stack_pointer[-1] = out;
906906
break;
@@ -925,7 +925,7 @@ def test_no_overridden_case(self):
925925
output = """
926926
case OP: {
927927
_Py_UOpsSymType *out;
928-
out = sym_new_unknown(ctx);
928+
out = _Py_uop_sym_newunknown(ctx);
929929
if (out == NULL) goto out_of_space;
930930
stack_pointer[-1] = out;
931931
break;

Modules/_testinternalcapi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "pycore_interp.h" // _PyInterpreterState_GetConfigCopy()
2525
#include "pycore_long.h" // _PyLong_Sign()
2626
#include "pycore_object.h" // _PyObject_IsFreed()
27+
#include "pycore_optimizer.h" // _Py_UOpsSymType, etc.
2728
#include "pycore_pathconfig.h" // _PyPathConfig_ClearGlobal()
2829
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
2930
#include "pycore_pystate.h" // _PyThreadState_GET()
@@ -1678,6 +1679,16 @@ get_py_thread_id(PyObject *self, PyObject *Py_UNUSED(ignored))
16781679
#endif
16791680

16801681

1682+
static PyObject *
1683+
test_uop_symbols(PyObject *self, PyObject *Py_UNUSED(ignored))
1684+
{
1685+
_Py_UOpsAbstractInterpContext context;
1686+
_Py_UOpsAbstractInterpContext *ctx = &context;
1687+
_Py_UOpsSymType * unknown = Py_uop_sym_newunknown(ctx);
1688+
1689+
}
1690+
1691+
16811692
static PyMethodDef module_functions[] = {
16821693
{"get_configs", get_configs, METH_NOARGS},
16831694
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
@@ -1747,6 +1758,7 @@ static PyMethodDef module_functions[] = {
17471758
#ifdef Py_GIL_DISABLED
17481759
{"py_thread_id", get_py_thread_id, METH_NOARGS},
17491760
#endif
1761+
{"test_uop_symbols", test_uop_symbols, METH_NOARGS},
17501762
{NULL, NULL} /* sentinel */
17511763
};
17521764

Python/optimizer_analysis.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
277277

278278
#define _LOAD_ATTR_NOT_NULL \
279279
do { \
280-
OUT_OF_SPACE_IF_NULL(attr = sym_new_known_notnull(ctx)); \
281-
OUT_OF_SPACE_IF_NULL(null = sym_new_null(ctx)); \
280+
OUT_OF_SPACE_IF_NULL(attr = _Py_uop_sym_new_notnull(ctx)); \
281+
OUT_OF_SPACE_IF_NULL(null = _Py_uop_sym_newnull(ctx)); \
282282
} while (0);
283283

284284

@@ -296,7 +296,7 @@ uop_redundancy_eliminator(
296296
_Py_UOpsAbstractInterpContext context;
297297
_Py_UOpsAbstractInterpContext *ctx = &context;
298298

299-
if (abstractcontext_init(
299+
if (_Py_uop_abstractcontext_init(
300300
ctx,
301301
co, curr_stacklen,
302302
trace_len) < 0) {
@@ -328,17 +328,17 @@ uop_redundancy_eliminator(
328328
assert(STACK_LEVEL() >= 0);
329329
}
330330

331-
abstractcontext_fini(ctx);
331+
_Py_uop_abstractcontext_fini(ctx);
332332
return 1;
333333

334334
out_of_space:
335335
DPRINTF(1, "Out of space in abstract interpreter\n");
336-
abstractcontext_fini(ctx);
336+
_Py_uop_abstractcontext_fini(ctx);
337337
return 0;
338338

339339
error:
340340
DPRINTF(1, "Encountered error in abstract interpreter\n");
341-
abstractcontext_fini(ctx);
341+
_Py_uop_abstractcontext_fini(ctx);
342342
return 0;
343343
}
344344

0 commit comments

Comments
 (0)