diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2024-05-22 00:46:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-22 00:46:39 (GMT) |
commit | 98e855fcc1f1d490c803565e84cb611b3f057e45 (patch) | |
tree | 53f19fb0244fa8c43e53534c31842adf5b65ebc2 /Python/generated_cases.c.h | |
parent | 506b1a3ff66a41c72d205c8e4cba574e439d8e76 (diff) | |
download | cpython-98e855fcc1f1d490c803565e84cb611b3f057e45.zip cpython-98e855fcc1f1d490c803565e84cb611b3f057e45.tar.gz cpython-98e855fcc1f1d490c803565e84cb611b3f057e45.tar.bz2 |
gh-119180: Add LOAD_COMMON_CONSTANT opcode (#119321)
The PEP 649 implementation will require a way to load NotImplementedError
from the bytecode. @markshannon suggested implementing this by converting
LOAD_ASSERTION_ERROR into a more general mechanism for loading constants.
This PR adds this new opcode. I will work on the rest of the implementation
of the PEP separately.
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r-- | Python/generated_cases.c.h | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 96161c5..07d9965 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -3695,17 +3695,6 @@ DISPATCH(); } - TARGET(LOAD_ASSERTION_ERROR) { - frame->instr_ptr = next_instr; - next_instr += 1; - INSTRUCTION_STATS(LOAD_ASSERTION_ERROR); - PyObject *value; - value = Py_NewRef(PyExc_AssertionError); - stack_pointer[0] = value; - stack_pointer += 1; - DISPATCH(); - } - TARGET(LOAD_ATTR) { frame->instr_ptr = next_instr; next_instr += 10; @@ -4251,6 +4240,27 @@ DISPATCH(); } + TARGET(LOAD_COMMON_CONSTANT) { + frame->instr_ptr = next_instr; + next_instr += 1; + INSTRUCTION_STATS(LOAD_COMMON_CONSTANT); + PyObject *value; + // Keep in sync with _common_constants in opcode.py + switch(oparg) { + case CONSTANT_ASSERTIONERROR: + value = PyExc_AssertionError; + break; + case CONSTANT_NOTIMPLEMENTEDERROR: + value = PyExc_NotImplementedError; + break; + default: + Py_FatalError("bad LOAD_COMMON_CONSTANT oparg"); + } + stack_pointer[0] = value; + stack_pointer += 1; + DISPATCH(); + } + TARGET(LOAD_CONST) { frame->instr_ptr = next_instr; next_instr += 1; |