mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
GH-99005: Add CALL_INTRINSIC_1 instruction (GH-100771)
* Remove PRINT_EXPR instruction * Remove STOPITERATION_ERROR instruction * Remove IMPORT_STAR instruction
This commit is contained in:
parent
f20c553a45
commit
28187141cc
19 changed files with 336 additions and 361 deletions
82
Python/generated_cases.c.h
generated
82
Python/generated_cases.c.h
generated
|
|
@ -684,22 +684,14 @@
|
|||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(PRINT_EXPR) {
|
||||
TARGET(CALL_INTRINSIC_1) {
|
||||
PyObject *value = PEEK(1);
|
||||
PyObject *hook = _PySys_GetAttr(tstate, &_Py_ID(displayhook));
|
||||
PyObject *res;
|
||||
// Can't use ERROR_IF here.
|
||||
if (hook == NULL) {
|
||||
_PyErr_SetString(tstate, PyExc_RuntimeError,
|
||||
"lost sys.displayhook");
|
||||
Py_DECREF(value);
|
||||
if (true) goto pop_1_error;
|
||||
}
|
||||
res = PyObject_CallOneArg(hook, value);
|
||||
assert(oparg <= MAX_INTRINSIC_1);
|
||||
res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value);
|
||||
Py_DECREF(value);
|
||||
if (res == NULL) goto pop_1_error;
|
||||
Py_DECREF(res);
|
||||
STACK_SHRINK(1);
|
||||
POKE(1, res);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
|
|
@ -1045,48 +1037,6 @@
|
|||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(STOPITERATION_ERROR) {
|
||||
assert(frame->owner == FRAME_OWNED_BY_GENERATOR);
|
||||
PyObject *exc = TOP();
|
||||
assert(PyExceptionInstance_Check(exc));
|
||||
const char *msg = NULL;
|
||||
if (PyErr_GivenExceptionMatches(exc, PyExc_StopIteration)) {
|
||||
msg = "generator raised StopIteration";
|
||||
if (frame->f_code->co_flags & CO_ASYNC_GENERATOR) {
|
||||
msg = "async generator raised StopIteration";
|
||||
}
|
||||
else if (frame->f_code->co_flags & CO_COROUTINE) {
|
||||
msg = "coroutine raised StopIteration";
|
||||
}
|
||||
}
|
||||
else if ((frame->f_code->co_flags & CO_ASYNC_GENERATOR) &&
|
||||
PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration))
|
||||
{
|
||||
/* code in `gen` raised a StopAsyncIteration error:
|
||||
raise a RuntimeError.
|
||||
*/
|
||||
msg = "async generator raised StopAsyncIteration";
|
||||
}
|
||||
if (msg != NULL) {
|
||||
PyObject *message = _PyUnicode_FromASCII(msg, strlen(msg));
|
||||
if (message == NULL) {
|
||||
goto error;
|
||||
}
|
||||
PyObject *error = PyObject_CallOneArg(PyExc_RuntimeError, message);
|
||||
if (error == NULL) {
|
||||
Py_DECREF(message);
|
||||
goto error;
|
||||
}
|
||||
assert(PyExceptionInstance_Check(error));
|
||||
SET_TOP(error);
|
||||
PyException_SetCause(error, Py_NewRef(exc));
|
||||
// Steal exc reference, rather than Py_NewRef+Py_DECREF
|
||||
PyException_SetContext(error, exc);
|
||||
Py_DECREF(message);
|
||||
}
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(LOAD_ASSERTION_ERROR) {
|
||||
PyObject *value;
|
||||
value = Py_NewRef(PyExc_AssertionError);
|
||||
|
|
@ -2401,30 +2351,6 @@
|
|||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(IMPORT_STAR) {
|
||||
PyObject *from = PEEK(1);
|
||||
PyObject *locals;
|
||||
int err;
|
||||
if (_PyFrame_FastToLocalsWithError(frame) < 0) {
|
||||
Py_DECREF(from);
|
||||
if (true) goto pop_1_error;
|
||||
}
|
||||
|
||||
locals = LOCALS();
|
||||
if (locals == NULL) {
|
||||
_PyErr_SetString(tstate, PyExc_SystemError,
|
||||
"no locals found during 'import *'");
|
||||
Py_DECREF(from);
|
||||
if (true) goto pop_1_error;
|
||||
}
|
||||
err = import_all_from(tstate, locals, from);
|
||||
_PyFrame_LocalsToFast(frame, 0);
|
||||
Py_DECREF(from);
|
||||
if (err) goto pop_1_error;
|
||||
STACK_SHRINK(1);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(IMPORT_FROM) {
|
||||
PyObject *from = PEEK(1);
|
||||
PyObject *res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue