|
45 | 45 | #include "ceval_macros.h" |
46 | 46 |
|
47 | 47 | /* Flow control macros */ |
48 | | -#define GO_TO_INSTRUCTION(instname) ((void)0) |
49 | 48 |
|
50 | 49 | #define inst(name, ...) case name: |
51 | 50 | #define op(name, ...) /* NAME is ignored */ |
@@ -2019,12 +2018,10 @@ dummy_func( |
2019 | 2018 | ERROR_IF(err != 0, error); |
2020 | 2019 | } |
2021 | 2020 |
|
2022 | | - inst(INSTRUMENTED_LOAD_SUPER_ATTR, (unused/1 -- )) { |
2023 | | - // cancel out the decrement that will happen in LOAD_SUPER_ATTR; we |
2024 | | - // don't want to specialize instrumented instructions |
2025 | | - PAUSE_ADAPTIVE_COUNTER(this_instr[1].counter); |
2026 | | - GO_TO_INSTRUCTION(LOAD_SUPER_ATTR); |
2027 | | - } |
| 2021 | + macro(INSTRUMENTED_LOAD_SUPER_ATTR) = |
| 2022 | + counter/1 + |
| 2023 | + _LOAD_SUPER_ATTR + |
| 2024 | + _PUSH_NULL_CONDITIONAL; |
2028 | 2025 |
|
2029 | 2026 | family(LOAD_SUPER_ATTR, INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR) = { |
2030 | 2027 | LOAD_SUPER_ATTR_ATTR, |
@@ -2088,7 +2085,10 @@ dummy_func( |
2088 | 2085 | attr = PyStackRef_FromPyObjectSteal(attr_o); |
2089 | 2086 | } |
2090 | 2087 |
|
2091 | | - macro(LOAD_SUPER_ATTR) = _SPECIALIZE_LOAD_SUPER_ATTR + _LOAD_SUPER_ATTR + _PUSH_NULL_CONDITIONAL; |
| 2088 | + macro(LOAD_SUPER_ATTR) = |
| 2089 | + _SPECIALIZE_LOAD_SUPER_ATTR + |
| 2090 | + _LOAD_SUPER_ATTR + |
| 2091 | + _PUSH_NULL_CONDITIONAL; |
2092 | 2092 |
|
2093 | 2093 | inst(LOAD_SUPER_ATTR_ATTR, (unused/1, global_super_st, class_st, self_st -- attr_st)) { |
2094 | 2094 | PyObject *global_super = PyStackRef_AsPyObjectBorrow(global_super_st); |
@@ -4331,18 +4331,23 @@ dummy_func( |
4331 | 4331 | CALL_KW_NON_PY, |
4332 | 4332 | }; |
4333 | 4333 |
|
4334 | | - inst(INSTRUMENTED_CALL_KW, (counter/1, version/2 -- )) { |
4335 | | - int is_meth = !PyStackRef_IsNull(PEEK(oparg + 2)); |
4336 | | - int total_args = oparg + is_meth; |
4337 | | - PyObject *function = PyStackRef_AsPyObjectBorrow(PEEK(oparg + 3)); |
4338 | | - PyObject *arg = total_args == 0 ? &_PyInstrumentation_MISSING |
4339 | | - : PyStackRef_AsPyObjectBorrow(PEEK(total_args + 1)); |
| 4334 | + op(_MONITOR_CALL_KW, (callable[1], self_or_null[1], args[oparg], kwnames -- callable[1], self_or_null[1], args[oparg], kwnames)) { |
| 4335 | + int is_meth = !PyStackRef_IsNull(self_or_null[0]); |
| 4336 | + PyObject *arg; |
| 4337 | + if (is_meth) { |
| 4338 | + arg = PyStackRef_AsPyObjectBorrow(self_or_null[0]); |
| 4339 | + } |
| 4340 | + else if (args) { |
| 4341 | + arg = PyStackRef_AsPyObjectBorrow(args[0]); |
| 4342 | + } |
| 4343 | + else { |
| 4344 | + arg = &_PyInstrumentation_MISSING; |
| 4345 | + } |
| 4346 | + PyObject *function = PyStackRef_AsPyObjectBorrow(callable[0]); |
4340 | 4347 | int err = _Py_call_instrumentation_2args( |
4341 | 4348 | tstate, PY_MONITORING_EVENT_CALL, |
4342 | 4349 | frame, this_instr, function, arg); |
4343 | 4350 | ERROR_IF(err, error); |
4344 | | - PAUSE_ADAPTIVE_COUNTER(this_instr[1].counter); |
4345 | | - GO_TO_INSTRUCTION(CALL_KW); |
4346 | 4351 | } |
4347 | 4352 |
|
4348 | 4353 | op(_MAYBE_EXPAND_METHOD_KW, (callable[1], self_or_null[1], args[oparg], kwnames_in -- func[1], maybe_self[1], args[oparg], kwnames_out)) { |
@@ -4520,6 +4525,13 @@ dummy_func( |
4520 | 4525 | _MAYBE_EXPAND_METHOD_KW + |
4521 | 4526 | _DO_CALL_KW; |
4522 | 4527 |
|
| 4528 | + macro(INSTRUMENTED_CALL_KW) = |
| 4529 | + counter/1 + |
| 4530 | + unused/2 + |
| 4531 | + _MONITOR_CALL_KW + |
| 4532 | + _MAYBE_EXPAND_METHOD_KW + |
| 4533 | + _DO_CALL_KW; |
| 4534 | + |
4523 | 4535 | op(_CHECK_IS_NOT_PY_CALLABLE_KW, (callable[1], unused[1], unused[oparg], kwnames -- callable[1], unused[1], unused[oparg], kwnames)) { |
4524 | 4536 | PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable[0]); |
4525 | 4537 | EXIT_IF(PyFunction_Check(callable_o)); |
@@ -4566,10 +4578,6 @@ dummy_func( |
4566 | 4578 | _CALL_KW_NON_PY + |
4567 | 4579 | _CHECK_PERIODIC; |
4568 | 4580 |
|
4569 | | - inst(INSTRUMENTED_CALL_FUNCTION_EX, ( -- )) { |
4570 | | - GO_TO_INSTRUCTION(CALL_FUNCTION_EX); |
4571 | | - } |
4572 | | - |
4573 | 4581 | op(_MAKE_CALLARGS_A_TUPLE, (func, unused, callargs, kwargs_in -- func, unused, tuple, kwargs_out)) { |
4574 | 4582 | PyObject *callargs_o = PyStackRef_AsPyObjectBorrow(callargs); |
4575 | 4583 | if (PyTuple_CheckExact(callargs_o)) { |
@@ -4678,6 +4686,10 @@ dummy_func( |
4678 | 4686 | _DO_CALL_FUNCTION_EX + |
4679 | 4687 | _CHECK_PERIODIC; |
4680 | 4688 |
|
| 4689 | + macro(INSTRUMENTED_CALL_FUNCTION_EX) = |
| 4690 | + _MAKE_CALLARGS_A_TUPLE + |
| 4691 | + _DO_CALL_FUNCTION_EX + |
| 4692 | + _CHECK_PERIODIC; |
4681 | 4693 |
|
4682 | 4694 | inst(MAKE_FUNCTION, (codeobj_st -- func)) { |
4683 | 4695 | PyObject *codeobj = PyStackRef_AsPyObjectBorrow(codeobj_st); |
|
0 commit comments