summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2022-11-02 17:42:57 (GMT)
committerGitHub <noreply@github.com>2022-11-02 17:42:57 (GMT)
commit276d77724f2373cc03838448a3e62977aa28bf0d (patch)
treeaeb2f83a896f02a3f38ace9d6ecb65b9620be8e3 /Objects
parent18fc232e07c14536d99f07821e338ebddfd8cb63 (diff)
downloadcpython-276d77724f2373cc03838448a3e62977aa28bf0d.zip
cpython-276d77724f2373cc03838448a3e62977aa28bf0d.tar.gz
cpython-276d77724f2373cc03838448a3e62977aa28bf0d.tar.bz2
GH-98686: Quicken everything (GH-98687)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/codeobject.c16
-rw-r--r--Objects/frameobject.c2
-rw-r--r--Objects/genobject.c3
3 files changed, 8 insertions, 13 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 8920b1d..854611f 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -301,6 +301,8 @@ _PyCode_Validate(struct _PyCodeConstructor *con)
return 0;
}
+extern void _PyCode_Quicken(PyCodeObject *code);
+
static void
init_code(PyCodeObject *co, struct _PyCodeConstructor *con)
{
@@ -353,7 +355,6 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con)
co->co_extra = NULL;
co->_co_cached = NULL;
- co->co_warmup = QUICKENING_INITIAL_WARMUP_VALUE;
co->_co_linearray_entry_size = 0;
co->_co_linearray = NULL;
memcpy(_PyCode_CODE(co), PyBytes_AS_STRING(con->code),
@@ -364,6 +365,7 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con)
entry_point++;
}
co->_co_firsttraceable = entry_point;
+ _PyCode_Quicken(co);
}
static int
@@ -1664,9 +1666,6 @@ code_dealloc(PyCodeObject *co)
if (co->_co_linearray) {
PyMem_Free(co->_co_linearray);
}
- if (co->co_warmup == 0) {
- _Py_QuickenedCount--;
- }
PyObject_Free(co);
}
@@ -2224,13 +2223,9 @@ _PyCode_ConstantKey(PyObject *op)
}
void
-_PyStaticCode_Dealloc(PyCodeObject *co)
+_PyStaticCode_Fini(PyCodeObject *co)
{
- if (co->co_warmup == 0) {
- _Py_QuickenedCount--;
- }
deopt_code(_PyCode_CODE(co), Py_SIZE(co));
- co->co_warmup = QUICKENING_INITIAL_WARMUP_VALUE;
PyMem_Free(co->co_extra);
if (co->_co_cached != NULL) {
Py_CLEAR(co->_co_cached->_co_code);
@@ -2252,7 +2247,7 @@ _PyStaticCode_Dealloc(PyCodeObject *co)
}
int
-_PyStaticCode_InternStrings(PyCodeObject *co)
+_PyStaticCode_Init(PyCodeObject *co)
{
int res = intern_strings(co->co_names);
if (res < 0) {
@@ -2266,5 +2261,6 @@ _PyStaticCode_InternStrings(PyCodeObject *co)
if (res < 0) {
return -1;
}
+ _PyCode_Quicken(co);
return 0;
}
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index dd69207..1f1228b 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -603,7 +603,7 @@ _PyFrame_GetState(PyFrameObject *frame)
if (_PyInterpreterFrame_LASTI(frame->f_frame) < 0) {
return FRAME_CREATED;
}
- switch (_PyOpcode_Deopt[_Py_OPCODE(*frame->f_frame->prev_instr)])
+ switch (_Py_OPCODE(*frame->f_frame->prev_instr))
{
case COPY_FREE_VARS:
case MAKE_CELL:
diff --git a/Objects/genobject.c b/Objects/genobject.c
index ad4fbed..c62fb62 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -8,7 +8,6 @@
#include "pycore_frame.h" // _PyInterpreterFrame
#include "pycore_genobject.h" // struct _Py_async_gen_state
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
-#include "pycore_opcode.h" // _PyOpcode_Deopt
#include "pycore_pyerrors.h" // _PyErr_ClearExcState()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "structmember.h" // PyMemberDef
@@ -364,7 +363,7 @@ _PyGen_yf(PyGenObject *gen)
return NULL;
}
_Py_CODEUNIT next = frame->prev_instr[1];
- if (_PyOpcode_Deopt[_Py_OPCODE(next)] != RESUME || _Py_OPARG(next) < 2)
+ if (_Py_OPCODE(next) != RESUME || _Py_OPARG(next) < 2)
{
/* Not in a yield from */
return NULL;