8000 Quick test to see if removing the tier2 interpreter speeds up tier1 by gvanrossum · Pull Request #117908 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Quick test to see if removing the tier2 interpreter speeds up tier1 #117908

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 9 commits into from
Prev Previous commit
Next Next commit
Fix the problem with CALL_STAT_INC (see issue)
  • Loading branch information
gvanrossum committed Apr 16, 2024
commit 0c195cb8a6af4cdfe382013602eb5d256ddcb301
7 changes: 5 additions & 2 deletions Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ extern int _PyStaticCode_Init(PyCodeObject *co);
#define STAT_INC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name++; } while (0)
#define STAT_DEC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name--; } while (0)
#define OPCODE_EXE_INC(opname) do { if (_Py_stats) _Py_stats->opcode_stats[opname].execution_count++; } while (0)
#define CALL_STAT_INC(name) do { if (_Py_stats) _Py_stats->call_stats.name++; } while (0)
#define REAL_CALL_STAT_INC(name) do { if (_Py_stats) _Py_stats->call_stats.name++; } while (0)
#define OBJECT_STAT_INC(name) do { if (_Py_stats) _Py_stats->object_stats.name++; } while (0)
#define OBJECT_STAT_INC_COND(name, cond) \
do { if (_Py_stats && cond) _Py_stats->object_stats.name++; } while (0)
Expand Down Expand Up @@ -329,7 +329,7 @@ PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void);
#define STAT_INC(opname, name) ((void)0)
#define STAT_DEC(opname, name) ((void)0)
#define OPCODE_EXE_INC(opname) ((void)0)
#define CALL_STAT_INC(name) ((void)0)
#define REAL_CALL_STAT_INC(name) ((void)0)
#define OBJECT_STAT_INC(name) ((void)0)
#define OBJECT_STAT_INC_COND(name, cond) ((void)0)
#define EVAL_CALL_STAT_INC(name) ((void)0)
Expand All @@ -343,6 +343,9 @@ PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void);
#define RARE_EVENT_STAT_INC(name) ((void)0)
#endif // !Py_STATS

// We do a little dance here so we can redefine and restore CALL_STAT_INC
#define CALL_STAT_INC(name) REAL_CALL_STAT_INC(name)

// Utility functions for reading/writing 32/64-bit values in the inline caches.
// Great care should be taken to ensure that these functions remain correct and
// performant! They should compile to just "move" instructions on all supported
Expand Down
11 changes: 11 additions & 0 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,17 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int

#endif // _Py_NOTIER2

// Undefine the macros we redefined, to avoid using the wrong ones below
#undef LOAD_IP
#undef GOTO_ERROR
#undef ENABLE_SPECIALIZATION
#undef STAT_INC
#undef STAT_DEC
#undef CALL_STAT_INC

// Restore this one
#define CALL_STAT_INC(name) REAL_CALL_STAT_INC(name)

}

#if defined(__GNUC__)
Expand Down
0