Skip to content

Commit 30e6cbd

Browse files
authored
GH-113860: Get rid of _PyUOpExecutorObject (GH-113954)
1 parent 29e2839 commit 30e6cbd

File tree

12 files changed

+35
-67
lines changed

12 files changed

+35
-67
lines changed

Include/cpython/optimizer.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ typedef struct {
2929
_PyExecutorLinkListNode links;
3030
} _PyVMData;
3131

32+
typedef struct {
33+
uint16_t opcode;
34+
uint16_t oparg;
35+
uint32_t target;
36+
uint64_t operand; // A cache entry
37+
} _PyUOpInstruction;
38+
3239
typedef struct _PyExecutorObject {
3340
PyObject_VAR_HEAD
3441
_PyVMData vm_data; /* Used by the VM, but opaque to the optimizer */
35-
/* Data needed by the executor goes here, but is opaque to the VM */
42+
_PyUOpInstruction trace[1];
3643
} _PyExecutorObject;
3744

3845
typedef struct _PyOptimizerObject _PyOptimizerObject;

Include/internal/pycore_optimizer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
#include "pycore_uops.h" // _PyUOpInstruction
12-
1311
int _Py_uop_analyze_and_optimize(PyCodeObject *code,
1412
_PyUOpInstruction *trace, int trace_len, int curr_stackentries);
1513

Include/internal/pycore_uops.h

Lines changed: 0 additions & 30 deletions
This file was deleted.

Makefile.pre.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,6 @@ PYTHON_HEADERS= \
18951895
$(srcdir)/Include/internal/pycore_unionobject.h \
18961896
$(srcdir)/Include/internal/pycore_unicodeobject.h \
18971897
$(srcdir)/Include/internal/pycore_unicodeobject_generated.h \
1898-
$(srcdir)/Include/internal/pycore_uops.h \
18991898
$(srcdir)/Include/internal/pycore_uop_metadata.h \
19001899
$(srcdir)/Include/internal/pycore_warnings.h \
19011900
$(srcdir)/Include/internal/pycore_weakref.h \

PCbuild/pythoncore.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@
295295
<ClInclude Include="..\Include\internal\pycore_unionobject.h" />
296296
<ClInclude Include="..\Include\internal\pycore_unicodeobject.h" />
297297
<ClInclude Include="..\Include\internal\pycore_unicodeobject_generated.h" />
298-
<ClInclude Include="..\Include\internal\pycore_uops.h" />
299298
<ClInclude Include="..\Include\internal\pycore_warnings.h" />
300299
<ClInclude Include="..\Include\internal\pycore_weakref.h" />
301300
<ClInclude Include="..\Include\interpreteridobject.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,9 +804,6 @@
804804
<ClInclude Include="..\Include\internal\pycore_unionobject.h">
805805
<Filter>Include\internal</Filter>
806806
</ClInclude>
807-
<ClInclude Include="..\Include\internal\pycore_uops.h">
808-
<Filter>Include\internal</Filter>
809-
</ClInclude>
810807
<ClInclude Include="..\Include\internal\mimalloc\mimalloc.h">
811808
<Filter>Include\internal\mimalloc</Filter>
812809
</ClInclude>

Python/bytecodes.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static size_t jump;
6868
static uint16_t invert, counter, index, hint;
6969
#define unused 0 // Used in a macro def, can't be static
7070
static uint32_t type_version;
71-
static _PyUOpExecutorObject *current_executor;
71+
static _PyExecutorObject *current_executor;
7272

7373
static PyObject *
7474
dummy_func(
@@ -2369,10 +2369,10 @@ dummy_func(
23692369
CHECK_EVAL_BREAKER();
23702370

23712371
PyCodeObject *code = _PyFrame_GetCode(frame);
2372-
_PyExecutorObject *executor = (_PyExecutorObject *)code->co_executors->executors[oparg&255];
2372+
_PyExecutorObject *executor = code->co_executors->executors[oparg & 255];
23732373
if (executor->vm_data.valid) {
23742374
Py_INCREF(executor);
2375-
current_executor = (_PyUOpExecutorObject *)executor;
2375+
current_executor = executor;
23762376
GOTO_TIER_TWO();
23772377
}
23782378
else {
@@ -4063,7 +4063,7 @@ dummy_func(
40634063

40644064
op(_CHECK_VALIDITY, (--)) {
40654065
TIER_TWO_ONLY
4066-
DEOPT_IF(!current_executor->base.vm_data.valid);
4066+
DEOPT_IF(!current_executor->vm_data.valid);
40674067
}
40684068

40694069
op(_LOAD_CONST_INLINE_BORROW, (ptr/4 -- value)) {

Python/ceval.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "pycore_tuple.h" // _PyTuple_ITEMS()
2626
#include "pycore_typeobject.h" // _PySuper_Lookup()
2727
#include "pycore_uop_ids.h" // Uops
28-
#include "pycore_uops.h" // _PyUOpExecutorObject
2928
#include "pycore_pyerrors.h"
3029

3130
#include "pycore_dict.h"
@@ -739,7 +738,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
739738
}
740739

741740
/* State shared between Tier 1 and Tier 2 interpreter */
742-
_PyUOpExecutorObject *current_executor = NULL;
741+
_PyExecutorObject *current_executor = NULL;
743742

744743
/* Local "register" variables.
745744
* These are cached values from the frame and code object. */

Python/executor_cases.c.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)