_opcode.c.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*[clinic input]
  2. preserve
  3. [clinic start generated code]*/
  4. #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
  5. # include "pycore_gc.h" // PyGC_Head
  6. # include "pycore_runtime.h" // _Py_ID()
  7. #endif
  8. PyDoc_STRVAR(_opcode_stack_effect__doc__,
  9. "stack_effect($module, opcode, oparg=None, /, *, jump=None)\n"
  10. "--\n"
  11. "\n"
  12. "Compute the stack effect of the opcode.");
  13. #define _OPCODE_STACK_EFFECT_METHODDEF \
  14. {"stack_effect", _PyCFunction_CAST(_opcode_stack_effect), METH_FASTCALL|METH_KEYWORDS, _opcode_stack_effect__doc__},
  15. static int
  16. _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg,
  17. PyObject *jump);
  18. static PyObject *
  19. _opcode_stack_effect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
  20. {
  21. PyObject *return_value = NULL;
  22. #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
  23. #define NUM_KEYWORDS 1
  24. static struct {
  25. PyGC_Head _this_is_not_used;
  26. PyObject_VAR_HEAD
  27. PyObject *ob_item[NUM_KEYWORDS];
  28. } _kwtuple = {
  29. .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
  30. .ob_item = { &_Py_ID(jump), },
  31. };
  32. #undef NUM_KEYWORDS
  33. #define KWTUPLE (&_kwtuple.ob_base.ob_base)
  34. #else // !Py_BUILD_CORE
  35. # define KWTUPLE NULL
  36. #endif // !Py_BUILD_CORE
  37. static const char * const _keywords[] = {"", "", "jump", NULL};
  38. static _PyArg_Parser _parser = {
  39. .keywords = _keywords,
  40. .fname = "stack_effect",
  41. .kwtuple = KWTUPLE,
  42. };
  43. #undef KWTUPLE
  44. PyObject *argsbuf[3];
  45. Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
  46. int opcode;
  47. PyObject *oparg = Py_None;
  48. PyObject *jump = Py_None;
  49. int _return_value;
  50. args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
  51. if (!args) {
  52. goto exit;
  53. }
  54. opcode = _PyLong_AsInt(args[0]);
  55. if (opcode == -1 && PyErr_Occurred()) {
  56. goto exit;
  57. }
  58. if (nargs < 2) {
  59. goto skip_optional_posonly;
  60. }
  61. noptargs--;
  62. oparg = args[1];
  63. skip_optional_posonly:
  64. if (!noptargs) {
  65. goto skip_optional_kwonly;
  66. }
  67. jump = args[2];
  68. skip_optional_kwonly:
  69. _return_value = _opcode_stack_effect_impl(module, opcode, oparg, jump);
  70. if ((_return_value == -1) && PyErr_Occurred()) {
  71. goto exit;
  72. }
  73. return_value = PyLong_FromLong((long)_return_value);
  74. exit:
  75. return return_value;
  76. }
  77. PyDoc_STRVAR(_opcode_get_specialization_stats__doc__,
  78. "get_specialization_stats($module, /)\n"
  79. "--\n"
  80. "\n"
  81. "Return the specialization stats");
  82. #define _OPCODE_GET_SPECIALIZATION_STATS_METHODDEF \
  83. {"get_specialization_stats", (PyCFunction)_opcode_get_specialization_stats, METH_NOARGS, _opcode_get_specialization_stats__doc__},
  84. static PyObject *
  85. _opcode_get_specialization_stats_impl(PyObject *module);
  86. static PyObject *
  87. _opcode_get_specialization_stats(PyObject *module, PyObject *Py_UNUSED(ignored))
  88. {
  89. return _opcode_get_specialization_stats_impl(module);
  90. }
  91. /*[clinic end generated code: output=21e3d53a659c651a input=a9049054013a1b77]*/