Ticket #185: python-gil-pruning-nodebug.patch

File python-gil-pruning-nodebug.patch, 2.0 KB (added by olly, 15 months ago)

Patch to remove redundant locking in SWIG generated wrappers

  • Source/Modules/python.cxx

     
    14741474    /* Last node in overloaded chain */ 
    14751475 
    14761476    int maxargs; 
    1477     int allow_thread = threads_enable(n); 
    14781477 
    14791478    String *tmp = NewString(""); 
    14801479    String *dispatch; 
     
    14971496    Wrapper_add_local(f, "argc", "int argc"); 
    14981497    Printf(tmp, "PyObject *argv[%d]", maxargs + 1); 
    14991498    Wrapper_add_local(f, "argv", tmp); 
    1500     if (allow_thread) 
    1501       thread_begin_block(n, f->code); 
    15021499 
    15031500    if (!fastunpack) { 
    15041501      Wrapper_add_local(f, "ii", "int ii"); 
     
    15151512 
    15161513    Replaceall(dispatch, "$args", "self,args"); 
    15171514 
    1518     if (allow_thread) { 
    1519       String *ret = NewStringEmpty(); 
    1520       thread_end_block(n, ret); 
    1521       Append(ret, "return "); 
    1522       Replaceall(dispatch, "return ", ret); 
    1523       Delete(ret); 
    1524     } 
    1525  
    15261515    Printv(f->code, dispatch, "\n", NIL); 
    15271516 
    1528     if (allow_thread) 
    1529       thread_end_block(n, f->code); 
    1530  
    15311517    if (GetFlag(n, "feature:python:maybecall")) { 
    15321518      Append(f->code, "fail:\n"); 
    15331519      Append(f->code, "Py_INCREF(Py_NotImplemented);\n"); 
     
    16341620    kwargs = NewString(""); 
    16351621 
    16361622    int allow_thread = threads_enable(n); 
    1637     if (allow_thread) 
    1638       thread_begin_block(n, f->code); 
    16391623 
    16401624    Wrapper_add_local(f, "resultobj", "PyObject *resultobj = 0"); 
    16411625 
     
    20662050      } 
    20672051    } 
    20682052 
    2069     if (allow_thread) 
    2070       thread_end_block(n, f->code); 
    20712053    Append(f->code, "    return resultobj;\n"); 
    20722054 
    20732055    /* Error handling code */ 
     
    20762058    if (need_cleanup) { 
    20772059      Printv(f->code, cleanup, NIL); 
    20782060    } 
    2079     if (allow_thread) 
    2080       thread_end_block(n, f->code); 
    20812061    Printv(f->code, ctab4, "return NULL;\n", NIL); 
    20822062 
    20832063 
     
    35623542 
    35633543    int allow_thread = threads_enable(n); 
    35643544 
    3565     if (allow_thread) 
    3566       thread_begin_block(n, w->code); 
    3567  
    35683545    if (allow_thread) { 
     3546      thread_begin_block(n, w->code); 
    35693547      Append(w->code, "{\n"); 
    35703548    } 
    35713549