bpo-43760: Check for tracing using 'bitwise or' instead of branch in dispatch. (GH-28723)

This commit is contained in:
Mark Shannon 2021-10-05 11:01:11 +01:00 committed by GitHub
parent ef6196028f
commit bd627eb7ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 249 additions and 217 deletions

File diff suppressed because it is too large Load diff

View file

@ -32,6 +32,7 @@ def write_contents(f):
"""
opcode = find_module('opcode')
targets = ['_unknown_opcode'] * 256
targets[255] = "TARGET_DO_TRACING"
for opname, op in opcode.opmap.items():
targets[op] = "TARGET_%s" % opname
next_op = 1

View file

@ -254,5 +254,5 @@ static void *opcode_targets[256] = {
&&_unknown_opcode,
&&_unknown_opcode,
&&_unknown_opcode,
&&_unknown_opcode
&&TARGET_DO_TRACING
};

View file

@ -268,7 +268,7 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
break;
}
if (canTrace) {
ts->cframe->use_tracing = (ts->c_tracefunc || ts->c_profilefunc);
ts->cframe->use_tracing = (ts->c_tracefunc || ts->c_profilefunc) ? 255 : 0;
ts->tracing--;
}
PyObject* args[2] = {eventName, eventArgs};
@ -283,7 +283,7 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
Py_DECREF(o);
Py_CLEAR(hook);
}
ts->cframe->use_tracing = (ts->c_tracefunc || ts->c_profilefunc);
ts->cframe->use_tracing = (ts->c_tracefunc || ts->c_profilefunc) ? 255 : 0;
ts->tracing--;
if (_PyErr_Occurred(ts)) {
goto exit;