From 734cc3d9f51cb9b250d92398d29e2bf359f75880 Mon Sep 17 00:00:00 2001 From: Jacob Bower Date: Thu, 30 Nov 2023 09:22:56 -0800 Subject: [PATCH] Introduce CinderX-private opcode definitions Summary: Refactor `Lib/opcode.py` to include a hook which will load cinderx opcode details if present, and add `CinderX/Interpreter/[opcode,cinderx_opcode_targets].h`. The new `opcode.h` is used throughout the CinderX code and `cinderx_opcode_targets.h` will be used when we have our own version of the interpreter. For now we include a hack in the makefile regen rules which mean both new and old headers have the same content. When we add a forked interpreter we'll strip all CinderX opcodes from `Python/[opcode,opcode_targets].h`. Some tests we modified for CinderX-specific opcode changes are now moved to `test_cinderx`. Reviewed By: DinoV Differential Revision: D51538479 fbshipit-source-id: 134a931a47a4358dced99bf97ae842e7695434ef --- CinderX/Interpreter/cinderx_opcode_targets.h | 587 ++++++++++++++++++ CinderX/Interpreter/opcode.h | 265 ++++++++ CinderX/Jit/bytecode.cpp | 3 +- CinderX/Jit/bytecode.h | 2 +- CinderX/Jit/codegen/gen_asm.h | 2 +- CinderX/Jit/hir/builder.cpp | 2 +- CinderX/Jit/hir/hir.h | 2 +- CinderX/Jit/hir/preload.cpp | 2 +- CinderX/Jit/profile_runtime.cpp | 2 +- CinderX/Makefile | 20 + CinderX/RuntimeTests/bytecode_test.cpp | 2 +- CinderX/RuntimeTests/deopt_test.cpp | 2 +- CinderX/RuntimeTests/hir_frame_state_test.cpp | 3 +- .../RuntimeTests/hir_operand_type_test.cpp | 2 +- CinderX/RuntimeTests/hir_test.cpp | 2 +- CinderX/Shadowcode/shadowcode.c | 3 +- CinderX/Shadowcode/shadowcode.h | 4 +- CinderX/StaticPython/classloader.c | 4 +- CinderX/TestScripts/cinder_skip_test.txt | 2 + CinderX/TestScripts/no_cinderx_skip_tests.txt | 1 + .../test_cpython_overrides/test__opcode.py | 115 ++++ .../test_cpython_overrides/test_dis.py | 26 + Lib/cinderx/__init__.py | 5 +- Lib/cinderx/opcode.py | 145 +++++ Lib/compileall.py | 2 +- Lib/opcode.py | 141 +---- Lib/sitecustomize.py | 2 +- Lib/test/test__opcode.py | 48 -- Lib/test/test_dis.py | 13 +- Makefile.pre.in | 14 +- Python/makeopcodetargets.py | 5 +- configure | 1 + configure.ac | 1 + 33 files changed, 1215 insertions(+), 215 deletions(-) create mode 100644 CinderX/Interpreter/cinderx_opcode_targets.h create mode 100644 CinderX/Interpreter/opcode.h create mode 100644 CinderX/test_cinderx/test_cpython_overrides/test__opcode.py create mode 100644 CinderX/test_cinderx/test_cpython_overrides/test_dis.py create mode 100644 Lib/cinderx/opcode.py diff --git a/CinderX/Interpreter/cinderx_opcode_targets.h b/CinderX/Interpreter/cinderx_opcode_targets.h new file mode 100644 index 00000000000..203e8e3e0b2 --- /dev/null +++ b/CinderX/Interpreter/cinderx_opcode_targets.h @@ -0,0 +1,587 @@ +static void *opcode_targets[256] = { + &&_unknown_opcode, + &&TARGET_POP_TOP, + &&TARGET_ROT_TWO, + &&TARGET_ROT_THREE, + &&TARGET_DUP_TOP, + &&TARGET_DUP_TOP_TWO, + &&TARGET_ROT_FOUR, + &&_unknown_opcode, + &&_unknown_opcode, + &&TARGET_NOP, + &&TARGET_UNARY_POSITIVE, + &&TARGET_UNARY_NEGATIVE, + &&TARGET_UNARY_NOT, + &&_unknown_opcode, + &&_unknown_opcode, + &&TARGET_UNARY_INVERT, + &&TARGET_BINARY_MATRIX_MULTIPLY, + &&TARGET_INPLACE_MATRIX_MULTIPLY, + &&_unknown_opcode, + &&TARGET_BINARY_POWER, + &&TARGET_BINARY_MULTIPLY, + &&_unknown_opcode, + &&TARGET_BINARY_MODULO, + &&TARGET_BINARY_ADD, + &&TARGET_BINARY_SUBTRACT, + &&TARGET_BINARY_SUBSCR, + &&TARGET_BINARY_FLOOR_DIVIDE, + &&TARGET_BINARY_TRUE_DIVIDE, + &&TARGET_INPLACE_FLOOR_DIVIDE, + &&TARGET_INPLACE_TRUE_DIVIDE, + &&TARGET_GET_LEN, + &&TARGET_MATCH_MAPPING, + &&TARGET_MATCH_SEQUENCE, + &&TARGET_MATCH_KEYS, + &&TARGET_COPY_DICT_WITHOUT_KEYS, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&TARGET_WITH_EXCEPT_START, + &&TARGET_GET_AITER, + &&TARGET_GET_ANEXT, + &&TARGET_BEFORE_ASYNC_WITH, + &&_unknown_opcode, + &&TARGET_END_ASYNC_FOR, + &&TARGET_INPLACE_ADD, + &&TARGET_INPLACE_SUBTRACT, + &&TARGET_INPLACE_MULTIPLY, + &&_unknown_opcode, + &&TARGET_INPLACE_MODULO, + &&TARGET_STORE_SUBSCR, + &&TARGET_DELETE_SUBSCR, + &&TARGET_BINARY_LSHIFT, + &&TARGET_BINARY_RSHIFT, + &&TARGET_BINARY_AND, + &&TARGET_BINARY_XOR, + &&TARGET_BINARY_OR, + &&TARGET_INPLACE_POWER, + &&TARGET_GET_ITER, + &&TARGET_GET_YIELD_FROM_ITER, + &&TARGET_PRINT_EXPR, + &&TARGET_LOAD_BUILD_CLASS, + &&TARGET_YIELD_FROM, + &&TARGET_GET_AWAITABLE, + &&TARGET_LOAD_ASSERTION_ERROR, + &&TARGET_INPLACE_LSHIFT, + &&TARGET_INPLACE_RSHIFT, + &&TARGET_INPLACE_AND, + &&TARGET_INPLACE_XOR, + &&TARGET_INPLACE_OR, + &&_unknown_opcode, + &&_unknown_opcode, + &&TARGET_LIST_TO_TUPLE, + &&TARGET_RETURN_VALUE, + &&TARGET_IMPORT_STAR, + &&TARGET_SETUP_ANNOTATIONS, + &&TARGET_YIELD_VALUE, + &&TARGET_POP_BLOCK, + &&_unknown_opcode, + &&TARGET_POP_EXCEPT, + &&TARGET_STORE_NAME, + &&TARGET_DELETE_NAME, + &&TARGET_UNPACK_SEQUENCE, + &&TARGET_FOR_ITER, + &&TARGET_UNPACK_EX, + &&TARGET_STORE_ATTR, + &&TARGET_DELETE_ATTR, + &&TARGET_STORE_GLOBAL, + &&TARGET_DELETE_GLOBAL, + &&TARGET_ROT_N, + &&TARGET_LOAD_CONST, + &&TARGET_LOAD_NAME, + &&TARGET_BUILD_TUPLE, + &&TARGET_BUILD_LIST, + &&TARGET_BUILD_SET, + &&TARGET_BUILD_MAP, + &&TARGET_LOAD_ATTR, + &&TARGET_COMPARE_OP, + &&TARGET_IMPORT_NAME, + &&TARGET_IMPORT_FROM, + &&TARGET_JUMP_FORWARD, + &&TARGET_JUMP_IF_FALSE_OR_POP, + &&TARGET_JUMP_IF_TRUE_OR_POP, + &&TARGET_JUMP_ABSOLUTE, + &&TARGET_POP_JUMP_IF_FALSE, + &&TARGET_POP_JUMP_IF_TRUE, + &&TARGET_LOAD_GLOBAL, + &&TARGET_IS_OP, + &&TARGET_CONTAINS_OP, + &&TARGET_RERAISE, + &&_unknown_opcode, + &&TARGET_JUMP_IF_NOT_EXC_MATCH, + &&TARGET_SETUP_FINALLY, + &&_unknown_opcode, + &&TARGET_LOAD_FAST, + &&TARGET_STORE_FAST, + &&TARGET_DELETE_FAST, + &&_unknown_opcode, + &&_unknown_opcode, + &&TARGET_GEN_START, + &&TARGET_RAISE_VARARGS, + &&TARGET_CALL_FUNCTION, + &&TARGET_MAKE_FUNCTION, + &&TARGET_BUILD_SLICE, + &&_unknown_opcode, + &&TARGET_LOAD_CLOSURE, + &&TARGET_LOAD_DEREF, + &&TARGET_STORE_DEREF, + &&TARGET_DELETE_DEREF, + &&_unknown_opcode, + &&_unknown_opcode, + &&TARGET_CALL_FUNCTION_KW, + &&TARGET_CALL_FUNCTION_EX, + &&TARGET_SETUP_WITH, + &&TARGET_EXTENDED_ARG, + &&TARGET_LIST_APPEND, + &&TARGET_SET_ADD, + &&TARGET_MAP_ADD, + &&TARGET_LOAD_CLASSDEREF, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&TARGET_MATCH_CLASS, + &&_unknown_opcode, + &&TARGET_SETUP_ASYNC_WITH, + &&TARGET_FORMAT_VALUE, + &&TARGET_BUILD_CONST_KEY_MAP, + &&TARGET_BUILD_STRING, +#ifdef ENABLE_CINDERX + &&TARGET_INVOKE_METHOD, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_FIELD, +#else + &&_unknown_opcode, +#endif + &&TARGET_LOAD_METHOD, + &&TARGET_CALL_METHOD, + &&TARGET_LIST_EXTEND, + &&TARGET_SET_UPDATE, + &&TARGET_DICT_MERGE, + &&TARGET_DICT_UPDATE, +#ifdef ENABLE_CINDERX + &&TARGET_STORE_FIELD, +#else + &&_unknown_opcode, +#endif + &&_unknown_opcode, +#ifdef ENABLE_CINDERX + &&TARGET_BUILD_CHECKED_LIST, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_TYPE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_CAST, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_LOCAL, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_STORE_LOCAL, +#else + &&_unknown_opcode, +#endif + &&_unknown_opcode, +#ifdef ENABLE_CINDERX + &&TARGET_PRIMITIVE_BOX, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_POP_JUMP_IF_ZERO, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_POP_JUMP_IF_NONZERO, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_PRIMITIVE_UNBOX, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_PRIMITIVE_BINARY_OP, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_PRIMITIVE_UNARY_OP, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_PRIMITIVE_COMPARE_OP, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ITERABLE_ARG, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_MAPPING_ARG, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_INVOKE_FUNCTION, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_JUMP_IF_ZERO_OR_POP, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_JUMP_IF_NONZERO_OR_POP, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_FAST_LEN, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_CONVERT_PRIMITIVE, +#else + &&_unknown_opcode, +#endif + &&_unknown_opcode, +#ifdef ENABLE_CINDERX + &&TARGET_INVOKE_NATIVE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_CLASS, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_BUILD_CHECKED_MAP, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_SEQUENCE_GET, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_SEQUENCE_SET, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LIST_DEL, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_REFINE_TYPE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_PRIMITIVE_LOAD_CONST, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_RETURN_PRIMITIVE, +#else + &&_unknown_opcode, +#endif + &&TARGET_LOAD_METHOD_SUPER, + &&TARGET_LOAD_ATTR_SUPER, +#ifdef ENABLE_CINDERX + &&TARGET_TP_ALLOC, +#else + &&_unknown_opcode, +#endif + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_UNSHADOWED_METHOD, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_TYPE_METHODLIKE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_BUILD_CHECKED_LIST_CACHED, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_TP_ALLOC_CACHED, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_S_MODULE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_S_MODULE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_INVOKE_FUNCTION_CACHED, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_INVOKE_FUNCTION_INDIRECT_CACHED, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_BUILD_CHECKED_MAP_CACHED, +#else + &&_unknown_opcode, +#endif + &&_unknown_opcode, +#ifdef ENABLE_CINDERX + &&TARGET_PRIMITIVE_STORE_FAST, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_CAST_CACHED_OPTIONAL, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_CAST_CACHED, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_CAST_CACHED_EXACT, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_CAST_CACHED_OPTIONAL_EXACT, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_PRIMITIVE_FIELD, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_STORE_PRIMITIVE_FIELD, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_OBJ_FIELD, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_STORE_OBJ_FIELD, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_INVOKE_METHOD_CACHED, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_BINARY_SUBSCR_TUPLE_CONST_INT, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_BINARY_SUBSCR_DICT_STR, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_BINARY_SUBSCR_LIST, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_BINARY_SUBSCR_TUPLE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_BINARY_SUBSCR_DICT, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_UNCACHABLE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_MODULE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_TYPE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_SPLIT_DICT_DESCR, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_SPLIT_DICT_METHOD, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_DICT_DESCR, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_DICT_METHOD, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_NO_DICT_METHOD, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_METHOD_NO_DICT_DESCR, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_STORE_ATTR_SLOT, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_STORE_ATTR_SPLIT_DICT, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_STORE_ATTR_DESCR, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_STORE_ATTR_UNCACHABLE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_STORE_ATTR_DICT, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_POLYMORPHIC, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_SLOT, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_MODULE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_TYPE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_SPLIT_DICT_DESCR, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_SPLIT_DICT, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_DICT_NO_DESCR, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_NO_DICT_DESCR, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_DICT_DESCR, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_ATTR_UNCACHABLE, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_LOAD_GLOBAL_CACHED, +#else + &&_unknown_opcode, +#endif +#ifdef ENABLE_CINDERX + &&TARGET_SHADOW_NOP, +#else + &&_unknown_opcode, +#endif + +}; diff --git a/CinderX/Interpreter/opcode.h b/CinderX/Interpreter/opcode.h new file mode 100644 index 00000000000..840a8f7c56a --- /dev/null +++ b/CinderX/Interpreter/opcode.h @@ -0,0 +1,265 @@ +/* Auto-generated by Tools/scripts/generate_opcode_h.py from Lib/opcode.py */ +#ifndef Py_OPCODE_H +#define Py_OPCODE_H +#ifdef __cplusplus +extern "C" { +#endif + + + /* Instruction opcodes for compiled code */ +#define PY_OPCODES(X) \ + X(POP_TOP, 1) \ + X(ROT_TWO, 2) \ + X(ROT_THREE, 3) \ + X(DUP_TOP, 4) \ + X(DUP_TOP_TWO, 5) \ + X(ROT_FOUR, 6) \ + X(NOP, 9) \ + X(UNARY_POSITIVE, 10) \ + X(UNARY_NEGATIVE, 11) \ + X(UNARY_NOT, 12) \ + X(UNARY_INVERT, 15) \ + X(BINARY_MATRIX_MULTIPLY, 16) \ + X(INPLACE_MATRIX_MULTIPLY, 17) \ + X(BINARY_POWER, 19) \ + X(BINARY_MULTIPLY, 20) \ + X(BINARY_MODULO, 22) \ + X(BINARY_ADD, 23) \ + X(BINARY_SUBTRACT, 24) \ + X(BINARY_SUBSCR, 25) \ + X(BINARY_FLOOR_DIVIDE, 26) \ + X(BINARY_TRUE_DIVIDE, 27) \ + X(INPLACE_FLOOR_DIVIDE, 28) \ + X(INPLACE_TRUE_DIVIDE, 29) \ + X(GET_LEN, 30) \ + X(MATCH_MAPPING, 31) \ + X(MATCH_SEQUENCE, 32) \ + X(MATCH_KEYS, 33) \ + X(COPY_DICT_WITHOUT_KEYS, 34) \ + X(WITH_EXCEPT_START, 49) \ + X(GET_AITER, 50) \ + X(GET_ANEXT, 51) \ + X(BEFORE_ASYNC_WITH, 52) \ + X(END_ASYNC_FOR, 54) \ + X(INPLACE_ADD, 55) \ + X(INPLACE_SUBTRACT, 56) \ + X(INPLACE_MULTIPLY, 57) \ + X(INPLACE_MODULO, 59) \ + X(STORE_SUBSCR, 60) \ + X(DELETE_SUBSCR, 61) \ + X(BINARY_LSHIFT, 62) \ + X(BINARY_RSHIFT, 63) \ + X(BINARY_AND, 64) \ + X(BINARY_XOR, 65) \ + X(BINARY_OR, 66) \ + X(INPLACE_POWER, 67) \ + X(GET_ITER, 68) \ + X(GET_YIELD_FROM_ITER, 69) \ + X(PRINT_EXPR, 70) \ + X(LOAD_BUILD_CLASS, 71) \ + X(YIELD_FROM, 72) \ + X(GET_AWAITABLE, 73) \ + X(LOAD_ASSERTION_ERROR, 74) \ + X(INPLACE_LSHIFT, 75) \ + X(INPLACE_RSHIFT, 76) \ + X(INPLACE_AND, 77) \ + X(INPLACE_XOR, 78) \ + X(INPLACE_OR, 79) \ + X(LIST_TO_TUPLE, 82) \ + X(RETURN_VALUE, 83) \ + X(IMPORT_STAR, 84) \ + X(SETUP_ANNOTATIONS, 85) \ + X(YIELD_VALUE, 86) \ + X(POP_BLOCK, 87) \ + X(POP_EXCEPT, 89) \ + X(HAVE_ARGUMENT, 90) \ + X(STORE_NAME, 90) \ + X(DELETE_NAME, 91) \ + X(UNPACK_SEQUENCE, 92) \ + X(FOR_ITER, 93) \ + X(UNPACK_EX, 94) \ + X(STORE_ATTR, 95) \ + X(DELETE_ATTR, 96) \ + X(STORE_GLOBAL, 97) \ + X(DELETE_GLOBAL, 98) \ + X(ROT_N, 99) \ + X(LOAD_CONST, 100) \ + X(LOAD_NAME, 101) \ + X(BUILD_TUPLE, 102) \ + X(BUILD_LIST, 103) \ + X(BUILD_SET, 104) \ + X(BUILD_MAP, 105) \ + X(LOAD_ATTR, 106) \ + X(COMPARE_OP, 107) \ + X(IMPORT_NAME, 108) \ + X(IMPORT_FROM, 109) \ + X(JUMP_FORWARD, 110) \ + X(JUMP_IF_FALSE_OR_POP, 111) \ + X(JUMP_IF_TRUE_OR_POP, 112) \ + X(JUMP_ABSOLUTE, 113) \ + X(POP_JUMP_IF_FALSE, 114) \ + X(POP_JUMP_IF_TRUE, 115) \ + X(LOAD_GLOBAL, 116) \ + X(IS_OP, 117) \ + X(CONTAINS_OP, 118) \ + X(RERAISE, 119) \ + X(JUMP_IF_NOT_EXC_MATCH, 121) \ + X(SETUP_FINALLY, 122) \ + X(LOAD_FAST, 124) \ + X(STORE_FAST, 125) \ + X(DELETE_FAST, 126) \ + X(GEN_START, 129) \ + X(RAISE_VARARGS, 130) \ + X(CALL_FUNCTION, 131) \ + X(MAKE_FUNCTION, 132) \ + X(BUILD_SLICE, 133) \ + X(LOAD_CLOSURE, 135) \ + X(LOAD_DEREF, 136) \ + X(STORE_DEREF, 137) \ + X(DELETE_DEREF, 138) \ + X(CALL_FUNCTION_KW, 141) \ + X(CALL_FUNCTION_EX, 142) \ + X(SETUP_WITH, 143) \ + X(EXTENDED_ARG, 144) \ + X(LIST_APPEND, 145) \ + X(SET_ADD, 146) \ + X(MAP_ADD, 147) \ + X(LOAD_CLASSDEREF, 148) \ + X(MATCH_CLASS, 152) \ + X(SETUP_ASYNC_WITH, 154) \ + X(FORMAT_VALUE, 155) \ + X(BUILD_CONST_KEY_MAP, 156) \ + X(BUILD_STRING, 157) \ + X(INVOKE_METHOD, 158) \ + X(LOAD_FIELD, 159) \ + X(LOAD_METHOD, 160) \ + X(CALL_METHOD, 161) \ + X(LIST_EXTEND, 162) \ + X(SET_UPDATE, 163) \ + X(DICT_MERGE, 164) \ + X(DICT_UPDATE, 165) \ + X(STORE_FIELD, 166) \ + X(BUILD_CHECKED_LIST, 168) \ + X(LOAD_TYPE, 169) \ + X(CAST, 170) \ + X(LOAD_LOCAL, 171) \ + X(STORE_LOCAL, 172) \ + X(PRIMITIVE_BOX, 174) \ + X(POP_JUMP_IF_ZERO, 175) \ + X(POP_JUMP_IF_NONZERO, 176) \ + X(PRIMITIVE_UNBOX, 177) \ + X(PRIMITIVE_BINARY_OP, 178) \ + X(PRIMITIVE_UNARY_OP, 179) \ + X(PRIMITIVE_COMPARE_OP, 180) \ + X(LOAD_ITERABLE_ARG, 181) \ + X(LOAD_MAPPING_ARG, 182) \ + X(INVOKE_FUNCTION, 183) \ + X(JUMP_IF_ZERO_OR_POP, 184) \ + X(JUMP_IF_NONZERO_OR_POP, 185) \ + X(FAST_LEN, 186) \ + X(CONVERT_PRIMITIVE, 187) \ + X(INVOKE_NATIVE, 189) \ + X(LOAD_CLASS, 190) \ + X(BUILD_CHECKED_MAP, 191) \ + X(SEQUENCE_GET, 192) \ + X(SEQUENCE_SET, 193) \ + X(LIST_DEL, 194) \ + X(REFINE_TYPE, 195) \ + X(PRIMITIVE_LOAD_CONST, 196) \ + X(RETURN_PRIMITIVE, 197) \ + X(LOAD_METHOD_SUPER, 198) \ + X(LOAD_ATTR_SUPER, 199) \ + X(TP_ALLOC, 200) \ + X(LOAD_METHOD_UNSHADOWED_METHOD, 205) \ + X(LOAD_METHOD_TYPE_METHODLIKE, 206) \ + X(BUILD_CHECKED_LIST_CACHED, 207) \ + X(TP_ALLOC_CACHED, 208) \ + X(LOAD_ATTR_S_MODULE, 209) \ + X(LOAD_METHOD_S_MODULE, 210) \ + X(INVOKE_FUNCTION_CACHED, 211) \ + X(INVOKE_FUNCTION_INDIRECT_CACHED, 212) \ + X(BUILD_CHECKED_MAP_CACHED, 213) \ + X(PRIMITIVE_STORE_FAST, 215) \ + X(CAST_CACHED_OPTIONAL, 216) \ + X(CAST_CACHED, 217) \ + X(CAST_CACHED_EXACT, 218) \ + X(CAST_CACHED_OPTIONAL_EXACT, 219) \ + X(LOAD_PRIMITIVE_FIELD, 220) \ + X(STORE_PRIMITIVE_FIELD, 221) \ + X(LOAD_OBJ_FIELD, 222) \ + X(STORE_OBJ_FIELD, 223) \ + X(INVOKE_METHOD_CACHED, 224) \ + X(BINARY_SUBSCR_TUPLE_CONST_INT, 225) \ + X(BINARY_SUBSCR_DICT_STR, 226) \ + X(BINARY_SUBSCR_LIST, 227) \ + X(BINARY_SUBSCR_TUPLE, 228) \ + X(BINARY_SUBSCR_DICT, 229) \ + X(LOAD_METHOD_UNCACHABLE, 230) \ + X(LOAD_METHOD_MODULE, 231) \ + X(LOAD_METHOD_TYPE, 232) \ + X(LOAD_METHOD_SPLIT_DICT_DESCR, 233) \ + X(LOAD_METHOD_SPLIT_DICT_METHOD, 234) \ + X(LOAD_METHOD_DICT_DESCR, 235) \ + X(LOAD_METHOD_DICT_METHOD, 236) \ + X(LOAD_METHOD_NO_DICT_METHOD, 237) \ + X(LOAD_METHOD_NO_DICT_DESCR, 238) \ + X(STORE_ATTR_SLOT, 239) \ + X(STORE_ATTR_SPLIT_DICT, 240) \ + X(STORE_ATTR_DESCR, 241) \ + X(STORE_ATTR_UNCACHABLE, 242) \ + X(STORE_ATTR_DICT, 243) \ + X(LOAD_ATTR_POLYMORPHIC, 244) \ + X(LOAD_ATTR_SLOT, 245) \ + X(LOAD_ATTR_MODULE, 246) \ + X(LOAD_ATTR_TYPE, 247) \ + X(LOAD_ATTR_SPLIT_DICT_DESCR, 248) \ + X(LOAD_ATTR_SPLIT_DICT, 249) \ + X(LOAD_ATTR_DICT_NO_DESCR, 250) \ + X(LOAD_ATTR_NO_DICT_DESCR, 251) \ + X(LOAD_ATTR_DICT_DESCR, 252) \ + X(LOAD_ATTR_UNCACHABLE, 253) \ + X(LOAD_GLOBAL_CACHED, 254) \ + X(SHADOW_NOP, 255) + +#ifdef NEED_OPCODE_JUMP_TABLES +static uint32_t _PyOpcode_RelativeJump[8] = { + 0U, + 0U, + 536870912U, + 67125248U, + 67141632U, + 0U, + 0U, + 0U, +}; +static uint32_t _PyOpcode_Jump[8] = { + 0U, + 0U, + 536870912U, + 101695488U, + 67141632U, + 50429952U, + 0U, + 0U, +}; +#endif /* OPCODE_TABLES */ + + +enum { +#define OP(op, value) op = value, +PY_OPCODES(OP) +#undef OP +}; + +/* EXCEPT_HANDLER is a special, implicit block type which is created when + entering an except handler. It is not an opcode but we define it here + as we want it to be available to both frameobject.c and ceval.c, while + remaining private.*/ +#define EXCEPT_HANDLER 257 + +#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OPCODE_H */ diff --git a/CinderX/Jit/bytecode.cpp b/CinderX/Jit/bytecode.cpp index 205ce89ab8a..bde1968e289 100644 --- a/CinderX/Jit/bytecode.cpp +++ b/CinderX/Jit/bytecode.cpp @@ -1,9 +1,8 @@ // Copyright (c) Meta Platforms, Inc. and affiliates. (http://www.meta.com) +#include "Interpreter/opcode.h" #include "Jit/bytecode.h" -#include "opcode.h" - #include namespace jit { diff --git a/CinderX/Jit/bytecode.h b/CinderX/Jit/bytecode.h index b01ef02cc01..4cfda4bfd65 100644 --- a/CinderX/Jit/bytecode.h +++ b/CinderX/Jit/bytecode.h @@ -3,8 +3,8 @@ #pragma once #include "Python.h" -#include "opcode.h" +#include "Interpreter/opcode.h" #include "Jit/bytecode_offsets.h" #include "Jit/log.h" diff --git a/CinderX/Jit/codegen/gen_asm.h b/CinderX/Jit/codegen/gen_asm.h index 4d9771f9df4..55dafa636a5 100644 --- a/CinderX/Jit/codegen/gen_asm.h +++ b/CinderX/Jit/codegen/gen_asm.h @@ -3,8 +3,8 @@ #pragma once #include "Python.h" -#include "opcode.h" +#include "Interpreter/opcode.h" #include "Jit/bitvector.h" #include "Jit/codegen/environ.h" #include "Jit/codegen/x86_64.h" diff --git a/CinderX/Jit/hir/builder.cpp b/CinderX/Jit/hir/builder.cpp index 6f4341db3a2..e576480517d 100644 --- a/CinderX/Jit/hir/builder.cpp +++ b/CinderX/Jit/hir/builder.cpp @@ -8,11 +8,11 @@ #include "boolobject.h" #include "ceval.h" #include "object.h" -#include "opcode.h" #include "preload.h" #include "structmember.h" #include "type.h" +#include "Interpreter/opcode.h" #include "Jit/bitvector.h" #include "Jit/bytecode.h" #include "Jit/codegen/environ.h" diff --git a/CinderX/Jit/hir/hir.h b/CinderX/Jit/hir/hir.h index b447468bf62..170c645609f 100644 --- a/CinderX/Jit/hir/hir.h +++ b/CinderX/Jit/hir/hir.h @@ -4,8 +4,8 @@ #include "Python.h" #include "code.h" -#include "opcode.h" +#include "Interpreter/opcode.h" #include "Jit/bytecode.h" #include "Jit/config.h" #include "Jit/deopt_patcher.h" diff --git a/CinderX/Jit/hir/preload.cpp b/CinderX/Jit/hir/preload.cpp index 3ab645f15fa..ddb55ea76b2 100644 --- a/CinderX/Jit/hir/preload.cpp +++ b/CinderX/Jit/hir/preload.cpp @@ -3,8 +3,8 @@ #include "Jit/hir/preload.h" #include "Python.h" -#include "opcode.h" +#include "Interpreter/opcode.h" #include "Jit/bytecode.h" #include "Jit/codegen/gen_asm.h" #include "Jit/hir/optimization.h" diff --git a/CinderX/Jit/profile_runtime.cpp b/CinderX/Jit/profile_runtime.cpp index 953edbb212c..1c9a286841d 100644 --- a/CinderX/Jit/profile_runtime.cpp +++ b/CinderX/Jit/profile_runtime.cpp @@ -5,8 +5,8 @@ #include "Objects/dict-common.h" #include "Python.h" #include "frameobject.h" -#include "opcode.h" +#include "Interpreter/opcode.h" #include "Jit/hir/type.h" #include "Jit/live_type_map.h" #include "Jit/log.h" diff --git a/CinderX/Makefile b/CinderX/Makefile index 0637554a819..045abb3a88c 100644 --- a/CinderX/Makefile +++ b/CinderX/Makefile @@ -260,3 +260,23 @@ test_strict_module: $(STRICTM_TESTS_BUILD_DIR)/strict_module_tests $(TESTPYTHON) $(CURDIR)/ThirdParty/gtest-parallel/gtest-parallel \ $(STRICTM_TESTS_BUILD_DIR)/strict_module_tests -- $(STRICTM_ASAN_SKIP_TESTS) .PHONY: test_strict_module + + +# +# Regen rules +# + +UPDATE_FILE=python3 $(abs_srcdir)/Tools/scripts/update_file.py + +.PHONY: regen-opcode +regen-opcode: + PYTHONPATH=$(CURDIR) python3 $(abs_srcdir)/Tools/scripts/generate_opcode_h.py \ + $(abs_srcdir)/Lib/opcode.py \ + Interpreter/opcode.h.new + $(UPDATE_FILE) Interpreter/opcode.h Interpreter/opcode.h.new + +.PHONY: regen-opcode-targets +regen-opcode-targets: + PYTHONPATH=$(CURDIR) python3 $(abs_srcdir)/Python/makeopcodetargets.py Interpreter/cinderx_opcode_targets.h.new + $(UPDATE_FILE) Interpreter/cinderx_opcode_targets.h Interpreter/cinderx_opcode_targets.h.new + diff --git a/CinderX/RuntimeTests/bytecode_test.cpp b/CinderX/RuntimeTests/bytecode_test.cpp index 904433c17b5..b63bacfe07f 100644 --- a/CinderX/RuntimeTests/bytecode_test.cpp +++ b/CinderX/RuntimeTests/bytecode_test.cpp @@ -2,8 +2,8 @@ #include #include "Python.h" -#include "opcode.h" +#include "Interpreter/opcode.h" #include "Jit/bytecode.h" #include "RuntimeTests/fixtures.h" diff --git a/CinderX/RuntimeTests/deopt_test.cpp b/CinderX/RuntimeTests/deopt_test.cpp index a7e9e2aa062..a06ee6bc78a 100644 --- a/CinderX/RuntimeTests/deopt_test.cpp +++ b/CinderX/RuntimeTests/deopt_test.cpp @@ -2,7 +2,7 @@ #include #include "Python.h" -#include "opcode.h" +#include "Interpreter/opcode.h" #include "Jit/codegen/gen_asm.h" #include "Jit/codegen/x86_64.h" diff --git a/CinderX/RuntimeTests/hir_frame_state_test.cpp b/CinderX/RuntimeTests/hir_frame_state_test.cpp index 095c747dc32..7d3a916a760 100644 --- a/CinderX/RuntimeTests/hir_frame_state_test.cpp +++ b/CinderX/RuntimeTests/hir_frame_state_test.cpp @@ -2,7 +2,8 @@ #include #include "Python.h" -#include "opcode.h" + +#include "Interpreter/opcode.h" #include "Jit/hir/builder.h" #include "Jit/hir/hir.h" diff --git a/CinderX/RuntimeTests/hir_operand_type_test.cpp b/CinderX/RuntimeTests/hir_operand_type_test.cpp index 61c60120491..88cfb73f934 100644 --- a/CinderX/RuntimeTests/hir_operand_type_test.cpp +++ b/CinderX/RuntimeTests/hir_operand_type_test.cpp @@ -2,8 +2,8 @@ #include #include "Python.h" -#include "opcode.h" +#include "Interpreter/opcode.h" #include "Jit/hir/analysis.h" #include "Jit/hir/hir.h" #include "Jit/hir/parser.h" diff --git a/CinderX/RuntimeTests/hir_test.cpp b/CinderX/RuntimeTests/hir_test.cpp index 02c40270fa8..1c67d028b0f 100644 --- a/CinderX/RuntimeTests/hir_test.cpp +++ b/CinderX/RuntimeTests/hir_test.cpp @@ -2,8 +2,8 @@ #include #include "Python.h" -#include "opcode.h" +#include "Interpreter/opcode.h" #include "Jit/compiler.h" #include "Jit/hir/builder.h" #include "Jit/hir/hir.h" diff --git a/CinderX/Shadowcode/shadowcode.c b/CinderX/Shadowcode/shadowcode.c index 6f521ea981a..d48c36406f7 100644 --- a/CinderX/Shadowcode/shadowcode.c +++ b/CinderX/Shadowcode/shadowcode.c @@ -22,9 +22,10 @@ #include "cinder/exports.h" // This relies on Python internals. -#include "opcode.h" #include "Python/wordcode_helpers.h" +#include "Interpreter/opcode.h" + #define _PyClassMethod_Check(op) (Py_TYPE(op) == &PyClassMethod_Type) #define _PyStaticMethod_Check(op) (Py_TYPE(op) == &PyStaticMethod_Type) #define _PyWrapperDescr_Check(d) (Py_TYPE(d) == &PyWrapperDescr_Type) diff --git a/CinderX/Shadowcode/shadowcode.h b/CinderX/Shadowcode/shadowcode.h index 2f69dab1c88..e8b504a87a8 100644 --- a/CinderX/Shadowcode/shadowcode.h +++ b/CinderX/Shadowcode/shadowcode.h @@ -4,7 +4,6 @@ #include "cinder/hooks.h" #include "Python.h" #include "code.h" -#include "opcode.h" #include "weakrefobject.h" #include "pycore_object.h" #include "pystate.h" @@ -16,6 +15,9 @@ #include "cinder/ci_api.h" #include "CachedProperties/cached_properties.h" +#ifndef Py_OPCODE_H +#include "Interpreter/opcode.h" +#endif #include diff --git a/CinderX/StaticPython/classloader.c b/CinderX/StaticPython/classloader.c index 5a46abd8a29..caffdb6aacd 100644 --- a/CinderX/StaticPython/classloader.c +++ b/CinderX/StaticPython/classloader.c @@ -3,7 +3,6 @@ #include "descrobject.h" #include "dictobject.h" #include "object.h" -#include "opcode.h" #include "pyerrors.h" #include "pyport.h" #include "structmember.h" @@ -14,9 +13,8 @@ #include "cinder/exports.h" #include "CachedProperties/cached_properties.h" - +#include "Interpreter/opcode.h" #include "Jit/pyjit.h" - #include "StaticPython/classloader.h" #include diff --git a/CinderX/TestScripts/cinder_skip_test.txt b/CinderX/TestScripts/cinder_skip_test.txt index a1d34c0c3b7..46fa2564a7a 100644 --- a/CinderX/TestScripts/cinder_skip_test.txt +++ b/CinderX/TestScripts/cinder_skip_test.txt @@ -14,3 +14,5 @@ test.test_threading.SubinterpThreadingTests.* test.test_interpreters.* test.test_capi.CAPITest.test_getitem_with_error test.test_repl.TestInteractiveInterpreter.test_no_memory +test.test__opcode.* +test.test_dis.*.test_widths diff --git a/CinderX/TestScripts/no_cinderx_skip_tests.txt b/CinderX/TestScripts/no_cinderx_skip_tests.txt index af8eaf85c93..63944173011 100644 --- a/CinderX/TestScripts/no_cinderx_skip_tests.txt +++ b/CinderX/TestScripts/no_cinderx_skip_tests.txt @@ -15,3 +15,4 @@ test_compiler_sbs_stdlib_9 test_perf_profiler_precompile.py test_shadowcode test_strictmodule +test_cinderx.test_cpython_overrides.test_capi.CinderX_CAPITest.test_getitem_with_error diff --git a/CinderX/test_cinderx/test_cpython_overrides/test__opcode.py b/CinderX/test_cinderx/test_cpython_overrides/test__opcode.py new file mode 100644 index 00000000000..9ad2967a248 --- /dev/null +++ b/CinderX/test_cinderx/test_cpython_overrides/test__opcode.py @@ -0,0 +1,115 @@ +import dis +import opcode +from test.support.import_helper import import_module +import unittest + +_opcode = import_module("_opcode") +from _opcode import stack_effect + + +MISSING_STACK_EFFECT = { + "LOAD_FIELD", + "STORE_FIELD", + "INVOKE_METHOD", + "BUILD_CHECKED_LIST", + "CAST", + "LOAD_LOCAL", + "STORE_LOCAL", + "PRIMITIVE_BOX", + "POP_JUMP_IF_ZERO", + "POP_JUMP_IF_NONZERO", + "PRIMITIVE_UNBOX", + "PRIMITIVE_BINARY_OP", + "PRIMITIVE_UNARY_OP", + "PRIMITIVE_COMPARE_OP", + "LOAD_ITERABLE_ARG", + "LOAD_MAPPING_ARG", + "INVOKE_FUNCTION", + "INVOKE_NATIVE", + "JUMP_IF_ZERO_OR_POP", + "JUMP_IF_NONZERO_OR_POP", + "FAST_LEN", + "CONVERT_PRIMITIVE", + "LOAD_TYPE", + "LOAD_CLASS", + "BUILD_CHECKED_MAP", + "SEQUENCE_GET", + "SEQUENCE_SET", + "LIST_DEL", + "REFINE_TYPE", + "PRIMITIVE_LOAD_CONST", + "RETURN_PRIMITIVE", + "LOAD_METHOD_SUPER", + "LOAD_ATTR_SUPER", + "TP_ALLOC", +} + + +class OpcodeTests(unittest.TestCase): + + def test_stack_effect(self): + self.assertEqual(stack_effect(dis.opmap['POP_TOP']), -1) + self.assertEqual(stack_effect(dis.opmap['DUP_TOP_TWO']), 2) + self.assertEqual(stack_effect(dis.opmap['BUILD_SLICE'], 0), -1) + self.assertEqual(stack_effect(dis.opmap['BUILD_SLICE'], 1), -1) + self.assertEqual(stack_effect(dis.opmap['BUILD_SLICE'], 3), -2) + self.assertRaises(ValueError, stack_effect, 30000) + self.assertRaises(ValueError, stack_effect, dis.opmap['BUILD_SLICE']) + self.assertRaises(ValueError, stack_effect, dis.opmap['POP_TOP'], 0) + # All defined opcodes + for name, code in dis.opmap.items(): + # TODO(T74641077) - Figure out how to deal with static python opcodes + if name in MISSING_STACK_EFFECT or code in opcode.shadowop: + continue + + with self.subTest(opname=name): + if code < dis.HAVE_ARGUMENT: + stack_effect(code) + self.assertRaises(ValueError, stack_effect, code, 0) + else: + stack_effect(code, 0) + self.assertRaises(ValueError, stack_effect, code) + # All not defined opcodes + for code in set(range(256)) - set(dis.opmap.values()): + with self.subTest(opcode=code): + self.assertRaises(ValueError, stack_effect, code) + self.assertRaises(ValueError, stack_effect, code, 0) + + def test_stack_effect_jump(self): + JUMP_IF_TRUE_OR_POP = dis.opmap['JUMP_IF_TRUE_OR_POP'] + self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0), 0) + self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0, jump=True), 0) + self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0, jump=False), -1) + FOR_ITER = dis.opmap['FOR_ITER'] + self.assertEqual(stack_effect(FOR_ITER, 0), 1) + self.assertEqual(stack_effect(FOR_ITER, 0, jump=True), -1) + self.assertEqual(stack_effect(FOR_ITER, 0, jump=False), 1) + JUMP_FORWARD = dis.opmap['JUMP_FORWARD'] + self.assertEqual(stack_effect(JUMP_FORWARD, 0), 0) + self.assertEqual(stack_effect(JUMP_FORWARD, 0, jump=True), 0) + self.assertEqual(stack_effect(JUMP_FORWARD, 0, jump=False), 0) + # All defined opcodes + has_jump = dis.hasjabs + dis.hasjrel + for name, code in dis.opmap.items(): + # TODO(T74641077) - Figure out how to deal with static python opcodes + if name in MISSING_STACK_EFFECT or code in opcode.shadowop: + continue + + with self.subTest(opname=name): + if code < dis.HAVE_ARGUMENT: + common = stack_effect(code) + jump = stack_effect(code, jump=True) + nojump = stack_effect(code, jump=False) + else: + common = stack_effect(code, 0) + jump = stack_effect(code, 0, jump=True) + nojump = stack_effect(code, 0, jump=False) + if code in has_jump: + self.assertEqual(common, max(jump, nojump)) + else: + self.assertEqual(jump, common) + self.assertEqual(nojump, common) + + +if __name__ == "__main__": + unittest.main() diff --git a/CinderX/test_cinderx/test_cpython_overrides/test_dis.py b/CinderX/test_cinderx/test_cpython_overrides/test_dis.py new file mode 100644 index 00000000000..e0aad2c1c88 --- /dev/null +++ b/CinderX/test_cinderx/test_cpython_overrides/test_dis.py @@ -0,0 +1,26 @@ +import dis +import unittest + +from cinderx.opcode import shadowop + +class CinderX_DisTests(unittest.TestCase): + def test_widths(self): + for opcode, opname in enumerate(dis.opname): + if ( + opname in ( + 'BUILD_MAP_UNPACK_WITH_CALL', + 'BUILD_TUPLE_UNPACK_WITH_CALL', + 'JUMP_IF_NONZERO_OR_POP', + 'JUMP_IF_NOT_EXC_MATCH', + ) + or opcode in shadowop + ): + continue + with self.subTest(opname=opname): + width = dis._OPNAME_WIDTH + if opcode < dis.HAVE_ARGUMENT: + width += 1 + dis._OPARG_WIDTH + self.assertLessEqual(len(opname), width) + +if __name__ == "__main__": + unittest.main() diff --git a/Lib/cinderx/__init__.py b/Lib/cinderx/__init__.py index 45957de3c2d..4aa5703068b 100644 --- a/Lib/cinderx/__init__.py +++ b/Lib/cinderx/__init__.py @@ -1,3 +1,6 @@ """High-performance Python runtime extensions.""" -from _cinderx import * +try: + from _cinderx import * +except ImportError: + pass diff --git a/Lib/cinderx/opcode.py b/Lib/cinderx/opcode.py new file mode 100644 index 00000000000..b50871bc9b5 --- /dev/null +++ b/Lib/cinderx/opcode.py @@ -0,0 +1,145 @@ +shadowop = set() +cinderxop = set() + + +def init(opname, opmap, hasname, hasjrel, hasjabs, hasconst): + + def def_op(name, op): + opname[op] = name + opmap[name] = op + cinderxop.add(name) + + def name_op(name, op): + def_op(name, op) + hasname.append(op) + + def jrel_op(name, op): + def_op(name, op) + hasjrel.append(op) + + def jabs_op(name, op): + def_op(name, op) + hasjabs.append(op) + + def shadow_op(name, op): + def_op(name, op) + shadowop.add(op) + + def_op("INVOKE_METHOD", 158) + hasconst.append(158) + + def_op("LOAD_FIELD", 159) + hasconst.append(159) + def_op("STORE_FIELD", 166) + hasconst.append(166) + + def_op("BUILD_CHECKED_LIST", 168) + hasconst.append(168) + def_op("LOAD_TYPE", 169) + hasconst.append(169) + + def_op("CAST", 170) + hasconst.append(170) + + def_op("LOAD_LOCAL", 171) + hasconst.append(171) + def_op("STORE_LOCAL", 172) + hasconst.append(172) + + def_op("PRIMITIVE_BOX", 174) + + jabs_op("POP_JUMP_IF_ZERO", 175) + jabs_op("POP_JUMP_IF_NONZERO", 176) + + def_op("PRIMITIVE_UNBOX", 177) + + def_op("PRIMITIVE_BINARY_OP", 178) + def_op("PRIMITIVE_UNARY_OP", 179) + def_op("PRIMITIVE_COMPARE_OP", 180) + def_op("LOAD_ITERABLE_ARG", 181) + def_op("LOAD_MAPPING_ARG", 182) + def_op("INVOKE_FUNCTION", 183) + hasconst.append(183) + + jabs_op("JUMP_IF_ZERO_OR_POP", 184) + jabs_op("JUMP_IF_NONZERO_OR_POP", 185) + + def_op("FAST_LEN", 186) + def_op("CONVERT_PRIMITIVE", 187) + + def_op("LOAD_CLASS", 190) + hasconst.append(190) + + def_op("INVOKE_NATIVE", 189) + hasconst.append(189) + + def_op("BUILD_CHECKED_MAP", 191) + hasconst.append(191) + + def_op("SEQUENCE_GET", 192) + def_op("SEQUENCE_SET", 193) + def_op("LIST_DEL", 194) + def_op("REFINE_TYPE", 195) + hasconst.append(195) + def_op("PRIMITIVE_LOAD_CONST", 196) + hasconst.append(196) + def_op("RETURN_PRIMITIVE", 197) + def_op("TP_ALLOC", 200) + hasconst.append(200) + + shadow_op("LOAD_METHOD_UNSHADOWED_METHOD", 205) + shadow_op("LOAD_METHOD_TYPE_METHODLIKE", 206) + shadow_op("BUILD_CHECKED_LIST_CACHED", 207) + shadow_op("TP_ALLOC_CACHED", 208) + shadow_op("LOAD_ATTR_S_MODULE", 209) + shadow_op("LOAD_METHOD_S_MODULE", 210) + shadow_op("INVOKE_FUNCTION_CACHED", 211) + shadow_op("INVOKE_FUNCTION_INDIRECT_CACHED", 212) + shadow_op("BUILD_CHECKED_MAP_CACHED", 213) + + shadow_op("PRIMITIVE_STORE_FAST", 215) + shadow_op("CAST_CACHED_OPTIONAL", 216) + shadow_op("CAST_CACHED", 217) + shadow_op("CAST_CACHED_EXACT", 218) + shadow_op("CAST_CACHED_OPTIONAL_EXACT", 219) + shadow_op("LOAD_PRIMITIVE_FIELD", 220) + shadow_op("STORE_PRIMITIVE_FIELD", 221) + shadow_op("LOAD_OBJ_FIELD", 222) + shadow_op("STORE_OBJ_FIELD", 223) + + shadow_op('INVOKE_METHOD_CACHED', 224) + shadow_op('BINARY_SUBSCR_TUPLE_CONST_INT', 225) + shadow_op('BINARY_SUBSCR_DICT_STR', 226) + shadow_op('BINARY_SUBSCR_LIST', 227) + shadow_op('BINARY_SUBSCR_TUPLE', 228) + shadow_op('BINARY_SUBSCR_DICT', 229) + + shadow_op('LOAD_METHOD_UNCACHABLE', 230) + shadow_op('LOAD_METHOD_MODULE', 231) + shadow_op('LOAD_METHOD_TYPE', 232) + shadow_op('LOAD_METHOD_SPLIT_DICT_DESCR', 233) + shadow_op('LOAD_METHOD_SPLIT_DICT_METHOD', 234) + shadow_op('LOAD_METHOD_DICT_DESCR', 235) + shadow_op('LOAD_METHOD_DICT_METHOD', 236) + shadow_op('LOAD_METHOD_NO_DICT_METHOD', 237) + shadow_op('LOAD_METHOD_NO_DICT_DESCR', 238) + + shadow_op('STORE_ATTR_SLOT', 239) + shadow_op('STORE_ATTR_SPLIT_DICT', 240) + shadow_op('STORE_ATTR_DESCR', 241) + shadow_op('STORE_ATTR_UNCACHABLE', 242) + shadow_op('STORE_ATTR_DICT', 243) + + shadow_op('LOAD_ATTR_POLYMORPHIC', 244) + shadow_op('LOAD_ATTR_SLOT', 245) + shadow_op('LOAD_ATTR_MODULE', 246) + shadow_op('LOAD_ATTR_TYPE', 247) + shadow_op('LOAD_ATTR_SPLIT_DICT_DESCR', 248) + shadow_op('LOAD_ATTR_SPLIT_DICT', 249) + shadow_op('LOAD_ATTR_DICT_NO_DESCR', 250) + shadow_op('LOAD_ATTR_NO_DICT_DESCR', 251) + shadow_op('LOAD_ATTR_DICT_DESCR', 252) + shadow_op('LOAD_ATTR_UNCACHABLE', 253) + + shadow_op('LOAD_GLOBAL_CACHED', 254) + shadow_op('SHADOW_NOP', 255) diff --git a/Lib/compileall.py b/Lib/compileall.py index f25380cb0d7..bb2273eb2ce 100644 --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -14,7 +14,7 @@ try: import cinderx cinderx.init() -except ImportError: +except (ImportError, AttributeError): pass import os diff --git a/Lib/opcode.py b/Lib/opcode.py index 04f48ff6170..80d7fe3ed5f 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -31,17 +31,13 @@ hascompare = [] hasfree = [] hasnargs = [] # unused -shadowop = set() -cinderxop = set() opmap = {} opname = ['<%r>' % (op,) for op in range(256)] -def def_op(name, op, cinderx=False): +def def_op(name, op): opname[op] = name opmap[name] = op - if cinderx: - cinderxop.add(name) def name_op(name, op): def_op(name, op) @@ -51,14 +47,9 @@ def jrel_op(name, op): def_op(name, op) hasjrel.append(op) -def jabs_op(name, op, cinderx=False): - def_op(name, op, cinderx) - hasjabs.append(op) - -def shadow_op(name, op): +def jabs_op(name, op): def_op(name, op) - shadowop.add(op) - cinderxop.add(name) + hasjabs.append(op) # Instruction opcodes for compiled code @@ -223,129 +214,15 @@ def shadow_op(name, op): def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) -# CinderX-specific opcodes - -def_op("INVOKE_METHOD", 158, cinderx=True) -hasconst.append(158) - -def_op("LOAD_FIELD", 159, cinderx=True) -hasconst.append(159) -def_op("STORE_FIELD", 166, cinderx=True) -hasconst.append(166) - -def_op("BUILD_CHECKED_LIST", 168, cinderx=True) -hasconst.append(168) -def_op("LOAD_TYPE", 169, cinderx=True) -hasconst.append(169) - -def_op("CAST", 170, cinderx=True) -hasconst.append(170) - -def_op("LOAD_LOCAL", 171, cinderx=True) -hasconst.append(171) -def_op("STORE_LOCAL", 172, cinderx=True) -hasconst.append(172) - -def_op("PRIMITIVE_BOX", 174, cinderx=True) - -jabs_op("POP_JUMP_IF_ZERO", 175, cinderx=True) -jabs_op("POP_JUMP_IF_NONZERO", 176, cinderx=True) - -def_op("PRIMITIVE_UNBOX", 177, cinderx=True) - -def_op("PRIMITIVE_BINARY_OP", 178, cinderx=True) -def_op("PRIMITIVE_UNARY_OP", 179, cinderx=True) -def_op("PRIMITIVE_COMPARE_OP", 180, cinderx=True) -def_op("LOAD_ITERABLE_ARG", 181, cinderx=True) -def_op("LOAD_MAPPING_ARG", 182, cinderx=True) -def_op("INVOKE_FUNCTION", 183, cinderx=True) -hasconst.append(183) - -jabs_op("JUMP_IF_ZERO_OR_POP", 184, cinderx=True) -jabs_op("JUMP_IF_NONZERO_OR_POP", 185, cinderx=True) - -def_op("FAST_LEN", 186, cinderx=True) -def_op("CONVERT_PRIMITIVE", 187, cinderx=True) - -def_op("LOAD_CLASS", 190, cinderx=True) -hasconst.append(190) - -def_op("INVOKE_NATIVE", 189, cinderx=True) -hasconst.append(189) - -def_op("BUILD_CHECKED_MAP", 191, cinderx=True) -hasconst.append(191) - -def_op("SEQUENCE_GET", 192, cinderx=True) -def_op("SEQUENCE_SET", 193, cinderx=True) -def_op("LIST_DEL", 194, cinderx=True) -def_op("REFINE_TYPE", 195, cinderx=True) -hasconst.append(195) -def_op("PRIMITIVE_LOAD_CONST", 196, cinderx=True) -hasconst.append(196) -def_op("RETURN_PRIMITIVE", 197, cinderx=True) def_op("LOAD_METHOD_SUPER", 198) hasconst.append(198) def_op("LOAD_ATTR_SUPER", 199) hasconst.append(199) -def_op("TP_ALLOC", 200, cinderx=True) -hasconst.append(200) - -shadow_op("LOAD_METHOD_UNSHADOWED_METHOD", 205) -shadow_op("LOAD_METHOD_TYPE_METHODLIKE", 206) -shadow_op("BUILD_CHECKED_LIST_CACHED", 207) -shadow_op("TP_ALLOC_CACHED", 208) -shadow_op("LOAD_ATTR_S_MODULE", 209) -shadow_op("LOAD_METHOD_S_MODULE", 210) -shadow_op("INVOKE_FUNCTION_CACHED", 211) -shadow_op("INVOKE_FUNCTION_INDIRECT_CACHED", 212) -shadow_op("BUILD_CHECKED_MAP_CACHED", 213) - -shadow_op("PRIMITIVE_STORE_FAST", 215) -shadow_op("CAST_CACHED_OPTIONAL", 216) -shadow_op("CAST_CACHED", 217) -shadow_op("CAST_CACHED_EXACT", 218) -shadow_op("CAST_CACHED_OPTIONAL_EXACT", 219) -shadow_op("LOAD_PRIMITIVE_FIELD", 220) -shadow_op("STORE_PRIMITIVE_FIELD", 221) -shadow_op("LOAD_OBJ_FIELD", 222) -shadow_op("STORE_OBJ_FIELD", 223) - -shadow_op('INVOKE_METHOD_CACHED', 224) -shadow_op('BINARY_SUBSCR_TUPLE_CONST_INT', 225) -shadow_op('BINARY_SUBSCR_DICT_STR', 226) -shadow_op('BINARY_SUBSCR_LIST', 227) -shadow_op('BINARY_SUBSCR_TUPLE', 228) -shadow_op('BINARY_SUBSCR_DICT', 229) - -shadow_op('LOAD_METHOD_UNCACHABLE', 230) -shadow_op('LOAD_METHOD_MODULE', 231) -shadow_op('LOAD_METHOD_TYPE', 232) -shadow_op('LOAD_METHOD_SPLIT_DICT_DESCR', 233) -shadow_op('LOAD_METHOD_SPLIT_DICT_METHOD', 234) -shadow_op('LOAD_METHOD_DICT_DESCR', 235) -shadow_op('LOAD_METHOD_DICT_METHOD', 236) -shadow_op('LOAD_METHOD_NO_DICT_METHOD', 237) -shadow_op('LOAD_METHOD_NO_DICT_DESCR', 238) - -shadow_op('STORE_ATTR_SLOT', 239) -shadow_op('STORE_ATTR_SPLIT_DICT', 240) -shadow_op('STORE_ATTR_DESCR', 241) -shadow_op('STORE_ATTR_UNCACHABLE', 242) -shadow_op('STORE_ATTR_DICT', 243) - -shadow_op('LOAD_ATTR_POLYMORPHIC', 244) -shadow_op('LOAD_ATTR_SLOT', 245) -shadow_op('LOAD_ATTR_MODULE', 246) -shadow_op('LOAD_ATTR_TYPE', 247) -shadow_op('LOAD_ATTR_SPLIT_DICT_DESCR', 248) -shadow_op('LOAD_ATTR_SPLIT_DICT', 249) -shadow_op('LOAD_ATTR_DICT_NO_DESCR', 250) -shadow_op('LOAD_ATTR_NO_DICT_DESCR', 251) -shadow_op('LOAD_ATTR_DICT_DESCR', 252) -shadow_op('LOAD_ATTR_UNCACHABLE', 253) - -shadow_op('LOAD_GLOBAL_CACHED', 254) -shadow_op('SHADOW_NOP', 255) + +try: + import cinderx.opcode + cinderx.opcode.init(opname, opmap, hasname, hasjrel, hasjabs, hasconst) +except ImportError: + pass del def_op, name_op, jrel_op, jabs_op diff --git a/Lib/sitecustomize.py b/Lib/sitecustomize.py index b6699017cc9..69a649e17d7 100644 --- a/Lib/sitecustomize.py +++ b/Lib/sitecustomize.py @@ -1,5 +1,5 @@ try: import cinderx cinderx.init() -except ImportError: +except (ImportError, AttributeError): pass diff --git a/Lib/test/test__opcode.py b/Lib/test/test__opcode.py index 9ad2967a248..be8483d146f 100644 --- a/Lib/test/test__opcode.py +++ b/Lib/test/test__opcode.py @@ -1,50 +1,10 @@ import dis -import opcode from test.support.import_helper import import_module import unittest _opcode = import_module("_opcode") from _opcode import stack_effect - -MISSING_STACK_EFFECT = { - "LOAD_FIELD", - "STORE_FIELD", - "INVOKE_METHOD", - "BUILD_CHECKED_LIST", - "CAST", - "LOAD_LOCAL", - "STORE_LOCAL", - "PRIMITIVE_BOX", - "POP_JUMP_IF_ZERO", - "POP_JUMP_IF_NONZERO", - "PRIMITIVE_UNBOX", - "PRIMITIVE_BINARY_OP", - "PRIMITIVE_UNARY_OP", - "PRIMITIVE_COMPARE_OP", - "LOAD_ITERABLE_ARG", - "LOAD_MAPPING_ARG", - "INVOKE_FUNCTION", - "INVOKE_NATIVE", - "JUMP_IF_ZERO_OR_POP", - "JUMP_IF_NONZERO_OR_POP", - "FAST_LEN", - "CONVERT_PRIMITIVE", - "LOAD_TYPE", - "LOAD_CLASS", - "BUILD_CHECKED_MAP", - "SEQUENCE_GET", - "SEQUENCE_SET", - "LIST_DEL", - "REFINE_TYPE", - "PRIMITIVE_LOAD_CONST", - "RETURN_PRIMITIVE", - "LOAD_METHOD_SUPER", - "LOAD_ATTR_SUPER", - "TP_ALLOC", -} - - class OpcodeTests(unittest.TestCase): def test_stack_effect(self): @@ -58,10 +18,6 @@ def test_stack_effect(self): self.assertRaises(ValueError, stack_effect, dis.opmap['POP_TOP'], 0) # All defined opcodes for name, code in dis.opmap.items(): - # TODO(T74641077) - Figure out how to deal with static python opcodes - if name in MISSING_STACK_EFFECT or code in opcode.shadowop: - continue - with self.subTest(opname=name): if code < dis.HAVE_ARGUMENT: stack_effect(code) @@ -91,10 +47,6 @@ def test_stack_effect_jump(self): # All defined opcodes has_jump = dis.hasjabs + dis.hasjrel for name, code in dis.opmap.items(): - # TODO(T74641077) - Figure out how to deal with static python opcodes - if name in MISSING_STACK_EFFECT or code in opcode.shadowop: - continue - with self.subTest(opname=name): if code < dis.HAVE_ARGUMENT: common = stack_effect(code) diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 001dc5be3bc..8f22de734a5 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -3,7 +3,6 @@ from test.support import captured_stdout from test.support.bytecode_helper import BytecodeTestCase from textwrap import dedent -from opcode import shadowop import unittest import sys import dis @@ -564,15 +563,9 @@ def test_boundaries(self): def test_widths(self): for opcode, opname in enumerate(dis.opname): - if ( - opname in ( - 'BUILD_MAP_UNPACK_WITH_CALL', - 'BUILD_TUPLE_UNPACK_WITH_CALL', - 'JUMP_IF_NONZERO_OR_POP', - 'JUMP_IF_NOT_EXC_MATCH', - ) - or opcode in shadowop - ): + if opname in ('BUILD_MAP_UNPACK_WITH_CALL', + 'BUILD_TUPLE_UNPACK_WITH_CALL', + 'JUMP_IF_NOT_EXC_MATCH'): continue with self.subTest(opname=opname): width = dis._OPNAME_WIDTH diff --git a/Makefile.pre.in b/Makefile.pre.in index bb06df7795c..c3def92823c 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1118,10 +1118,14 @@ regen-ast: regen-opcode: # Regenerate Include/opcode.h from Lib/opcode.py # using Tools/scripts/generate_opcode_h.py - $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \ + # Setting PYTHONPATH is a temporary hack which ensures CinderX opcodes are + # generated. Once we have a separate CinderX interpreter we'll remove this. + PYTHONPATH=$(srcdir)/CinderX $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \ $(srcdir)/Lib/opcode.py \ $(srcdir)/Include/opcode.h.new $(UPDATE_FILE) $(srcdir)/Include/opcode.h $(srcdir)/Include/opcode.h.new + $(MAKE) -C $(srcdir)/CinderX/ abs_srcdir=$(abs_srcdir) regen-opcode + .PHONY: regen-frozen regen-frozen: Programs/_freeze_importlib @@ -1228,9 +1232,13 @@ Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h regen-opcode-targets: # Regenerate Python/opcode_targets.h from Lib/opcode.py # using Python/makeopcodetargets.py - $(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \ + # Setting PYTHONPATH is a temporary hack which ensures CinderX opcodes are + # generated. Once we have a separate CinderX interpreter we'll remove this. + PYTHONPATH=$(srcdir)/CinderX $(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \ $(srcdir)/Python/opcode_targets.h.new $(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new + $(MAKE) -C $(srcdir)/CinderX/ abs_srcdir=$(abs_srcdir) regen-opcode-targets + Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h \ $(srcdir)/Python/condvar.h @@ -1295,6 +1303,8 @@ regen-typeslots: CINDERX_PRIVATE_HEADERS = \ $(srcdir)/CinderX/CachedProperties/cached_properties.h \ + $(srcdir)/CinderX/Interpreter/cinderx_opcode_targets.h \ + $(srcdir)/CinderX/Interpreter/opcode.h \ $(srcdir)/CinderX/Jit/bitvector.h \ $(srcdir)/CinderX/Jit/bytecode.h \ $(srcdir)/CinderX/Jit/bytecode_offsets.h \ diff --git a/Python/makeopcodetargets.py b/Python/makeopcodetargets.py index bbbc9634c64..7bc804adc91 100755 --- a/Python/makeopcodetargets.py +++ b/Python/makeopcodetargets.py @@ -5,6 +5,7 @@ import os import sys +import cinderx try: @@ -39,10 +40,10 @@ def write_contents(f): if s is None: f.write(f" &&_unknown_opcode,\n") continue - if s in opcode.cinderxop: + if s in cinderx.opcode.cinderxop: f.write(f"#ifdef ENABLE_CINDERX\n") f.write(f" &&TARGET_{s},\n") - if s in opcode.cinderxop: + if s in cinderx.opcode.cinderxop: f.write(f"#else\n &&_unknown_opcode,\n#endif\n") f.write("\n};\n") diff --git a/configure b/configure index a4afc23595c..49d54ef96e6 100755 --- a/configure +++ b/configure @@ -17278,6 +17278,7 @@ done SRCDIRS="Parser Objects Python Modules Programs \ CinderX/CachedProperties \ CinderX/Common \ + CinderX/Interpreter \ CinderX/Jit \ CinderX/Jit/codegen \ CinderX/Jit/hir \ diff --git a/configure.ac b/configure.ac index 7b07ca71b72..0896b231b20 100644 --- a/configure.ac +++ b/configure.ac @@ -5683,6 +5683,7 @@ AC_SUBST(SRCDIRS) SRCDIRS="Parser Objects Python Modules Programs \ CinderX/CachedProperties \ CinderX/Common \ + CinderX/Interpreter \ CinderX/Jit \ CinderX/Jit/codegen \ CinderX/Jit/hir \