mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
GH-98686: Quicken everything (GH-98687)
This commit is contained in:
parent
18fc232e07
commit
276d77724f
21 changed files with 144 additions and 239 deletions
|
@ -31,7 +31,6 @@ uint8_t _PyOpcode_Adaptive[256] = {
|
|||
[FOR_ITER] = FOR_ITER_ADAPTIVE,
|
||||
};
|
||||
|
||||
Py_ssize_t _Py_QuickenedCount = 0;
|
||||
#ifdef Py_STATS
|
||||
PyStats _py_stats_struct = { 0 };
|
||||
PyStats *_py_stats = &_py_stats_struct;
|
||||
|
@ -280,16 +279,14 @@ do { \
|
|||
void
|
||||
_PyCode_Quicken(PyCodeObject *code)
|
||||
{
|
||||
_Py_QuickenedCount++;
|
||||
int previous_opcode = -1;
|
||||
_Py_CODEUNIT *instructions = _PyCode_CODE(code);
|
||||
for (int i = 0; i < Py_SIZE(code); i++) {
|
||||
int opcode = _Py_OPCODE(instructions[i]);
|
||||
int opcode = _PyOpcode_Deopt[_Py_OPCODE(instructions[i])];
|
||||
uint8_t adaptive_opcode = _PyOpcode_Adaptive[opcode];
|
||||
if (adaptive_opcode) {
|
||||
_Py_SET_OPCODE(instructions[i], adaptive_opcode);
|
||||
// Make sure the adaptive counter is zero:
|
||||
assert(instructions[i + 1] == 0);
|
||||
instructions[i + 1] = adaptive_counter_start();
|
||||
previous_opcode = -1;
|
||||
i += _PyOpcode_Caches[opcode];
|
||||
}
|
||||
|
@ -299,12 +296,6 @@ _PyCode_Quicken(PyCodeObject *code)
|
|||
case EXTENDED_ARG:
|
||||
_Py_SET_OPCODE(instructions[i], EXTENDED_ARG_QUICK);
|
||||
break;
|
||||
case JUMP_BACKWARD:
|
||||
_Py_SET_OPCODE(instructions[i], JUMP_BACKWARD_QUICK);
|
||||
break;
|
||||
case RESUME:
|
||||
_Py_SET_OPCODE(instructions[i], RESUME_QUICK);
|
||||
break;
|
||||
case LOAD_FAST:
|
||||
switch(previous_opcode) {
|
||||
case LOAD_FAST:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue