summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2022-04-21 18:53:57 (GMT)
committerGitHub <noreply@github.com>2022-04-21 18:53:57 (GMT)
commitf8dc6186d1857a19edd182277a9d78e6d6cc3787 (patch)
treee85e859c1999d95ce7cc6402068f84efad807e1f /Include/cpython
parentd44815cabc0a8d9932df2fa95cb374eadddb7c17 (diff)
downloadcpython-f8dc6186d1857a19edd182277a9d78e6d6cc3787.zip
cpython-f8dc6186d1857a19edd182277a9d78e6d6cc3787.tar.gz
cpython-f8dc6186d1857a19edd182277a9d78e6d6cc3787.tar.bz2
GH-91719: Make MSVC generate somewhat faster switch code (#91718)
Apparently a switch on an 8-bit quantity where all cases are present generates a more efficient jump (doing only one indexed memory load instead of two). So we make opcode and use_tracing uint8_t, and generate a macro full of extra `case NNN:` lines for all unused opcodes. See https://github.com/faster-cpython/ideas/issues/321#issuecomment-1103263673
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/pystate.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 1af21a2..2bd4606 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -46,7 +46,7 @@ typedef struct _PyCFrame {
* discipline and make sure that instances of this struct cannot
* accessed outside of their lifetime.
*/
- int use_tracing;
+ uint8_t use_tracing; // 0 or 255 (or'ed into opcode, hence 8-bit type)
/* Pointer to the currently executing frame (it can be NULL) */
struct _PyInterpreterFrame *current_frame;
struct _PyCFrame *previous;