summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2021-06-07 17:38:06 (GMT)
committerGitHub <noreply@github.com>2021-06-07 17:38:06 (GMT)
commit001eb520b5757294dc455c900d94b7b153de6cdd (patch)
treec9d3a3d36e860a9a0591ce6d7d758201e72c2230 /Include/cpython
parent89e50ab36fac6a0e7f1998501f36fcd2872a6604 (diff)
downloadcpython-001eb520b5757294dc455c900d94b7b153de6cdd.zip
cpython-001eb520b5757294dc455c900d94b7b153de6cdd.tar.gz
cpython-001eb520b5757294dc455c900d94b7b153de6cdd.tar.bz2
bpo-44187: Quickening infrastructure (GH-26264)
* Add co_firstinstr field to code object. * Implement barebones quickening. * Use non-quickened bytecode when tracing. * Add NEWS item * Add new file to Windows build. * Don't specialize instructions with EXTENDED_ARG.
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/code.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/Include/cpython/code.h b/Include/cpython/code.h
index 5c0fae4..98d728b 100644
--- a/Include/cpython/code.h
+++ b/Include/cpython/code.h
@@ -7,9 +7,11 @@ typedef uint16_t _Py_CODEUNIT;
#ifdef WORDS_BIGENDIAN
# define _Py_OPCODE(word) ((word) >> 8)
# define _Py_OPARG(word) ((word) & 255)
+# define _Py_MAKECODEUNIT(opcode, oparg) (((opcode)<<8)|(oparg))
#else
# define _Py_OPCODE(word) ((word) & 255)
# define _Py_OPARG(word) ((word) >> 8)
+# define _Py_MAKECODEUNIT(opcode, oparg) ((opcode)|((oparg)<<8))
#endif
typedef struct _PyOpcache _PyOpcache;
@@ -43,16 +45,20 @@ struct PyCodeObject {
/* These fields are set with provided values on new code objects. */
// The hottest fields (in the eval loop) are grouped here at the top.
- PyObject *co_code; /* instruction opcodes */
PyObject *co_consts; /* list (constants used) */
PyObject *co_names; /* list of strings (names used) */
+ _Py_CODEUNIT *co_firstinstr; /* Pointer to first instruction, used for quickening */
+ PyObject *co_exceptiontable; /* Byte string encoding exception handling table */
int co_flags; /* CO_..., see below */
+ int co_warmup; /* Warmup counter for quickening */
+
// The rest are not so impactful on performance.
int co_argcount; /* #arguments, except *args */
int co_posonlyargcount; /* #positional only arguments */
int co_kwonlyargcount; /* #keyword only arguments */
int co_stacksize; /* #entries needed for evaluation stack */
int co_firstlineno; /* first source line number */
+ PyObject *co_code; /* instruction opcodes */
PyObject *co_varnames; /* tuple of strings (local variable names) */
PyObject *co_cellvars; /* tuple of strings (cell variable names) */
PyObject *co_freevars; /* tuple of strings (free variable names) */
@@ -60,7 +66,6 @@ struct PyCodeObject {
PyObject *co_name; /* unicode (name, for reference) */
PyObject *co_linetable; /* string (encoding addr<->lineno mapping) See
Objects/lnotab_notes.txt for details. */
- PyObject *co_exceptiontable; /* Byte string encoding exception handling table */
/* These fields are set with computed values on new code objects. */
@@ -78,6 +83,10 @@ struct PyCodeObject {
Type is a void* to keep the format private in codeobject.c to force
people to go through the proper APIs. */
void *co_extra;
+ /* Quickened instructions and cache, or NULL
+ This should be treated as opaque by all code except the specializer and
+ interpreter. */
+ union _cache_or_instruction *co_quickened;
/* Per opcodes just-in-time cache
*