Add new PyFrame_GetLasti C-API function (GH-32413)

This commit is contained in:
Mark Shannon 2022-04-08 12:18:57 +01:00 committed by GitHub
parent f4b328e2bb
commit 5b4a4b6f09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 4 deletions

View file

@ -880,7 +880,7 @@ _PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
// This only works when opcode is a non-quickened form:
assert(_PyOpcode_Deopt[opcode] == opcode);
int check_oparg = 0;
for (_Py_CODEUNIT *instruction = _PyCode_CODE(frame->f_code);
for (_Py_CODEUNIT *instruction = _PyCode_CODE(frame->f_code);
instruction < frame->prev_instr; instruction++)
{
int check_opcode = _PyOpcode_Deopt[_Py_OPCODE(*instruction)];
@ -1135,6 +1135,16 @@ PyFrame_GetBuiltins(PyFrameObject *frame)
return frame_getbuiltins(frame, NULL);
}
int
PyFrame_GetLasti(PyFrameObject *frame)
{
int lasti = _PyInterpreterFrame_LASTI(frame->f_frame);
if (lasti < 0) {
return -1;
}
return lasti*2;
}
PyObject *
PyFrame_GetGenerator(PyFrameObject *frame)
{