mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	gh-104584: Change DEOPT_IF in uops executor (#106146)
This effectively reverts bb578a0, restoring the original DEOPT_IF() macro in ceval_macros.h, and redefining it in the Tier 2 interpreter. We can get rid of the PREDICTED() macros there as well!
			
			
This commit is contained in:
		
							parent
							
								
									5290881009
								
							
						
					
					
						commit
						6b5166fb12
					
				
					 2 changed files with 7 additions and 12 deletions
				
			
		| 
						 | 
					@ -2767,10 +2767,11 @@ void Py_LeaveRecursiveCall(void)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///////////////////// Experimental UOp Interpreter /////////////////////
 | 
					///////////////////// Experimental UOp Interpreter /////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UPDATE_MISS_STATS (called by DEOPT_IF) uses next_instr
 | 
					#undef DEOPT_IF
 | 
				
			||||||
// TODO: Make it do something useful
 | 
					#define DEOPT_IF(COND, INSTNAME) \
 | 
				
			||||||
#undef UPDATE_MISS_STATS
 | 
					    if ((COND)) {                \
 | 
				
			||||||
#define UPDATE_MISS_STATS(INSTNAME) ((void)0)
 | 
					        goto deoptimize;         \
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
_PyInterpreterFrame *
 | 
					_PyInterpreterFrame *
 | 
				
			||||||
_PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject **stack_pointer)
 | 
					_PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject **stack_pointer)
 | 
				
			||||||
| 
						 | 
					@ -2875,12 +2876,7 @@ _PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject
 | 
				
			||||||
    Py_DECREF(self);
 | 
					    Py_DECREF(self);
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PREDICTED(UNPACK_SEQUENCE)
 | 
					deoptimize:
 | 
				
			||||||
PREDICTED(COMPARE_OP)
 | 
					 | 
				
			||||||
PREDICTED(LOAD_SUPER_ATTR)
 | 
					 | 
				
			||||||
PREDICTED(STORE_SUBSCR)
 | 
					 | 
				
			||||||
PREDICTED(BINARY_SUBSCR)
 | 
					 | 
				
			||||||
PREDICTED(BINARY_OP)
 | 
					 | 
				
			||||||
    // On DEOPT_IF we just repeat the last instruction.
 | 
					    // On DEOPT_IF we just repeat the last instruction.
 | 
				
			||||||
    // This presumes nothing was popped from the stack (nor pushed).
 | 
					    // This presumes nothing was popped from the stack (nor pushed).
 | 
				
			||||||
#ifdef LLTRACE
 | 
					#ifdef LLTRACE
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -264,12 +264,11 @@ GETITEM(PyObject *v, Py_ssize_t i) {
 | 
				
			||||||
#define UPDATE_MISS_STATS(INSTNAME) ((void)0)
 | 
					#define UPDATE_MISS_STATS(INSTNAME) ((void)0)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NOTE: in the uops version, opcode may be > 255
 | 
					 | 
				
			||||||
#define DEOPT_IF(COND, INSTNAME)                            \
 | 
					#define DEOPT_IF(COND, INSTNAME)                            \
 | 
				
			||||||
    if ((COND)) {                                           \
 | 
					    if ((COND)) {                                           \
 | 
				
			||||||
        /* This is only a single jump on release builds! */ \
 | 
					        /* This is only a single jump on release builds! */ \
 | 
				
			||||||
        UPDATE_MISS_STATS((INSTNAME));                      \
 | 
					        UPDATE_MISS_STATS((INSTNAME));                      \
 | 
				
			||||||
        assert(opcode >= 256 || _PyOpcode_Deopt[opcode] == (INSTNAME)); \
 | 
					        assert(_PyOpcode_Deopt[opcode] == (INSTNAME));      \
 | 
				
			||||||
        GO_TO_INSTRUCTION(INSTNAME);                        \
 | 
					        GO_TO_INSTRUCTION(INSTNAME);                        \
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue