6868#define JUMPBY (offset ) ((void)0)
6969#define GO_TO_INSTRUCTION (instname ) ((void)0)
7070#define DISPATCH_SAME_OPARG () ((void)0)
71- #define DISPATCH () ((void)0)
7271
7372#define inst (name , ...) case name:
7473#define super (name ) static int SUPER_##name
@@ -104,10 +103,6 @@ dummy_func(
104103{
105104 switch (opcode ) {
106105
107- /* BEWARE!
108- It is essential that any operation that fails must goto error
109- and that all operation that succeed call DISPATCH() ! */
110-
111106// BEGIN BYTECODES //
112107 inst (NOP , (-- )) {
113108 }
@@ -152,16 +147,14 @@ dummy_func(
152147 super (LOAD_FAST__LOAD_CONST ) = LOAD_FAST + LOAD_CONST ;
153148 super (STORE_FAST__LOAD_FAST ) = STORE_FAST + LOAD_FAST ;
154149 super (STORE_FAST__STORE_FAST ) = STORE_FAST + STORE_FAST ;
155- super (LOAD_CONST__LOAD_FAST ) = LOAD_CONST + LOAD_FAST ;
150+ super (LOAD_CONST__LOAD_FAST ) = LOAD_CONST + LOAD_FAST ;
156151
157152 inst (POP_TOP , (value -- )) {
158153 Py_DECREF (value );
159154 }
160155
161- // stack effect: ( -- __0)
162- inst (PUSH_NULL ) {
163- /* Use BASIC_PUSH as NULL is not a valid object pointer */
164- BASIC_PUSH (NULL );
156+ inst (PUSH_NULL , (-- res )) {
157+ res = NULL ;
165158 }
166159
167160 inst (END_FOR , (value1 , value2 -- )) {
@@ -816,11 +809,12 @@ dummy_func(
816809 Py_DECREF (receiver );
817810 SET_TOP (retval );
818811 JUMPBY (oparg );
819- DISPATCH ();
820812 }
821- assert (gen_status == PYGEN_NEXT );
822- assert (retval != NULL );
823- PUSH (retval );
813+ else {
814+ assert (gen_status == PYGEN_NEXT );
815+ assert (retval != NULL );
816+ PUSH (retval );
817+ }
824818 }
825819
826820 // stack effect: ( -- )
@@ -913,7 +907,6 @@ dummy_func(
913907 if (PyErr_GivenExceptionMatches (val , PyExc_StopAsyncIteration )) {
914908 Py_DECREF (val );
915909 Py_DECREF (POP ());
916- DISPATCH ();
917910 }
918911 else {
919912 PyObject * exc = Py_NewRef (PyExceptionInstance_Class (val ));
@@ -935,12 +928,13 @@ dummy_func(
935928 Py_DECREF (POP ()); // The last sent value.
936929 Py_DECREF (POP ()); // The delegated sub-iterator.
937930 PUSH (value );
938- DISPATCH ();
939931 }
940- PyObject * exc_type = Py_NewRef (Py_TYPE (exc_value ));
941- PyObject * exc_traceback = PyException_GetTraceback (exc_value );
942- _PyErr_Restore (tstate , exc_type , Py_NewRef (exc_value ), exc_traceback );
943- goto exception_unwind ;
932+ else {
933+ PyObject * exc_type = Py_NewRef (Py_TYPE (exc_value ));
934+ PyObject * exc_traceback = PyException_GetTraceback (exc_value );
935+ _PyErr_Restore (tstate , exc_type , Py_NewRef (exc_value ), exc_traceback );
936+ goto exception_unwind ;
937+ }
944938 }
945939
946940 inst (STOPITERATION_ERROR ) {
@@ -982,7 +976,6 @@ dummy_func(
982976 PyException_SetContext (error , exc );
983977 Py_DECREF (message );
984978 }
985- DISPATCH ();
986979 }
987980
988981
@@ -1040,8 +1033,7 @@ dummy_func(
10401033 goto error ;
10411034 }
10421035
1043- // stack effect: ( -- )
1044- inst (DELETE_NAME ) {
1036+ inst (DELETE_NAME , (-- )) {
10451037 PyObject * name = GETITEM (names , oparg );
10461038 PyObject * ns = LOCALS ();
10471039 int err ;
@@ -1051,6 +1043,7 @@ dummy_func(
10511043 goto error ;
10521044 }
10531045 err = PyObject_DelItem (ns , name );
1046+ // Can't use ERROR_IF here.
10541047 if (err != 0 ) {
10551048 format_exc_check_arg (tstate , PyExc_NameError ,
10561049 NAME_ERROR_MSG ,
@@ -1190,11 +1183,11 @@ dummy_func(
11901183 goto error ;
11911184 }
11921185
1193- // stack effect: ( -- )
1194- inst (DELETE_GLOBAL ) {
1186+ inst (DELETE_GLOBAL , (-- )) {
11951187 PyObject * name = GETITEM (names , oparg );
11961188 int err ;
11971189 err = PyDict_DelItem (GLOBALS (), name );
1190+ // Can't use ERROR_IF here.
11981191 if (err != 0 ) {
11991192 if (_PyErr_ExceptionMatches (tstate , PyExc_KeyError )) {
12001193 format_exc_check_arg (tstate , PyExc_NameError ,
@@ -1374,18 +1367,13 @@ dummy_func(
13741367 SET_TOP (Py_NewRef (res ));
13751368 }
13761369
1377- // stack effect: ( -- )
1378- inst (DELETE_FAST ) {
1370+ inst (DELETE_FAST , (-- )) {
13791371 PyObject * v = GETLOCAL (oparg );
1380- if (v != NULL ) {
1381- SETLOCAL (oparg , NULL );
1382- DISPATCH ();
1383- }
1384- goto unbound_local_error ;
1372+ ERROR_IF (v == NULL , unbound_local_error );
1373+ SETLOCAL (oparg , NULL );
13851374 }
13861375
1387- // stack effect: ( -- )
1388- inst (MAKE_CELL ) {
1376+ inst (MAKE_CELL , (-- )) {
13891377 // "initial" is probably NULL but not if it's an arg (or set
13901378 // via PyFrame_LocalsToFast() before MAKE_CELL has run).
13911379 PyObject * initial = GETLOCAL (oparg );
@@ -1396,17 +1384,17 @@ dummy_func(
13961384 SETLOCAL (oparg , cell );
13971385 }
13981386
1399- // stack effect: ( -- )
1400- inst (DELETE_DEREF ) {
1387+ inst (DELETE_DEREF , (-- )) {
14011388 PyObject * cell = GETLOCAL (oparg );
14021389 PyObject * oldobj = PyCell_GET (cell );
1403- if (oldobj != NULL ) {
1404- PyCell_SET (cell , NULL );
1405- Py_DECREF (oldobj );
1406- DISPATCH ();
1390+ // Can't use ERROR_IF here.
1391+ // Fortunately we don't need its superpower.
1392+ if (oldobj == NULL ) {
1393+ format_exc_unbound (tstate , frame -> f_code , oparg );
1394+ goto error ;
14071395 }
1408- format_exc_unbound ( tstate , frame -> f_code , oparg );
1409- goto error ;
1396+ PyCell_SET ( cell , NULL );
1397+ Py_DECREF ( oldobj ) ;
14101398 }
14111399
14121400 // stack effect: ( -- __0)
@@ -1769,15 +1757,15 @@ dummy_func(
17691757 Py_DECREF (owner );
17701758 PUSH (meth );
17711759 }
1772- JUMPBY (INLINE_CACHE_ENTRIES_LOAD_ATTR );
1773- DISPATCH ();
17741760 }
1775- PyObject * res = PyObject_GetAttr (owner , name );
1776- if (res == NULL ) {
1777- goto error ;
1761+ else {
1762+ PyObject * res = PyObject_GetAttr (owner , name );
1763+ if (res == NULL ) {
1764+ goto error ;
1765+ }
1766+ Py_DECREF (owner );
1767+ SET_TOP (res );
17781768 }
1779- Py_DECREF (owner );
1780- SET_TOP (res );
17811769 JUMPBY (INLINE_CACHE_ENTRIES_LOAD_ATTR );
17821770 }
17831771
@@ -2435,21 +2423,23 @@ dummy_func(
24352423 if (Py_IsTrue (cond )) {
24362424 STACK_SHRINK (1 );
24372425 _Py_DECREF_NO_DEALLOC (cond );
2438- DISPATCH ();
24392426 }
2440- if (Py_IsFalse (cond )) {
2427+ else if (Py_IsFalse (cond )) {
24412428 JUMPBY (oparg );
2442- DISPATCH ();
24432429 }
2444- err = PyObject_IsTrue (cond );
2445- if (err > 0 ) {
2446- STACK_SHRINK (1 );
2447- Py_DECREF (cond );
2430+ else {
2431+ err = PyObject_IsTrue (cond );
2432+ if (err > 0 ) {
2433+ STACK_SHRINK (1 );
2434+ Py_DECREF (cond );
2435+ }
2436+ else if (err == 0 ) {
2437+ JUMPBY (oparg );
2438+ }
2439+ else {
2440+ goto error ;
2441+ }
24482442 }
2449- else if (err == 0 )
2450- JUMPBY (oparg );
2451- else
2452- goto error ;
24532443 }
24542444
24552445 // error: JUMP_IF_TRUE_OR_POP stack effect depends on jump flag
@@ -2459,22 +2449,23 @@ dummy_func(
24592449 if (Py_IsFalse (cond )) {
24602450 STACK_SHRINK (1 );
24612451 _Py_DECREF_NO_DEALLOC (cond );
2462- DISPATCH ();
2463- }
2464- if (Py_IsTrue (cond )) {
2465- JUMPBY (oparg );
2466- DISPATCH ();
24672452 }
2468- err = PyObject_IsTrue (cond );
2469- if (err > 0 ) {
2453+ else if (Py_IsTrue (cond )) {
24702454 JUMPBY (oparg );
24712455 }
2472- else if (err == 0 ) {
2473- STACK_SHRINK (1 );
2474- Py_DECREF (cond );
2456+ else {
2457+ err = PyObject_IsTrue (cond );
2458+ if (err > 0 ) {
2459+ JUMPBY (oparg );
2460+ }
2461+ else if (err == 0 ) {
2462+ STACK_SHRINK (1 );
2463+ Py_DECREF (cond );
2464+ }
2465+ else {
2466+ goto error ;
2467+ }
24752468 }
2476- else
2477- goto error ;
24782469 }
24792470
24802471 // stack effect: ( -- )
@@ -2615,23 +2606,24 @@ dummy_func(
26152606 if (next != NULL ) {
26162607 PUSH (next );
26172608 JUMPBY (INLINE_CACHE_ENTRIES_FOR_ITER );
2618- DISPATCH ();
26192609 }
2620- if (_PyErr_Occurred (tstate )) {
2621- if (!_PyErr_ExceptionMatches (tstate , PyExc_StopIteration )) {
2622- goto error ;
2623- }
2624- else if (tstate -> c_tracefunc != NULL ) {
2625- call_exc_trace (tstate -> c_tracefunc , tstate -> c_traceobj , tstate , frame );
2610+ else {
2611+ if (_PyErr_Occurred (tstate )) {
2612+ if (!_PyErr_ExceptionMatches (tstate , PyExc_StopIteration )) {
2613+ goto error ;
2614+ }
2615+ else if (tstate -> c_tracefunc != NULL ) {
2616+ call_exc_trace (tstate -> c_tracefunc , tstate -> c_traceobj , tstate , frame );
2617+ }
2618+ _PyErr_Clear (tstate );
26262619 }
2627- _PyErr_Clear (tstate );
2620+ /* iterator ended normally */
2621+ assert (_Py_OPCODE (next_instr [INLINE_CACHE_ENTRIES_FOR_ITER + oparg ]) == END_FOR );
2622+ STACK_SHRINK (1 );
2623+ Py_DECREF (iter );
2624+ /* Skip END_FOR */
2625+ JUMPBY (INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1 );
26282626 }
2629- /* iterator ended normally */
2630- assert (_Py_OPCODE (next_instr [INLINE_CACHE_ENTRIES_FOR_ITER + oparg ]) == END_FOR );
2631- STACK_SHRINK (1 );
2632- Py_DECREF (iter );
2633- /* Skip END_FOR */
2634- JUMPBY (INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1 );
26352627 }
26362628
26372629 // stack effect: ( -- __0)
@@ -2646,14 +2638,15 @@ dummy_func(
26462638 PyObject * next = PyList_GET_ITEM (seq , it -> it_index ++ );
26472639 PUSH (Py_NewRef (next ));
26482640 JUMPBY (INLINE_CACHE_ENTRIES_FOR_ITER );
2649- DISPATCH ();
2641+ goto end_for_iter_list ; // End of this instruction
26502642 }
26512643 it -> it_seq = NULL ;
26522644 Py_DECREF (seq );
26532645 }
26542646 STACK_SHRINK (1 );
26552647 Py_DECREF (it );
26562648 JUMPBY (INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1 );
2649+ end_for_iter_list :
26572650 }
26582651
26592652 // stack effect: ( -- __0)
@@ -2668,15 +2661,16 @@ dummy_func(
26682661 STACK_SHRINK (1 );
26692662 Py_DECREF (r );
26702663 JUMPBY (INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1 );
2671- DISPATCH ();
26722664 }
2673- long value = (long )(r -> start +
2674- (unsigned long )(r -> index ++ ) * r -> step );
2675- if (_PyLong_AssignValue (& GETLOCAL (_Py_OPARG (next )), value ) < 0 ) {
2676- goto error ;
2665+ else {
2666+ long value = (long )(r -> start +
2667+ (unsigned long )(r -> index ++ ) * r -> step );
2668+ if (_PyLong_AssignValue (& GETLOCAL (_Py_OPARG (next )), value ) < 0 ) {
2669+ goto error ;
2670+ }
2671+ // The STORE_FAST is already done.
2672+ JUMPBY (INLINE_CACHE_ENTRIES_FOR_ITER + 1 );
26772673 }
2678- // The STORE_FAST is already done.
2679- JUMPBY (INLINE_CACHE_ENTRIES_FOR_ITER + 1 );
26802674 }
26812675
26822676 inst (FOR_ITER_GEN ) {
0 commit comments