Skip to content

Rename ...UOp... to ...Uop... for consistency #112347

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Include/cpython/optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extern void _Py_Executors_InvalidateAll(PyInterpreterState *interp);

/* For testing */
PyAPI_FUNC(PyObject *)PyUnstable_Optimizer_NewCounter(void);
PyAPI_FUNC(PyObject *)PyUnstable_Optimizer_NewUOpOptimizer(void);
PyAPI_FUNC(PyObject *)PyUnstable_Optimizer_NewUopOptimizer(void);

#define OPTIMIZER_BITS_IN_COUNTER 4
/* Minimum of 16 additional executions before retry */
Expand Down
4 changes: 2 additions & 2 deletions Include/cpython/pystats.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ typedef struct _gc_stats {
typedef struct _uop_stats {
uint64_t execution_count;
uint64_t miss;
} UOpStats;
} UopStats;

#define _Py_UOP_HIST_SIZE 32

Expand All @@ -114,7 +114,7 @@ typedef struct _optimization_stats {
uint64_t trace_too_short;
uint64_t inner_loop;
uint64_t recursive_call;
UOpStats opcode[512];
UopStats opcode[512];
uint64_t unsupported_opcode[256];
uint64_t trace_length_hist[_Py_UOP_HIST_SIZE];
uint64_t trace_run_length_hist[_Py_UOP_HIST_SIZE];
Expand Down
8 changes: 4 additions & 4 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

#include "pycore_uops.h" // _PyUOpInstruction
#include "pycore_uops.h" // _PyUopInstruction

int _Py_uop_analyze_and_optimize(PyCodeObject *code,
_PyUOpInstruction *trace, int trace_len, int curr_stackentries);
_PyUopInstruction *trace, int trace_len, int curr_stackentries);

extern PyTypeObject _PyCounterExecutor_Type;
extern PyTypeObject _PyCounterOptimizer_Type;
extern PyTypeObject _PyDefaultOptimizer_Type;
extern PyTypeObject _PyUOpExecutor_Type;
extern PyTypeObject _PyUOpOptimizer_Type;
extern PyTypeObject _PyUopExecutor_Type;
extern PyTypeObject _PyUopOptimizer_Type;

#ifdef __cplusplus
}
Expand Down
6 changes: 3 additions & 3 deletions Include/internal/pycore_uops.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ typedef struct {
uint16_t oparg;
uint32_t target;
uint64_t operand; // A cache entry
} _PyUOpInstruction;
} _PyUopInstruction;

typedef struct {
_PyExecutorObject base;
_PyUOpInstruction trace[1];
} _PyUOpExecutorObject;
_PyUopInstruction trace[1];
} _PyUopExecutorObject;

_PyInterpreterFrame *_PyUopExecute(
_PyExecutorObject *executor,
Expand Down
2 changes: 1 addition & 1 deletion Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ get_counter_optimizer(PyObject *self, PyObject *arg)
static PyObject *
get_uop_optimizer(PyObject *self, PyObject *arg)
{
return PyUnstable_Optimizer_NewUOpOptimizer();
return PyUnstable_Optimizer_NewUopOptimizer();
}

static PyObject *
Expand Down
6 changes: 3 additions & 3 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "pycore_memoryobject.h" // _PyManagedBuffer_Type
#include "pycore_namespace.h" // _PyNamespace_Type
#include "pycore_object.h" // PyAPI_DATA() _Py_SwappedOp definition
#include "pycore_optimizer.h" // _PyUOpExecutor_Type, _PyUOpOptimizer_Type, ...
#include "pycore_optimizer.h" // _PyUopExecutor_Type, _PyUopOptimizer_Type, ...
#include "pycore_pyerrors.h" // _PyErr_Occurred()
#include "pycore_pymem.h" // _PyMem_IsPtrFreed()
#include "pycore_pystate.h" // _PyThreadState_GET()
Expand Down Expand Up @@ -2291,8 +2291,8 @@ static PyTypeObject* static_types[] = {
&_PyPositionsIterator,
&_PyUnicodeASCIIIter_Type,
&_PyUnion_Type,
&_PyUOpExecutor_Type,
&_PyUOpOptimizer_Type,
&_PyUopExecutor_Type,
&_PyUopOptimizer_Type,
&_PyWeakref_CallableProxyType,
&_PyWeakref_ProxyType,
&_PyWeakref_RefType,
Expand Down
4 changes: 2 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static size_t jump;
static uint16_t invert, counter, index, hint;
#define unused 0 // Used in a macro def, can't be static
static uint32_t type_version;
static _PyUOpExecutorObject *current_executor;
static _PyUopExecutorObject *current_executor;

static PyObject *
dummy_func(
Expand Down Expand Up @@ -2358,7 +2358,7 @@ dummy_func(
frame->instr_ptr = next_instr;
Py_INCREF(executor);
if (executor->execute == _PyUopExecute) {
current_executor = (_PyUOpExecutorObject *)executor;
current_executor = (_PyUopExecutorObject *)executor;
GOTO_TIER_TWO();
}
frame = executor->execute(executor, frame, stack_pointer);
Expand Down
6 changes: 3 additions & 3 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "pycore_sysmodule.h" // _PySys_Audit()
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include "pycore_typeobject.h" // _PySuper_Lookup()
#include "pycore_uops.h" // _PyUOpExecutorObject
#include "pycore_uops.h" // _PyUopExecutorObject
#include "pycore_pyerrors.h"

#include "pycore_dict.h"
Expand Down Expand Up @@ -738,7 +738,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
}

/* State shared between Tier 1 and Tier 2 interpreter */
_PyUOpExecutorObject *current_executor = NULL;
_PyUopExecutorObject *current_executor = NULL;

/* Local "register" variables.
* These are cached values from the frame and code object. */
Expand Down Expand Up @@ -991,7 +991,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
#endif

OPT_STAT_INC(traces_executed);
_PyUOpInstruction *next_uop = current_executor->trace;
_PyUopInstruction *next_uop = current_executor->trace;
uint16_t uopcode;
#ifdef Py_STATS
uint64_t trace_uop_execution_counter = 0;
Expand Down
2 changes: 1 addition & 1 deletion Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ PyUnstable_Optimizer_NewCounter(void)
return (PyObject *)opt;
}

///////////////////// Experimental UOp Optimizer /////////////////////
///////////////////// Experimental Uop Optimizer /////////////////////

static void
uop_dealloc(_PyUOpExecutorObject *self) {
uop_dealloc(_PyUopExecutorObject *self) {
_Py_ExecutorClear((_PyExecutorObject *)self);
PyObject_Free(self);
}
Expand All @@ -334,13 +334,13 @@ _PyUopName(int index)
}

static Py_ssize_t
uop_len(_PyUOpExecutorObject *self)
uop_len(_PyUopExecutorObject *self)
{
return Py_SIZE(self);
}

static PyObject *
uop_item(_PyUOpExecutorObject *self, Py_ssize_t index)
uop_item(_PyUopExecutorObject *self, Py_ssize_t index)
{
Py_ssize_t len = uop_len(self);
if (index < 0 || index >= len) {
Expand Down Expand Up @@ -375,11 +375,11 @@ PySequenceMethods uop_as_sequence = {
.sq_item = (ssizeargfunc)uop_item,
};

PyTypeObject _PyUOpExecutor_Type = {
PyTypeObject _PyUopExecutor_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "uop_executor",
.tp_basicsize = sizeof(_PyUOpExecutorObject) - sizeof(_PyUOpInstruction),
.tp_itemsize = sizeof(_PyUOpInstruction),
.tp_basicsize = sizeof(_PyUopExecutorObject) - sizeof(_PyUopInstruction),
.tp_itemsize = sizeof(_PyUopInstruction),
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
.tp_dealloc = (destructor)uop_dealloc,
.tp_as_sequence = &uop_as_sequence,
Expand Down Expand Up @@ -417,7 +417,7 @@ static int
translate_bytecode_to_trace(
PyCodeObject *code,
_Py_CODEUNIT *instr,
_PyUOpInstruction *trace,
_PyUopInstruction *trace,
int buffer_size,
_PyBloomFilter *dependencies)
{
Expand Down Expand Up @@ -770,7 +770,7 @@ translate_bytecode_to_trace(
* NOPs are excluded from the count.
*/
static int
compute_used(_PyUOpInstruction *buffer, uint32_t *used)
compute_used(_PyUopInstruction *buffer, uint32_t *used)
{
int count = 0;
SET_BIT(used, 0);
Expand Down Expand Up @@ -803,11 +803,11 @@ compute_used(_PyUOpInstruction *buffer, uint32_t *used)
* and not a NOP.
*/
static _PyExecutorObject *
make_executor_from_uops(_PyUOpInstruction *buffer, _PyBloomFilter *dependencies)
make_executor_from_uops(_PyUopInstruction *buffer, _PyBloomFilter *dependencies)
{
uint32_t used[(_Py_UOP_MAX_TRACE_LENGTH + 31)/32] = { 0 };
int length = compute_used(buffer, used);
_PyUOpExecutorObject *executor = PyObject_NewVar(_PyUOpExecutorObject, &_PyUOpExecutor_Type, length);
_PyUopExecutorObject *executor = PyObject_NewVar(_PyUopExecutorObject, &_PyUopExecutor_Type, length);
if (executor == NULL) {
return NULL;
}
Expand Down Expand Up @@ -865,7 +865,7 @@ uop_optimize(
{
_PyBloomFilter dependencies;
_Py_BloomFilter_Init(&dependencies);
_PyUOpInstruction buffer[_Py_UOP_MAX_TRACE_LENGTH];
_PyUopInstruction buffer[_Py_UOP_MAX_TRACE_LENGTH];
int err = translate_bytecode_to_trace(code, instr, buffer, _Py_UOP_MAX_TRACE_LENGTH, &dependencies);
if (err <= 0) {
// Error or nothing translated
Expand Down Expand Up @@ -902,7 +902,7 @@ uop_opt_dealloc(PyObject *self) {
PyObject_Free(self);
}

PyTypeObject _PyUOpOptimizer_Type = {
PyTypeObject _PyUopOptimizer_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "uop_optimizer",
.tp_basicsize = sizeof(_PyOptimizerObject),
Expand All @@ -912,9 +912,9 @@ PyTypeObject _PyUOpOptimizer_Type = {
};

PyObject *
PyUnstable_Optimizer_NewUOpOptimizer(void)
PyUnstable_Optimizer_NewUopOptimizer(void)
{
_PyOptimizerObject *opt = PyObject_New(_PyOptimizerObject, &_PyUOpOptimizer_Type);
_PyOptimizerObject *opt = PyObject_New(_PyOptimizerObject, &_PyUopOptimizer_Type);
if (opt == NULL) {
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "pycore_optimizer.h"

static void
remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
remove_unneeded_uops(_PyUopInstruction *buffer, int buffer_size)
{
// Note that we don't enter stubs, those SET_IPs are needed.
int last_set_ip = -1;
Expand Down Expand Up @@ -55,7 +55,7 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
int
_Py_uop_analyze_and_optimize(
PyCodeObject *co,
_PyUOpInstruction *buffer,
_PyUopInstruction *buffer,
int buffer_size,
int curr_stacklen
)
Expand Down
2 changes: 1 addition & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ init_interp_main(PyThreadState *tstate)
enabled = 1;
}
if (enabled) {
PyObject *opt = PyUnstable_Optimizer_NewUOpOptimizer();
PyObject *opt = PyUnstable_Optimizer_NewUopOptimizer();
if (opt == NULL) {
return _PyStatus_ERR("can't initialize optimizer");
}
Expand Down
4 changes: 2 additions & 2 deletions Tools/c-analyzer/cpython/ignored.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ Python/sysmodule.c - whatstrings -
Python/optimizer.c - _PyDefaultOptimizer_Type -
Python/optimizer.c - _PyCounterExecutor_Type -
Python/optimizer.c - _PyCounterOptimizer_Type -
Python/optimizer.c - _PyUOpExecutor_Type -
Python/optimizer.c - _PyUOpOptimizer_Type -
Python/optimizer.c - _PyUopExecutor_Type -
Python/optimizer.c - _PyUopOptimizer_Type -
Python/optimizer.c - _PyOptimizer_Default -

##-----------------------
Expand Down