python / python/cpython

Redundant stack spills on subsequent escaping calls separated by comments

Aperta
#128,760 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

interpreter-core type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug report

Bug description:

Tier 1 case generator emits stack spill for every subsequent escaping call, when subsequent escaping calls are separated by comment(s). Example:

Subsequent escaping calls without comments in between:

Bytecode definition:

pure inst(NOP, (--)) {
    escaping_call1();
    escaping_call2();
    escaping_call3();
}

Generated case:

TARGET(NOP) {
    frame->instr_ptr = next_instr;
    next_instr += 1;
    INSTRUCTION_STATS(NOP);
    _PyFrame_SetStackPointer(frame, stack_pointer);
    escaping_call1();
    escaping_call2();
    escaping_call3();
    stack_pointer = _PyFrame_GetStackPointer(frame);
    DISPATCH();
}
Subsequent escaping calls with comments in between:

Bytecode definition:

pure inst(NOP, (--)) {
    escaping_call1();
    // comment1
    escaping_call2();
    // comment2
    escaping_call3();
}

Generated case:

TARGET(NOP) {
    frame->instr_ptr = next_instr;
    next_instr += 1;
    INSTRUCTION_STATS(NOP);
    _PyFrame_SetStackPointer(frame, stack_pointer);
    escaping_call1();
    stack_pointer = _PyFrame_GetStackPointer(frame);
    // comment1
    _PyFrame_SetStackPointer(frame, stack_pointer);
    escaping_call2();
    stack_pointer = _PyFrame_GetStackPointer(frame);
    // comment2
    _PyFrame_SetStackPointer(frame, stack_pointer);
    escaping_call3();
    stack_pointer = _PyFrame_GetStackPointer(frame);
    DISPATCH();
}
CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-128761

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con il generatore di casi di Tier 1 e la definizione del bytecode mostrati nel report, quindi esamina il PR collegato gh-128761 per conoscere il lavoro attuale. Riproduci gli esempi con commenti tra le chiamate di escaping e verifica che il caso generato emetta solo le operazioni necessarie dello stack pointer.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c, python
Ambito
compilers
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.