@@ -181,6 +181,7 @@ _PyOptimizer_BackEdge(_PyInterpreterFrame *frame, _Py_CODEUNIT *src, _Py_CODEUNI
181181 }
182182insert_executor (code ,src ,index ,executor );
183183assert (frame -> prev_instr == src );
184+ frame -> prev_instr = dest - 1 ;
184185return executor -> execute (executor ,frame ,stack_pointer );
185186jump_to_destination :
186187frame -> prev_instr = dest - 1 ;
@@ -201,7 +202,7 @@ PyUnstable_GetExecutor(PyCodeObject *code, int offset)
201202 }
202203i += _PyInstruction_GetLength (code ,i );
203204 }
204- PyErr_SetString (PyExc_ValueError ,"no executor at given offset" );
205+ PyErr_SetString (PyExc_ValueError ,"no executor at givenbyte offset" );
205206return NULL ;
206207}
207208
@@ -399,22 +400,28 @@ translate_bytecode_to_trace(
399400 trace_length++;
400401
401402DPRINTF (4 ,
402- "Optimizing %s (%s:%d) at offset %ld\n" ,
403+ "Optimizing %s (%s:%d) atbyte offset %ld\n" ,
403404PyUnicode_AsUTF8 (code -> co_qualname ),
404405PyUnicode_AsUTF8 (code -> co_filename ),
405406code -> co_firstlineno ,
406- (long )(instr - (_Py_CODEUNIT * )code -> co_code_adaptive ));
407+ 2 * (long )(initial_instr - (_Py_CODEUNIT * )code -> co_code_adaptive ));
407408
408409for (;;) {
409410ADD_TO_TRACE (SAVE_IP , (int )(instr - (_Py_CODEUNIT * )code -> co_code_adaptive ));
410411int opcode = instr -> op .code ;
411412uint64_t operand = instr -> op .arg ;
412- // TODO: EXTENDED_ARG handling
413+ int extras = 0 ;
414+ while (opcode == EXTENDED_ARG ) {
415+ instr ++ ;
416+ extras += 1 ;
417+ opcode = instr -> op .code ;
418+ operand = (operand <<8 ) |instr -> op .arg ;
419+ }
413420if (opcode == ENTER_EXECUTOR ) {
414421_PyExecutorObject * executor = (_PyExecutorObject * )code -> co_executors -> executors [operand & 255 ];
415422opcode = executor -> vm_data .opcode ;
416423DPRINTF (2 ," * ENTER_EXECUTOR -> %s\n" ,_PyOpcode_OpName [opcode ]);
417- operand = executor -> vm_data .oparg ;// TODO: EXTENDED_ARG handling
424+ operand = ( operand & 0xffffff00 ) | executor -> vm_data .oparg ;
418425 }
419426switch (opcode ) {
420427case LOAD_FAST_LOAD_FAST :
@@ -474,6 +481,15 @@ translate_bytecode_to_trace(
474481int offset = expansion -> uops [i ].offset ;
475482switch (expansion -> uops [i ].size ) {
476483case 0 :
484+ if (extras && OPCODE_HAS_JUMP (opcode )) {
485+ if (opcode == JUMP_BACKWARD_NO_INTERRUPT ) {
486+ operand -= extras ;
487+ }
488+ else {
489+ assert (opcode != JUMP_BACKWARD );
490+ operand += extras ;
491+ }
492+ }
477493break ;
478494case 1 :
479495operand = read_u16 (& instr [offset ].cache );
@@ -512,21 +528,21 @@ translate_bytecode_to_trace(
512528if (trace_length > 3 ) {
513529ADD_TO_TRACE (EXIT_TRACE ,0 );
514530DPRINTF (1 ,
515- "Created a trace for %s (%s:%d) at offset %ld -- length %d\n" ,
531+ "Created a trace for %s (%s:%d) atbyte offset %ld -- length %d\n" ,
516532PyUnicode_AsUTF8 (code -> co_qualname ),
517533PyUnicode_AsUTF8 (code -> co_filename ),
518534code -> co_firstlineno ,
519- (long )(instr - (_Py_CODEUNIT * )code -> co_code_adaptive ),
535+ 2 * (long )(initial_instr - (_Py_CODEUNIT * )code -> co_code_adaptive ),
520536trace_length );
521537return trace_length ;
522538 }
523539else {
524540DPRINTF (4 ,
525- "No trace for %s (%s:%d) at offset %ld\n" ,
541+ "No trace for %s (%s:%d) atbyte offset %ld\n" ,
526542PyUnicode_AsUTF8 (code -> co_qualname ),
527543PyUnicode_AsUTF8 (code -> co_filename ),
528544code -> co_firstlineno ,
529- (long )(instr - (_Py_CODEUNIT * )code -> co_code_adaptive ));
545+ 2 * (long )(initial_instr - (_Py_CODEUNIT * )code -> co_code_adaptive ));
530546 }
531547return 0 ;
532548