Write header file that defines the jump target table
(analysis: Analysis, out: CWriter)
| 21 | |
| 22 | |
| 23 | def write_opcode_targets(analysis: Analysis, out: CWriter) -> None: |
| 24 | """Write header file that defines the jump target table""" |
| 25 | targets = ["&&_unknown_opcode,\n"] * 256 |
| 26 | for name, op in analysis.opmap.items(): |
| 27 | if op < 256: |
| 28 | targets[op] = f"&&TARGET_{name},\n" |
| 29 | out.emit("#if !_Py_TAIL_CALL_INTERP\n") |
| 30 | out.emit("static void *opcode_targets_table[256] = {\n") |
| 31 | for target in targets: |
| 32 | out.emit(target) |
| 33 | out.emit("};\n") |
| 34 | targets = ["&&_unknown_opcode,\n"] * 256 |
| 35 | for name, op in analysis.opmap.items(): |
| 36 | if op < 256: |
| 37 | targets[op] = f"&&TARGET_TRACE_RECORD,\n" |
| 38 | out.emit("#if _Py_TIER2\n") |
| 39 | out.emit("static void *opcode_tracing_targets_table[256] = {\n") |
| 40 | for target in targets: |
| 41 | out.emit(target) |
| 42 | out.emit("};\n") |
| 43 | out.emit(f"#endif\n") |
| 44 | out.emit("#else /* _Py_TAIL_CALL_INTERP */\n") |
| 45 | |
| 46 | def function_proto(name: str) -> str: |
| 47 | return f"static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_{name}(TAIL_CALL_PARAMS)" |
no test coverage detected
searching dependent graphs…