2009-01-25 16:34:23 +00:00
|
|
|
static void *opcode_targets[256] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
&&_unknown_opcode,
|
|
|
|
&&TARGET_POP_TOP,
|
|
|
|
&&TARGET_ROT_TWO,
|
|
|
|
&&TARGET_ROT_THREE,
|
|
|
|
&&TARGET_DUP_TOP,
|
2010-09-04 18:43:52 +00:00
|
|
|
&&TARGET_DUP_TOP_TWO,
|
2018-02-22 21:33:30 +00:00
|
|
|
&&TARGET_ROT_FOUR,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_BINARY_ADD_ADAPTIVE,
|
|
|
|
&&TARGET_BINARY_ADD_INT,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_NOP,
|
|
|
|
&&TARGET_UNARY_POSITIVE,
|
|
|
|
&&TARGET_UNARY_NEGATIVE,
|
|
|
|
&&TARGET_UNARY_NOT,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_BINARY_ADD_FLOAT,
|
|
|
|
&&TARGET_BINARY_ADD_UNICODE,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_UNARY_INVERT,
|
2014-04-10 03:55:56 +00:00
|
|
|
&&TARGET_BINARY_MATRIX_MULTIPLY,
|
|
|
|
&&TARGET_INPLACE_MATRIX_MULTIPLY,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_BINARY_ADD_UNICODE_INPLACE_FAST,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_BINARY_POWER,
|
|
|
|
&&TARGET_BINARY_MULTIPLY,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_BINARY_SUBSCR_ADAPTIVE,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&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,
|
2021-02-26 22:51:55 +00:00
|
|
|
&&TARGET_GET_LEN,
|
|
|
|
&&TARGET_MATCH_MAPPING,
|
|
|
|
&&TARGET_MATCH_SEQUENCE,
|
|
|
|
&&TARGET_MATCH_KEYS,
|
|
|
|
&&TARGET_COPY_DICT_WITHOUT_KEYS,
|
2021-05-07 14:19:19 +00:00
|
|
|
&&TARGET_PUSH_EXC_INFO,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_BINARY_SUBSCR_LIST_INT,
|
2021-05-07 14:19:19 +00:00
|
|
|
&&TARGET_POP_EXCEPT_AND_RERAISE,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_BINARY_SUBSCR_TUPLE_INT,
|
|
|
|
&&TARGET_BINARY_SUBSCR_DICT,
|
|
|
|
&&TARGET_JUMP_ABSOLUTE_QUICK,
|
|
|
|
&&TARGET_LOAD_ATTR_ADAPTIVE,
|
|
|
|
&&TARGET_LOAD_ATTR_SPLIT_KEYS,
|
2021-07-15 12:13:12 +00:00
|
|
|
&&TARGET_LOAD_ATTR_WITH_HINT,
|
|
|
|
&&TARGET_LOAD_ATTR_SLOT,
|
|
|
|
&&TARGET_LOAD_ATTR_MODULE,
|
|
|
|
&&TARGET_LOAD_GLOBAL_ADAPTIVE,
|
2021-06-14 10:04:09 +00:00
|
|
|
&&TARGET_LOAD_GLOBAL_MODULE,
|
|
|
|
&&TARGET_LOAD_GLOBAL_BUILTIN,
|
2019-11-21 09:11:43 +00:00
|
|
|
&&TARGET_WITH_EXCEPT_START,
|
2015-05-12 02:57:16 +00:00
|
|
|
&&TARGET_GET_AITER,
|
|
|
|
&&TARGET_GET_ANEXT,
|
|
|
|
&&TARGET_BEFORE_ASYNC_WITH,
|
2021-05-07 14:19:19 +00:00
|
|
|
&&TARGET_BEFORE_WITH,
|
2018-03-23 12:34:35 +00:00
|
|
|
&&TARGET_END_ASYNC_FOR,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_INPLACE_ADD,
|
|
|
|
&&TARGET_INPLACE_SUBTRACT,
|
|
|
|
&&TARGET_INPLACE_MULTIPLY,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_LOAD_METHOD_ADAPTIVE,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&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,
|
Issue #24400: Introduce a distinct type for 'async def' coroutines.
Summary of changes:
1. Coroutines now have a distinct, separate from generators
type at the C level: PyGen_Type, and a new typedef PyCoroObject.
PyCoroObject shares the initial segment of struct layout with
PyGenObject, making it possible to reuse existing generators
machinery. The new type is exposed as 'types.CoroutineType'.
As a consequence of having a new type, CO_GENERATOR flag is
no longer applied to coroutines.
2. Having a separate type for coroutines made it possible to add
an __await__ method to the type. Although it is not used by the
interpreter (see details on that below), it makes coroutines
naturally (without using __instancecheck__) conform to
collections.abc.Coroutine and collections.abc.Awaitable ABCs.
[The __instancecheck__ is still used for generator-based
coroutines, as we don't want to add __await__ for generators.]
3. Add new opcode: GET_YIELD_FROM_ITER. The opcode is needed to
allow passing native coroutines to the YIELD_FROM opcode.
Before this change, 'yield from o' expression was compiled to:
(o)
GET_ITER
LOAD_CONST
YIELD_FROM
Now, we use GET_YIELD_FROM_ITER instead of GET_ITER.
The reason for adding a new opcode is that GET_ITER is used
in some contexts (such as 'for .. in' loops) where passing
a coroutine object is invalid.
4. Add two new introspection functions to the inspec module:
getcoroutinestate(c) and getcoroutinelocals(c).
5. inspect.iscoroutine(o) is updated to test if 'o' is a native
coroutine object. Before this commit it used abc.Coroutine,
and it was requested to update inspect.isgenerator(o) to use
abc.Generator; it was decided, however, that inspect functions
should really be tailored for checking for native types.
6. sys.set_coroutine_wrapper(w) API is updated to work with only
native coroutines. Since types.coroutine decorator supports
any type of callables now, it would be confusing that it does
not work for all types of coroutines.
7. Exceptions logic in generators C implementation was updated
to raise clearer messages for coroutines:
Before: TypeError("generator raised StopIteration")
After: TypeError("coroutine raised StopIteration")
2015-06-22 16:19:30 +00:00
|
|
|
&&TARGET_GET_YIELD_FROM_ITER,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_PRINT_EXPR,
|
|
|
|
&&TARGET_LOAD_BUILD_CLASS,
|
2012-01-13 11:43:40 +00:00
|
|
|
&&TARGET_YIELD_FROM,
|
2015-05-12 02:57:16 +00:00
|
|
|
&&TARGET_GET_AWAITABLE,
|
2019-08-25 09:44:09 +00:00
|
|
|
&&TARGET_LOAD_ASSERTION_ERROR,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_INPLACE_LSHIFT,
|
|
|
|
&&TARGET_INPLACE_RSHIFT,
|
|
|
|
&&TARGET_INPLACE_AND,
|
|
|
|
&&TARGET_INPLACE_XOR,
|
|
|
|
&&TARGET_INPLACE_OR,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_LOAD_METHOD_CACHED,
|
|
|
|
&&TARGET_LOAD_METHOD_CLASS,
|
2020-01-23 09:25:17 +00:00
|
|
|
&&TARGET_LIST_TO_TUPLE,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_RETURN_VALUE,
|
|
|
|
&&TARGET_IMPORT_STAR,
|
2016-09-09 03:50:03 +00:00
|
|
|
&&TARGET_SETUP_ANNOTATIONS,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_YIELD_VALUE,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_LOAD_METHOD_MODULE,
|
|
|
|
&&TARGET_STORE_ATTR_ADAPTIVE,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&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,
|
2021-05-02 20:02:10 +00:00
|
|
|
&&TARGET_ROT_N,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&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,
|
2020-01-14 10:12:45 +00:00
|
|
|
&&TARGET_IS_OP,
|
|
|
|
&&TARGET_CONTAINS_OP,
|
2020-12-17 13:55:28 +00:00
|
|
|
&&TARGET_RERAISE,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_STORE_ATTR_SPLIT_KEYS,
|
2020-01-14 10:12:45 +00:00
|
|
|
&&TARGET_JUMP_IF_NOT_EXC_MATCH,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_STORE_ATTR_SLOT,
|
|
|
|
&&TARGET_STORE_ATTR_WITH_HINT,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_LOAD_FAST,
|
|
|
|
&&TARGET_STORE_FAST,
|
|
|
|
&&TARGET_DELETE_FAST,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_LOAD_FAST__LOAD_FAST,
|
|
|
|
&&TARGET_STORE_FAST__LOAD_FAST,
|
2021-04-06 10:48:59 +00:00
|
|
|
&&TARGET_GEN_START,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_RAISE_VARARGS,
|
|
|
|
&&TARGET_CALL_FUNCTION,
|
|
|
|
&&TARGET_MAKE_FUNCTION,
|
|
|
|
&&TARGET_BUILD_SLICE,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_LOAD_FAST__LOAD_CONST,
|
2021-06-08 22:01:34 +00:00
|
|
|
&&TARGET_MAKE_CELL,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_LOAD_CLOSURE,
|
|
|
|
&&TARGET_LOAD_DEREF,
|
|
|
|
&&TARGET_STORE_DEREF,
|
2010-09-10 21:39:53 +00:00
|
|
|
&&TARGET_DELETE_DEREF,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_LOAD_CONST__LOAD_FAST,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_CALL_FUNCTION_KW,
|
2016-09-09 17:17:08 +00:00
|
|
|
&&TARGET_CALL_FUNCTION_EX,
|
2021-08-27 08:21:01 +00:00
|
|
|
&&TARGET_STORE_FAST__STORE_FAST,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&TARGET_EXTENDED_ARG,
|
|
|
|
&&TARGET_LIST_APPEND,
|
|
|
|
&&TARGET_SET_ADD,
|
|
|
|
&&TARGET_MAP_ADD,
|
2013-04-30 13:41:40 +00:00
|
|
|
&&TARGET_LOAD_CLASSDEREF,
|
2020-01-23 09:25:17 +00:00
|
|
|
&&_unknown_opcode,
|
2020-01-27 09:57:45 +00:00
|
|
|
&&_unknown_opcode,
|
|
|
|
&&_unknown_opcode,
|
2021-02-26 22:51:55 +00:00
|
|
|
&&TARGET_MATCH_CLASS,
|
2020-01-23 09:25:17 +00:00
|
|
|
&&_unknown_opcode,
|
2021-05-07 14:19:19 +00:00
|
|
|
&&_unknown_opcode,
|
2015-11-03 17:45:05 +00:00
|
|
|
&&TARGET_FORMAT_VALUE,
|
2016-06-11 21:39:41 +00:00
|
|
|
&&TARGET_BUILD_CONST_KEY_MAP,
|
2016-09-06 19:07:53 +00:00
|
|
|
&&TARGET_BUILD_STRING,
|
2020-01-23 09:25:17 +00:00
|
|
|
&&_unknown_opcode,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&_unknown_opcode,
|
2016-12-14 00:03:51 +00:00
|
|
|
&&TARGET_LOAD_METHOD,
|
|
|
|
&&TARGET_CALL_METHOD,
|
2020-01-23 09:25:17 +00:00
|
|
|
&&TARGET_LIST_EXTEND,
|
|
|
|
&&TARGET_SET_UPDATE,
|
2020-01-27 09:57:45 +00:00
|
|
|
&&TARGET_DICT_MERGE,
|
|
|
|
&&TARGET_DICT_UPDATE,
|
2021-05-15 15:15:23 +00:00
|
|
|
&&TARGET_CALL_METHOD_KW,
|
2010-05-09 15:52:27 +00:00
|
|
|
&&_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,
|
|
|
|
&&_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,
|
|
|
|
&&_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,
|
|
|
|
&&_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,
|
|
|
|
&&_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,
|
|
|
|
&&_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,
|
|
|
|
&&_unknown_opcode,
|
|
|
|
&&_unknown_opcode,
|
|
|
|
&&_unknown_opcode,
|
|
|
|
&&_unknown_opcode,
|
|
|
|
&&_unknown_opcode
|
2009-01-25 16:34:23 +00:00
|
|
|
};
|