mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	GH-125912: Teach the JIT's optimizer about _BINARY_OP_INPLACE_ADD_UNICODE (GH-125935)
This commit is contained in:
		
							parent
							
								
									dcda92f8fc
								
							
						
					
					
						commit
						b5b06349eb
					
				
					 2 changed files with 37 additions and 0 deletions
				
			
		
							
								
								
									
										19
									
								
								Python/optimizer_cases.c.h
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										19
									
								
								Python/optimizer_cases.c.h
									
										
									
										generated
									
									
									
								
							|  | @ -484,6 +484,25 @@ | |||
|         } | ||||
| 
 | ||||
|         case _BINARY_OP_INPLACE_ADD_UNICODE: { | ||||
|             _Py_UopsSymbol *right; | ||||
|             _Py_UopsSymbol *left; | ||||
|             right = stack_pointer[-1]; | ||||
|             left = stack_pointer[-2]; | ||||
|             _Py_UopsSymbol *res; | ||||
|             if (sym_is_const(left) && sym_is_const(right) && | ||||
|                 sym_matches_type(left, &PyUnicode_Type) && sym_matches_type(right, &PyUnicode_Type)) { | ||||
|                 PyObject *temp = PyUnicode_Concat(sym_get_const(left), sym_get_const(right)); | ||||
|                 if (temp == NULL) { | ||||
|                     goto error; | ||||
|                 } | ||||
|                 res = sym_new_const(ctx, temp); | ||||
|                 Py_DECREF(temp); | ||||
|             } | ||||
|             else { | ||||
|                 res = sym_new_type(ctx, &PyUnicode_Type); | ||||
|             } | ||||
|             // _STORE_FAST:
 | ||||
|             GETLOCAL(this_instr->operand) = res; | ||||
|             stack_pointer += -2; | ||||
|             assert(WITHIN_STACK_BOUNDS()); | ||||
|             break; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brandt Bucher
						Brandt Bucher