opcode_310pypy.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # (C) Copyright 2022-2024 by Rocky Bernstein
  2. """
  3. PYPY 3.10 opcodes
  4. This is a like Python 3.10's opcode.py with some classification
  5. of stack usage and information for formatting instructions.
  6. """
  7. import xdis.opcodes.opcode_310 as opcode_310
  8. from xdis.opcodes.base import (
  9. def_op,
  10. finalize_opcodes,
  11. init_opdata,
  12. jrel_op,
  13. nargs_op,
  14. rm_op,
  15. update_pj3,
  16. varargs_op,
  17. )
  18. from xdis.opcodes.opcode_310 import opcode_arg_fmt310, opcode_extended_fmt310
  19. version_tuple = (3, 10)
  20. python_implementation = "PyPy"
  21. loc = locals()
  22. init_opdata(loc, opcode_310, version_tuple, is_pypy=True)
  23. # fmt: off
  24. # Changed opcodes
  25. # ----------------------
  26. rm_op(loc, "GEN_START", 129)
  27. rm_op(loc, "LIST_EXTEND", 162)
  28. rm_op(loc, "SET_UPDATE", 163)
  29. rm_op(loc, "DICT_MERGE", 164)
  30. rm_op(loc, "DICT_UPDATE", 165)
  31. # ----------------------
  32. def_op(loc, "LIST_EXTEND", 164, 2, 1)
  33. def_op(loc, "SET_UPDATE", 165, 2, 1)
  34. def_op(loc, "DICT_MERGE", 166, 2, 1)
  35. def_op(loc, "DICT_UPDATE", 167, 2, 1)
  36. # PyPy only
  37. # ----------
  38. loc["hasvargs"].append(202)
  39. nargs_op(loc, "CALL_METHOD_KW", 204, -1, 1)
  40. # Used only in single-mode compilation list-comprehension generators
  41. jrel_op(loc, 'SETUP_EXCEPT', 120, 0, 6, conditional=True) # ""
  42. varargs_op(loc, "BUILD_LIST_FROM_ARG", 203)
  43. def_op(loc, "LOAD_REVDB_VAR", 205)
  44. # fmt: on
  45. opcode_arg_fmt = opcode_arg_fmt310pypy = opcode_arg_fmt310.copy()
  46. opcode_extended_fmt = opcode_extended_fmt310pypy = opcode_extended_fmt310.copy()
  47. update_pj3(globals(), loc)
  48. finalize_opcodes(loc)