generated_cases.c.h 191 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809
  1. // This file is generated by Tools/cases_generator/generate_cases.py
  2. // from:
  3. // Python/bytecodes.c
  4. // Do not edit!
  5. TARGET(NOP) {
  6. DISPATCH();
  7. }
  8. TARGET(RESUME) {
  9. #line 137 "Python/bytecodes.c"
  10. assert(tstate->cframe == &cframe);
  11. assert(frame == cframe.current_frame);
  12. /* Possibly combine this with eval breaker */
  13. if (frame->f_code->_co_instrumentation_version != tstate->interp->monitoring_version) {
  14. int err = _Py_Instrument(frame->f_code, tstate->interp);
  15. if (err) goto error;
  16. next_instr--;
  17. }
  18. else if (_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker) && oparg < 2) {
  19. goto handle_eval_breaker;
  20. }
  21. #line 24 "Python/generated_cases.c.h"
  22. DISPATCH();
  23. }
  24. TARGET(INSTRUMENTED_RESUME) {
  25. #line 151 "Python/bytecodes.c"
  26. /* Possible performance enhancement:
  27. * We need to check the eval breaker anyway, can we
  28. * combine the instrument verison check and the eval breaker test?
  29. */
  30. if (frame->f_code->_co_instrumentation_version != tstate->interp->monitoring_version) {
  31. if (_Py_Instrument(frame->f_code, tstate->interp)) {
  32. goto error;
  33. }
  34. next_instr--;
  35. }
  36. else {
  37. _PyFrame_SetStackPointer(frame, stack_pointer);
  38. int err = _Py_call_instrumentation(
  39. tstate, oparg > 0, frame, next_instr-1);
  40. stack_pointer = _PyFrame_GetStackPointer(frame);
  41. if (err) goto error;
  42. if (frame->prev_instr != next_instr-1) {
  43. /* Instrumentation has jumped */
  44. next_instr = frame->prev_instr;
  45. DISPATCH();
  46. }
  47. if (_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker) && oparg < 2) {
  48. goto handle_eval_breaker;
  49. }
  50. }
  51. #line 55 "Python/generated_cases.c.h"
  52. DISPATCH();
  53. }
  54. TARGET(LOAD_CLOSURE) {
  55. PyObject *value;
  56. #line 179 "Python/bytecodes.c"
  57. /* We keep LOAD_CLOSURE so that the bytecode stays more readable. */
  58. value = GETLOCAL(oparg);
  59. if (value == NULL) goto unbound_local_error;
  60. Py_INCREF(value);
  61. #line 66 "Python/generated_cases.c.h"
  62. STACK_GROW(1);
  63. stack_pointer[-1] = value;
  64. DISPATCH();
  65. }
  66. TARGET(LOAD_FAST_CHECK) {
  67. PyObject *value;
  68. #line 186 "Python/bytecodes.c"
  69. value = GETLOCAL(oparg);
  70. if (value == NULL) goto unbound_local_error;
  71. Py_INCREF(value);
  72. #line 78 "Python/generated_cases.c.h"
  73. STACK_GROW(1);
  74. stack_pointer[-1] = value;
  75. DISPATCH();
  76. }
  77. TARGET(LOAD_FAST) {
  78. PyObject *value;
  79. #line 192 "Python/bytecodes.c"
  80. value = GETLOCAL(oparg);
  81. assert(value != NULL);
  82. Py_INCREF(value);
  83. #line 90 "Python/generated_cases.c.h"
  84. STACK_GROW(1);
  85. stack_pointer[-1] = value;
  86. DISPATCH();
  87. }
  88. TARGET(LOAD_FAST_AND_CLEAR) {
  89. PyObject *value;
  90. #line 198 "Python/bytecodes.c"
  91. value = GETLOCAL(oparg);
  92. // do not use SETLOCAL here, it decrefs the old value
  93. GETLOCAL(oparg) = NULL;
  94. #line 102 "Python/generated_cases.c.h"
  95. STACK_GROW(1);
  96. stack_pointer[-1] = value;
  97. DISPATCH();
  98. }
  99. TARGET(LOAD_CONST) {
  100. PREDICTED(LOAD_CONST);
  101. PyObject *value;
  102. #line 204 "Python/bytecodes.c"
  103. value = GETITEM(frame->f_code->co_consts, oparg);
  104. Py_INCREF(value);
  105. #line 114 "Python/generated_cases.c.h"
  106. STACK_GROW(1);
  107. stack_pointer[-1] = value;
  108. DISPATCH();
  109. }
  110. TARGET(STORE_FAST) {
  111. PyObject *value = stack_pointer[-1];
  112. #line 209 "Python/bytecodes.c"
  113. SETLOCAL(oparg, value);
  114. #line 124 "Python/generated_cases.c.h"
  115. STACK_SHRINK(1);
  116. DISPATCH();
  117. }
  118. TARGET(LOAD_FAST__LOAD_FAST) {
  119. PyObject *_tmp_1;
  120. PyObject *_tmp_2;
  121. {
  122. PyObject *value;
  123. #line 192 "Python/bytecodes.c"
  124. value = GETLOCAL(oparg);
  125. assert(value != NULL);
  126. Py_INCREF(value);
  127. #line 138 "Python/generated_cases.c.h"
  128. _tmp_2 = value;
  129. }
  130. oparg = (next_instr++)->op.arg;
  131. {
  132. PyObject *value;
  133. #line 192 "Python/bytecodes.c"
  134. value = GETLOCAL(oparg);
  135. assert(value != NULL);
  136. Py_INCREF(value);
  137. #line 148 "Python/generated_cases.c.h"
  138. _tmp_1 = value;
  139. }
  140. STACK_GROW(2);
  141. stack_pointer[-1] = _tmp_1;
  142. stack_pointer[-2] = _tmp_2;
  143. DISPATCH();
  144. }
  145. TARGET(LOAD_FAST__LOAD_CONST) {
  146. PyObject *_tmp_1;
  147. PyObject *_tmp_2;
  148. {
  149. PyObject *value;
  150. #line 192 "Python/bytecodes.c"
  151. value = GETLOCAL(oparg);
  152. assert(value != NULL);
  153. Py_INCREF(value);
  154. #line 166 "Python/generated_cases.c.h"
  155. _tmp_2 = value;
  156. }
  157. oparg = (next_instr++)->op.arg;
  158. {
  159. PyObject *value;
  160. #line 204 "Python/bytecodes.c"
  161. value = GETITEM(frame->f_code->co_consts, oparg);
  162. Py_INCREF(value);
  163. #line 175 "Python/generated_cases.c.h"
  164. _tmp_1 = value;
  165. }
  166. STACK_GROW(2);
  167. stack_pointer[-1] = _tmp_1;
  168. stack_pointer[-2] = _tmp_2;
  169. DISPATCH();
  170. }
  171. TARGET(STORE_FAST__LOAD_FAST) {
  172. PyObject *_tmp_1 = stack_pointer[-1];
  173. {
  174. PyObject *value = _tmp_1;
  175. #line 209 "Python/bytecodes.c"
  176. SETLOCAL(oparg, value);
  177. #line 190 "Python/generated_cases.c.h"
  178. }
  179. oparg = (next_instr++)->op.arg;
  180. {
  181. PyObject *value;
  182. #line 192 "Python/bytecodes.c"
  183. value = GETLOCAL(oparg);
  184. assert(value != NULL);
  185. Py_INCREF(value);
  186. #line 199 "Python/generated_cases.c.h"
  187. _tmp_1 = value;
  188. }
  189. stack_pointer[-1] = _tmp_1;
  190. DISPATCH();
  191. }
  192. TARGET(STORE_FAST__STORE_FAST) {
  193. PyObject *_tmp_1 = stack_pointer[-1];
  194. PyObject *_tmp_2 = stack_pointer[-2];
  195. {
  196. PyObject *value = _tmp_1;
  197. #line 209 "Python/bytecodes.c"
  198. SETLOCAL(oparg, value);
  199. #line 213 "Python/generated_cases.c.h"
  200. }
  201. oparg = (next_instr++)->op.arg;
  202. {
  203. PyObject *value = _tmp_2;
  204. #line 209 "Python/bytecodes.c"
  205. SETLOCAL(oparg, value);
  206. #line 220 "Python/generated_cases.c.h"
  207. }
  208. STACK_SHRINK(2);
  209. DISPATCH();
  210. }
  211. TARGET(LOAD_CONST__LOAD_FAST) {
  212. PyObject *_tmp_1;
  213. PyObject *_tmp_2;
  214. {
  215. PyObject *value;
  216. #line 204 "Python/bytecodes.c"
  217. value = GETITEM(frame->f_code->co_consts, oparg);
  218. Py_INCREF(value);
  219. #line 234 "Python/generated_cases.c.h"
  220. _tmp_2 = value;
  221. }
  222. oparg = (next_instr++)->op.arg;
  223. {
  224. PyObject *value;
  225. #line 192 "Python/bytecodes.c"
  226. value = GETLOCAL(oparg);
  227. assert(value != NULL);
  228. Py_INCREF(value);
  229. #line 244 "Python/generated_cases.c.h"
  230. _tmp_1 = value;
  231. }
  232. STACK_GROW(2);
  233. stack_pointer[-1] = _tmp_1;
  234. stack_pointer[-2] = _tmp_2;
  235. DISPATCH();
  236. }
  237. TARGET(POP_TOP) {
  238. PyObject *value = stack_pointer[-1];
  239. #line 219 "Python/bytecodes.c"
  240. #line 256 "Python/generated_cases.c.h"
  241. Py_DECREF(value);
  242. STACK_SHRINK(1);
  243. DISPATCH();
  244. }
  245. TARGET(PUSH_NULL) {
  246. PyObject *res;
  247. #line 223 "Python/bytecodes.c"
  248. res = NULL;
  249. #line 266 "Python/generated_cases.c.h"
  250. STACK_GROW(1);
  251. stack_pointer[-1] = res;
  252. DISPATCH();
  253. }
  254. TARGET(END_FOR) {
  255. PyObject *_tmp_1 = stack_pointer[-1];
  256. PyObject *_tmp_2 = stack_pointer[-2];
  257. {
  258. PyObject *value = _tmp_1;
  259. #line 219 "Python/bytecodes.c"
  260. #line 278 "Python/generated_cases.c.h"
  261. Py_DECREF(value);
  262. }
  263. {
  264. PyObject *value = _tmp_2;
  265. #line 219 "Python/bytecodes.c"
  266. #line 284 "Python/generated_cases.c.h"
  267. Py_DECREF(value);
  268. }
  269. STACK_SHRINK(2);
  270. DISPATCH();
  271. }
  272. TARGET(INSTRUMENTED_END_FOR) {
  273. PyObject *value = stack_pointer[-1];
  274. PyObject *receiver = stack_pointer[-2];
  275. #line 229 "Python/bytecodes.c"
  276. /* Need to create a fake StopIteration error here,
  277. * to conform to PEP 380 */
  278. if (PyGen_Check(receiver)) {
  279. PyErr_SetObject(PyExc_StopIteration, value);
  280. if (monitor_stop_iteration(tstate, frame, next_instr-1)) {
  281. goto error;
  282. }
  283. PyErr_SetRaisedException(NULL);
  284. }
  285. #line 304 "Python/generated_cases.c.h"
  286. Py_DECREF(receiver);
  287. Py_DECREF(value);
  288. STACK_SHRINK(2);
  289. DISPATCH();
  290. }
  291. TARGET(END_SEND) {
  292. PyObject *value = stack_pointer[-1];
  293. PyObject *receiver = stack_pointer[-2];
  294. #line 242 "Python/bytecodes.c"
  295. Py_DECREF(receiver);
  296. #line 316 "Python/generated_cases.c.h"
  297. STACK_SHRINK(1);
  298. stack_pointer[-1] = value;
  299. DISPATCH();
  300. }
  301. TARGET(INSTRUMENTED_END_SEND) {
  302. PyObject *value = stack_pointer[-1];
  303. PyObject *receiver = stack_pointer[-2];
  304. #line 246 "Python/bytecodes.c"
  305. if (PyGen_Check(receiver) || PyCoro_CheckExact(receiver)) {
  306. PyErr_SetObject(PyExc_StopIteration, value);
  307. if (monitor_stop_iteration(tstate, frame, next_instr-1)) {
  308. goto error;
  309. }
  310. PyErr_SetRaisedException(NULL);
  311. }
  312. Py_DECREF(receiver);
  313. #line 334 "Python/generated_cases.c.h"
  314. STACK_SHRINK(1);
  315. stack_pointer[-1] = value;
  316. DISPATCH();
  317. }
  318. TARGET(UNARY_NEGATIVE) {
  319. PyObject *value = stack_pointer[-1];
  320. PyObject *res;
  321. #line 257 "Python/bytecodes.c"
  322. res = PyNumber_Negative(value);
  323. #line 345 "Python/generated_cases.c.h"
  324. Py_DECREF(value);
  325. #line 259 "Python/bytecodes.c"
  326. if (res == NULL) goto pop_1_error;
  327. #line 349 "Python/generated_cases.c.h"
  328. stack_pointer[-1] = res;
  329. DISPATCH();
  330. }
  331. TARGET(UNARY_NOT) {
  332. PyObject *value = stack_pointer[-1];
  333. PyObject *res;
  334. #line 263 "Python/bytecodes.c"
  335. int err = PyObject_IsTrue(value);
  336. #line 359 "Python/generated_cases.c.h"
  337. Py_DECREF(value);
  338. #line 265 "Python/bytecodes.c"
  339. if (err < 0) goto pop_1_error;
  340. if (err == 0) {
  341. res = Py_True;
  342. }
  343. else {
  344. res = Py_False;
  345. }
  346. #line 369 "Python/generated_cases.c.h"
  347. stack_pointer[-1] = res;
  348. DISPATCH();
  349. }
  350. TARGET(UNARY_INVERT) {
  351. PyObject *value = stack_pointer[-1];
  352. PyObject *res;
  353. #line 275 "Python/bytecodes.c"
  354. res = PyNumber_Invert(value);
  355. #line 379 "Python/generated_cases.c.h"
  356. Py_DECREF(value);
  357. #line 277 "Python/bytecodes.c"
  358. if (res == NULL) goto pop_1_error;
  359. #line 383 "Python/generated_cases.c.h"
  360. stack_pointer[-1] = res;
  361. DISPATCH();
  362. }
  363. TARGET(BINARY_OP_MULTIPLY_INT) {
  364. PyObject *right = stack_pointer[-1];
  365. PyObject *left = stack_pointer[-2];
  366. PyObject *prod;
  367. #line 294 "Python/bytecodes.c"
  368. DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
  369. DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
  370. STAT_INC(BINARY_OP, hit);
  371. prod = _PyLong_Multiply((PyLongObject *)left, (PyLongObject *)right);
  372. _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
  373. _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
  374. if (prod == NULL) goto pop_2_error;
  375. #line 400 "Python/generated_cases.c.h"
  376. STACK_SHRINK(1);
  377. stack_pointer[-1] = prod;
  378. next_instr += 1;
  379. DISPATCH();
  380. }
  381. TARGET(BINARY_OP_MULTIPLY_FLOAT) {
  382. PyObject *right = stack_pointer[-1];
  383. PyObject *left = stack_pointer[-2];
  384. PyObject *prod;
  385. #line 304 "Python/bytecodes.c"
  386. DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
  387. DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
  388. STAT_INC(BINARY_OP, hit);
  389. double dprod = ((PyFloatObject *)left)->ob_fval *
  390. ((PyFloatObject *)right)->ob_fval;
  391. DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dprod, prod);
  392. #line 418 "Python/generated_cases.c.h"
  393. STACK_SHRINK(1);
  394. stack_pointer[-1] = prod;
  395. next_instr += 1;
  396. DISPATCH();
  397. }
  398. TARGET(BINARY_OP_SUBTRACT_INT) {
  399. PyObject *right = stack_pointer[-1];
  400. PyObject *left = stack_pointer[-2];
  401. PyObject *sub;
  402. #line 313 "Python/bytecodes.c"
  403. DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
  404. DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
  405. STAT_INC(BINARY_OP, hit);
  406. sub = _PyLong_Subtract((PyLongObject *)left, (PyLongObject *)right);
  407. _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
  408. _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
  409. if (sub == NULL) goto pop_2_error;
  410. #line 437 "Python/generated_cases.c.h"
  411. STACK_SHRINK(1);
  412. stack_pointer[-1] = sub;
  413. next_instr += 1;
  414. DISPATCH();
  415. }
  416. TARGET(BINARY_OP_SUBTRACT_FLOAT) {
  417. PyObject *right = stack_pointer[-1];
  418. PyObject *left = stack_pointer[-2];
  419. PyObject *sub;
  420. #line 323 "Python/bytecodes.c"
  421. DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
  422. DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
  423. STAT_INC(BINARY_OP, hit);
  424. double dsub = ((PyFloatObject *)left)->ob_fval - ((PyFloatObject *)right)->ob_fval;
  425. DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsub, sub);
  426. #line 454 "Python/generated_cases.c.h"
  427. STACK_SHRINK(1);
  428. stack_pointer[-1] = sub;
  429. next_instr += 1;
  430. DISPATCH();
  431. }
  432. TARGET(BINARY_OP_ADD_UNICODE) {
  433. PyObject *right = stack_pointer[-1];
  434. PyObject *left = stack_pointer[-2];
  435. PyObject *res;
  436. #line 331 "Python/bytecodes.c"
  437. DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP);
  438. DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
  439. STAT_INC(BINARY_OP, hit);
  440. res = PyUnicode_Concat(left, right);
  441. _Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc);
  442. _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
  443. if (res == NULL) goto pop_2_error;
  444. #line 473 "Python/generated_cases.c.h"
  445. STACK_SHRINK(1);
  446. stack_pointer[-1] = res;
  447. next_instr += 1;
  448. DISPATCH();
  449. }
  450. TARGET(BINARY_OP_INPLACE_ADD_UNICODE) {
  451. PyObject *right = stack_pointer[-1];
  452. PyObject *left = stack_pointer[-2];
  453. #line 347 "Python/bytecodes.c"
  454. DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP);
  455. DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
  456. _Py_CODEUNIT true_next = next_instr[INLINE_CACHE_ENTRIES_BINARY_OP];
  457. assert(true_next.op.code == STORE_FAST ||
  458. true_next.op.code == STORE_FAST__LOAD_FAST);
  459. PyObject **target_local = &GETLOCAL(true_next.op.arg);
  460. DEOPT_IF(*target_local != left, BINARY_OP);
  461. STAT_INC(BINARY_OP, hit);
  462. /* Handle `left = left + right` or `left += right` for str.
  463. *
  464. * When possible, extend `left` in place rather than
  465. * allocating a new PyUnicodeObject. This attempts to avoid
  466. * quadratic behavior when one neglects to use str.join().
  467. *
  468. * If `left` has only two references remaining (one from
  469. * the stack, one in the locals), DECREFing `left` leaves
  470. * only the locals reference, so PyUnicode_Append knows
  471. * that the string is safe to mutate.
  472. */
  473. assert(Py_REFCNT(left) >= 2);
  474. _Py_DECREF_NO_DEALLOC(left);
  475. PyUnicode_Append(target_local, right);
  476. _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
  477. if (*target_local == NULL) goto pop_2_error;
  478. // The STORE_FAST is already done.
  479. JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP + 1);
  480. #line 510 "Python/generated_cases.c.h"
  481. STACK_SHRINK(2);
  482. DISPATCH();
  483. }
  484. TARGET(BINARY_OP_ADD_FLOAT) {
  485. PyObject *right = stack_pointer[-1];
  486. PyObject *left = stack_pointer[-2];
  487. PyObject *sum;
  488. #line 376 "Python/bytecodes.c"
  489. DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
  490. DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
  491. STAT_INC(BINARY_OP, hit);
  492. double dsum = ((PyFloatObject *)left)->ob_fval +
  493. ((PyFloatObject *)right)->ob_fval;
  494. DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsum, sum);
  495. #line 526 "Python/generated_cases.c.h"
  496. STACK_SHRINK(1);
  497. stack_pointer[-1] = sum;
  498. next_instr += 1;
  499. DISPATCH();
  500. }
  501. TARGET(BINARY_OP_ADD_INT) {
  502. PyObject *right = stack_pointer[-1];
  503. PyObject *left = stack_pointer[-2];
  504. PyObject *sum;
  505. #line 385 "Python/bytecodes.c"
  506. DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
  507. DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
  508. STAT_INC(BINARY_OP, hit);
  509. sum = _PyLong_Add((PyLongObject *)left, (PyLongObject *)right);
  510. _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
  511. _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
  512. if (sum == NULL) goto pop_2_error;
  513. #line 545 "Python/generated_cases.c.h"
  514. STACK_SHRINK(1);
  515. stack_pointer[-1] = sum;
  516. next_instr += 1;
  517. DISPATCH();
  518. }
  519. TARGET(BINARY_SUBSCR) {
  520. PREDICTED(BINARY_SUBSCR);
  521. static_assert(INLINE_CACHE_ENTRIES_BINARY_SUBSCR == 1, "incorrect cache size");
  522. PyObject *sub = stack_pointer[-1];
  523. PyObject *container = stack_pointer[-2];
  524. PyObject *res;
  525. #line 403 "Python/bytecodes.c"
  526. #if ENABLE_SPECIALIZATION
  527. _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
  528. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  529. next_instr--;
  530. _Py_Specialize_BinarySubscr(container, sub, next_instr);
  531. DISPATCH_SAME_OPARG();
  532. }
  533. STAT_INC(BINARY_SUBSCR, deferred);
  534. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  535. #endif /* ENABLE_SPECIALIZATION */
  536. res = PyObject_GetItem(container, sub);
  537. #line 570 "Python/generated_cases.c.h"
  538. Py_DECREF(container);
  539. Py_DECREF(sub);
  540. #line 415 "Python/bytecodes.c"
  541. if (res == NULL) goto pop_2_error;
  542. #line 575 "Python/generated_cases.c.h"
  543. STACK_SHRINK(1);
  544. stack_pointer[-1] = res;
  545. next_instr += 1;
  546. DISPATCH();
  547. }
  548. TARGET(BINARY_SLICE) {
  549. PyObject *stop = stack_pointer[-1];
  550. PyObject *start = stack_pointer[-2];
  551. PyObject *container = stack_pointer[-3];
  552. PyObject *res;
  553. #line 419 "Python/bytecodes.c"
  554. PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop);
  555. // Can't use ERROR_IF() here, because we haven't
  556. // DECREF'ed container yet, and we still own slice.
  557. if (slice == NULL) {
  558. res = NULL;
  559. }
  560. else {
  561. res = PyObject_GetItem(container, slice);
  562. Py_DECREF(slice);
  563. }
  564. Py_DECREF(container);
  565. if (res == NULL) goto pop_3_error;
  566. #line 600 "Python/generated_cases.c.h"
  567. STACK_SHRINK(2);
  568. stack_pointer[-1] = res;
  569. DISPATCH();
  570. }
  571. TARGET(STORE_SLICE) {
  572. PyObject *stop = stack_pointer[-1];
  573. PyObject *start = stack_pointer[-2];
  574. PyObject *container = stack_pointer[-3];
  575. PyObject *v = stack_pointer[-4];
  576. #line 434 "Python/bytecodes.c"
  577. PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop);
  578. int err;
  579. if (slice == NULL) {
  580. err = 1;
  581. }
  582. else {
  583. err = PyObject_SetItem(container, slice, v);
  584. Py_DECREF(slice);
  585. }
  586. Py_DECREF(v);
  587. Py_DECREF(container);
  588. if (err) goto pop_4_error;
  589. #line 624 "Python/generated_cases.c.h"
  590. STACK_SHRINK(4);
  591. DISPATCH();
  592. }
  593. TARGET(BINARY_SUBSCR_LIST_INT) {
  594. PyObject *sub = stack_pointer[-1];
  595. PyObject *list = stack_pointer[-2];
  596. PyObject *res;
  597. #line 449 "Python/bytecodes.c"
  598. DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR);
  599. DEOPT_IF(!PyList_CheckExact(list), BINARY_SUBSCR);
  600. // Deopt unless 0 <= sub < PyList_Size(list)
  601. DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), BINARY_SUBSCR);
  602. Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
  603. DEOPT_IF(index >= PyList_GET_SIZE(list), BINARY_SUBSCR);
  604. STAT_INC(BINARY_SUBSCR, hit);
  605. res = PyList_GET_ITEM(list, index);
  606. assert(res != NULL);
  607. Py_INCREF(res);
  608. _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
  609. Py_DECREF(list);
  610. #line 647 "Python/generated_cases.c.h"
  611. STACK_SHRINK(1);
  612. stack_pointer[-1] = res;
  613. next_instr += 1;
  614. DISPATCH();
  615. }
  616. TARGET(BINARY_SUBSCR_TUPLE_INT) {
  617. PyObject *sub = stack_pointer[-1];
  618. PyObject *tuple = stack_pointer[-2];
  619. PyObject *res;
  620. #line 465 "Python/bytecodes.c"
  621. DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR);
  622. DEOPT_IF(!PyTuple_CheckExact(tuple), BINARY_SUBSCR);
  623. // Deopt unless 0 <= sub < PyTuple_Size(list)
  624. DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), BINARY_SUBSCR);
  625. Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
  626. DEOPT_IF(index >= PyTuple_GET_SIZE(tuple), BINARY_SUBSCR);
  627. STAT_INC(BINARY_SUBSCR, hit);
  628. res = PyTuple_GET_ITEM(tuple, index);
  629. assert(res != NULL);
  630. Py_INCREF(res);
  631. _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
  632. Py_DECREF(tuple);
  633. #line 672 "Python/generated_cases.c.h"
  634. STACK_SHRINK(1);
  635. stack_pointer[-1] = res;
  636. next_instr += 1;
  637. DISPATCH();
  638. }
  639. TARGET(BINARY_SUBSCR_DICT) {
  640. PyObject *sub = stack_pointer[-1];
  641. PyObject *dict = stack_pointer[-2];
  642. PyObject *res;
  643. #line 481 "Python/bytecodes.c"
  644. DEOPT_IF(!PyDict_CheckExact(dict), BINARY_SUBSCR);
  645. STAT_INC(BINARY_SUBSCR, hit);
  646. res = PyDict_GetItemWithError(dict, sub);
  647. if (res == NULL) {
  648. if (!_PyErr_Occurred(tstate)) {
  649. _PyErr_SetKeyError(sub);
  650. }
  651. #line 691 "Python/generated_cases.c.h"
  652. Py_DECREF(dict);
  653. Py_DECREF(sub);
  654. #line 489 "Python/bytecodes.c"
  655. if (true) goto pop_2_error;
  656. }
  657. Py_INCREF(res); // Do this before DECREF'ing dict, sub
  658. #line 698 "Python/generated_cases.c.h"
  659. Py_DECREF(dict);
  660. Py_DECREF(sub);
  661. STACK_SHRINK(1);
  662. stack_pointer[-1] = res;
  663. next_instr += 1;
  664. DISPATCH();
  665. }
  666. TARGET(BINARY_SUBSCR_GETITEM) {
  667. PyObject *sub = stack_pointer[-1];
  668. PyObject *container = stack_pointer[-2];
  669. #line 496 "Python/bytecodes.c"
  670. DEOPT_IF(tstate->interp->eval_frame, BINARY_SUBSCR);
  671. PyTypeObject *tp = Py_TYPE(container);
  672. DEOPT_IF(!PyType_HasFeature(tp, Py_TPFLAGS_HEAPTYPE), BINARY_SUBSCR);
  673. PyHeapTypeObject *ht = (PyHeapTypeObject *)tp;
  674. PyObject *cached = ht->_spec_cache.getitem;
  675. DEOPT_IF(cached == NULL, BINARY_SUBSCR);
  676. assert(PyFunction_Check(cached));
  677. PyFunctionObject *getitem = (PyFunctionObject *)cached;
  678. uint32_t cached_version = ht->_spec_cache.getitem_version;
  679. DEOPT_IF(getitem->func_version != cached_version, BINARY_SUBSCR);
  680. PyCodeObject *code = (PyCodeObject *)getitem->func_code;
  681. assert(code->co_argcount == 2);
  682. DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), BINARY_SUBSCR);
  683. STAT_INC(BINARY_SUBSCR, hit);
  684. Py_INCREF(getitem);
  685. _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, getitem, 2);
  686. STACK_SHRINK(2);
  687. new_frame->localsplus[0] = container;
  688. new_frame->localsplus[1] = sub;
  689. JUMPBY(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
  690. frame->return_offset = 0;
  691. DISPATCH_INLINED(new_frame);
  692. #line 733 "Python/generated_cases.c.h"
  693. }
  694. TARGET(LIST_APPEND) {
  695. PyObject *v = stack_pointer[-1];
  696. PyObject *list = stack_pointer[-(2 + (oparg-1))];
  697. #line 521 "Python/bytecodes.c"
  698. if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0) goto pop_1_error;
  699. #line 741 "Python/generated_cases.c.h"
  700. STACK_SHRINK(1);
  701. PREDICT(JUMP_BACKWARD);
  702. DISPATCH();
  703. }
  704. TARGET(SET_ADD) {
  705. PyObject *v = stack_pointer[-1];
  706. PyObject *set = stack_pointer[-(2 + (oparg-1))];
  707. #line 526 "Python/bytecodes.c"
  708. int err = PySet_Add(set, v);
  709. #line 752 "Python/generated_cases.c.h"
  710. Py_DECREF(v);
  711. #line 528 "Python/bytecodes.c"
  712. if (err) goto pop_1_error;
  713. #line 756 "Python/generated_cases.c.h"
  714. STACK_SHRINK(1);
  715. PREDICT(JUMP_BACKWARD);
  716. DISPATCH();
  717. }
  718. TARGET(STORE_SUBSCR) {
  719. PREDICTED(STORE_SUBSCR);
  720. static_assert(INLINE_CACHE_ENTRIES_STORE_SUBSCR == 1, "incorrect cache size");
  721. PyObject *sub = stack_pointer[-1];
  722. PyObject *container = stack_pointer[-2];
  723. PyObject *v = stack_pointer[-3];
  724. uint16_t counter = read_u16(&next_instr[0].cache);
  725. #line 539 "Python/bytecodes.c"
  726. #if ENABLE_SPECIALIZATION
  727. if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
  728. next_instr--;
  729. _Py_Specialize_StoreSubscr(container, sub, next_instr);
  730. DISPATCH_SAME_OPARG();
  731. }
  732. STAT_INC(STORE_SUBSCR, deferred);
  733. _PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
  734. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  735. #else
  736. (void)counter; // Unused.
  737. #endif /* ENABLE_SPECIALIZATION */
  738. /* container[sub] = v */
  739. int err = PyObject_SetItem(container, sub, v);
  740. #line 784 "Python/generated_cases.c.h"
  741. Py_DECREF(v);
  742. Py_DECREF(container);
  743. Py_DECREF(sub);
  744. #line 554 "Python/bytecodes.c"
  745. if (err) goto pop_3_error;
  746. #line 790 "Python/generated_cases.c.h"
  747. STACK_SHRINK(3);
  748. next_instr += 1;
  749. DISPATCH();
  750. }
  751. TARGET(STORE_SUBSCR_LIST_INT) {
  752. PyObject *sub = stack_pointer[-1];
  753. PyObject *list = stack_pointer[-2];
  754. PyObject *value = stack_pointer[-3];
  755. #line 558 "Python/bytecodes.c"
  756. DEOPT_IF(!PyLong_CheckExact(sub), STORE_SUBSCR);
  757. DEOPT_IF(!PyList_CheckExact(list), STORE_SUBSCR);
  758. // Ensure nonnegative, zero-or-one-digit ints.
  759. DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), STORE_SUBSCR);
  760. Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
  761. // Ensure index < len(list)
  762. DEOPT_IF(index >= PyList_GET_SIZE(list), STORE_SUBSCR);
  763. STAT_INC(STORE_SUBSCR, hit);
  764. PyObject *old_value = PyList_GET_ITEM(list, index);
  765. PyList_SET_ITEM(list, index, value);
  766. assert(old_value != NULL);
  767. Py_DECREF(old_value);
  768. _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
  769. Py_DECREF(list);
  770. #line 817 "Python/generated_cases.c.h"
  771. STACK_SHRINK(3);
  772. next_instr += 1;
  773. DISPATCH();
  774. }
  775. TARGET(STORE_SUBSCR_DICT) {
  776. PyObject *sub = stack_pointer[-1];
  777. PyObject *dict = stack_pointer[-2];
  778. PyObject *value = stack_pointer[-3];
  779. #line 577 "Python/bytecodes.c"
  780. DEOPT_IF(!PyDict_CheckExact(dict), STORE_SUBSCR);
  781. STAT_INC(STORE_SUBSCR, hit);
  782. int err = _PyDict_SetItem_Take2((PyDictObject *)dict, sub, value);
  783. Py_DECREF(dict);
  784. if (err) goto pop_3_error;
  785. #line 833 "Python/generated_cases.c.h"
  786. STACK_SHRINK(3);
  787. next_instr += 1;
  788. DISPATCH();
  789. }
  790. TARGET(DELETE_SUBSCR) {
  791. PyObject *sub = stack_pointer[-1];
  792. PyObject *container = stack_pointer[-2];
  793. #line 585 "Python/bytecodes.c"
  794. /* del container[sub] */
  795. int err = PyObject_DelItem(container, sub);
  796. #line 845 "Python/generated_cases.c.h"
  797. Py_DECREF(container);
  798. Py_DECREF(sub);
  799. #line 588 "Python/bytecodes.c"
  800. if (err) goto pop_2_error;
  801. #line 850 "Python/generated_cases.c.h"
  802. STACK_SHRINK(2);
  803. DISPATCH();
  804. }
  805. TARGET(CALL_INTRINSIC_1) {
  806. PyObject *value = stack_pointer[-1];
  807. PyObject *res;
  808. #line 592 "Python/bytecodes.c"
  809. assert(oparg <= MAX_INTRINSIC_1);
  810. res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value);
  811. #line 861 "Python/generated_cases.c.h"
  812. Py_DECREF(value);
  813. #line 595 "Python/bytecodes.c"
  814. if (res == NULL) goto pop_1_error;
  815. #line 865 "Python/generated_cases.c.h"
  816. stack_pointer[-1] = res;
  817. DISPATCH();
  818. }
  819. TARGET(CALL_INTRINSIC_2) {
  820. PyObject *value1 = stack_pointer[-1];
  821. PyObject *value2 = stack_pointer[-2];
  822. PyObject *res;
  823. #line 599 "Python/bytecodes.c"
  824. assert(oparg <= MAX_INTRINSIC_2);
  825. res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1);
  826. #line 877 "Python/generated_cases.c.h"
  827. Py_DECREF(value2);
  828. Py_DECREF(value1);
  829. #line 602 "Python/bytecodes.c"
  830. if (res == NULL) goto pop_2_error;
  831. #line 882 "Python/generated_cases.c.h"
  832. STACK_SHRINK(1);
  833. stack_pointer[-1] = res;
  834. DISPATCH();
  835. }
  836. TARGET(RAISE_VARARGS) {
  837. PyObject **args = (stack_pointer - oparg);
  838. #line 606 "Python/bytecodes.c"
  839. PyObject *cause = NULL, *exc = NULL;
  840. switch (oparg) {
  841. case 2:
  842. cause = args[1];
  843. /* fall through */
  844. case 1:
  845. exc = args[0];
  846. /* fall through */
  847. case 0:
  848. if (do_raise(tstate, exc, cause)) {
  849. assert(oparg == 0);
  850. monitor_reraise(tstate, frame, next_instr-1);
  851. goto exception_unwind;
  852. }
  853. break;
  854. default:
  855. _PyErr_SetString(tstate, PyExc_SystemError,
  856. "bad RAISE_VARARGS oparg");
  857. break;
  858. }
  859. if (true) { STACK_SHRINK(oparg); goto error; }
  860. #line 912 "Python/generated_cases.c.h"
  861. }
  862. TARGET(INTERPRETER_EXIT) {
  863. PyObject *retval = stack_pointer[-1];
  864. #line 630 "Python/bytecodes.c"
  865. assert(frame == &entry_frame);
  866. assert(_PyFrame_IsIncomplete(frame));
  867. STACK_SHRINK(1); // Since we're not going to DISPATCH()
  868. assert(EMPTY());
  869. /* Restore previous cframe and return. */
  870. tstate->cframe = cframe.previous;
  871. assert(tstate->cframe->current_frame == frame->previous);
  872. assert(!_PyErr_Occurred(tstate));
  873. tstate->c_recursion_remaining += PY_EVAL_C_STACK_UNITS;
  874. return retval;
  875. #line 928 "Python/generated_cases.c.h"
  876. }
  877. TARGET(RETURN_VALUE) {
  878. PyObject *retval = stack_pointer[-1];
  879. #line 643 "Python/bytecodes.c"
  880. STACK_SHRINK(1);
  881. assert(EMPTY());
  882. _PyFrame_SetStackPointer(frame, stack_pointer);
  883. _Py_LeaveRecursiveCallPy(tstate);
  884. assert(frame != &entry_frame);
  885. // GH-99729: We need to unlink the frame *before* clearing it:
  886. _PyInterpreterFrame *dying = frame;
  887. frame = cframe.current_frame = dying->previous;
  888. _PyEvalFrameClearAndPop(tstate, dying);
  889. frame->prev_instr += frame->return_offset;
  890. _PyFrame_StackPush(frame, retval);
  891. goto resume_frame;
  892. #line 946 "Python/generated_cases.c.h"
  893. }
  894. TARGET(INSTRUMENTED_RETURN_VALUE) {
  895. PyObject *retval = stack_pointer[-1];
  896. #line 658 "Python/bytecodes.c"
  897. int err = _Py_call_instrumentation_arg(
  898. tstate, PY_MONITORING_EVENT_PY_RETURN,
  899. frame, next_instr-1, retval);
  900. if (err) goto error;
  901. STACK_SHRINK(1);
  902. assert(EMPTY());
  903. _PyFrame_SetStackPointer(frame, stack_pointer);
  904. _Py_LeaveRecursiveCallPy(tstate);
  905. assert(frame != &entry_frame);
  906. // GH-99729: We need to unlink the frame *before* clearing it:
  907. _PyInterpreterFrame *dying = frame;
  908. frame = cframe.current_frame = dying->previous;
  909. _PyEvalFrameClearAndPop(tstate, dying);
  910. frame->prev_instr += frame->return_offset;
  911. _PyFrame_StackPush(frame, retval);
  912. goto resume_frame;
  913. #line 968 "Python/generated_cases.c.h"
  914. }
  915. TARGET(RETURN_CONST) {
  916. #line 677 "Python/bytecodes.c"
  917. PyObject *retval = GETITEM(frame->f_code->co_consts, oparg);
  918. Py_INCREF(retval);
  919. assert(EMPTY());
  920. _PyFrame_SetStackPointer(frame, stack_pointer);
  921. _Py_LeaveRecursiveCallPy(tstate);
  922. assert(frame != &entry_frame);
  923. // GH-99729: We need to unlink the frame *before* clearing it:
  924. _PyInterpreterFrame *dying = frame;
  925. frame = cframe.current_frame = dying->previous;
  926. _PyEvalFrameClearAndPop(tstate, dying);
  927. frame->prev_instr += frame->return_offset;
  928. _PyFrame_StackPush(frame, retval);
  929. goto resume_frame;
  930. #line 986 "Python/generated_cases.c.h"
  931. }
  932. TARGET(INSTRUMENTED_RETURN_CONST) {
  933. #line 693 "Python/bytecodes.c"
  934. PyObject *retval = GETITEM(frame->f_code->co_consts, oparg);
  935. int err = _Py_call_instrumentation_arg(
  936. tstate, PY_MONITORING_EVENT_PY_RETURN,
  937. frame, next_instr-1, retval);
  938. if (err) goto error;
  939. Py_INCREF(retval);
  940. assert(EMPTY());
  941. _PyFrame_SetStackPointer(frame, stack_pointer);
  942. _Py_LeaveRecursiveCallPy(tstate);
  943. assert(frame != &entry_frame);
  944. // GH-99729: We need to unlink the frame *before* clearing it:
  945. _PyInterpreterFrame *dying = frame;
  946. frame = cframe.current_frame = dying->previous;
  947. _PyEvalFrameClearAndPop(tstate, dying);
  948. frame->prev_instr += frame->return_offset;
  949. _PyFrame_StackPush(frame, retval);
  950. goto resume_frame;
  951. #line 1008 "Python/generated_cases.c.h"
  952. }
  953. TARGET(GET_AITER) {
  954. PyObject *obj = stack_pointer[-1];
  955. PyObject *iter;
  956. #line 713 "Python/bytecodes.c"
  957. unaryfunc getter = NULL;
  958. PyTypeObject *type = Py_TYPE(obj);
  959. if (type->tp_as_async != NULL) {
  960. getter = type->tp_as_async->am_aiter;
  961. }
  962. if (getter == NULL) {
  963. _PyErr_Format(tstate, PyExc_TypeError,
  964. "'async for' requires an object with "
  965. "__aiter__ method, got %.100s",
  966. type->tp_name);
  967. #line 1027 "Python/generated_cases.c.h"
  968. Py_DECREF(obj);
  969. #line 726 "Python/bytecodes.c"
  970. if (true) goto pop_1_error;
  971. }
  972. iter = (*getter)(obj);
  973. #line 1034 "Python/generated_cases.c.h"
  974. Py_DECREF(obj);
  975. #line 731 "Python/bytecodes.c"
  976. if (iter == NULL) goto pop_1_error;
  977. if (Py_TYPE(iter)->tp_as_async == NULL ||
  978. Py_TYPE(iter)->tp_as_async->am_anext == NULL) {
  979. _PyErr_Format(tstate, PyExc_TypeError,
  980. "'async for' received an object from __aiter__ "
  981. "that does not implement __anext__: %.100s",
  982. Py_TYPE(iter)->tp_name);
  983. Py_DECREF(iter);
  984. if (true) goto pop_1_error;
  985. }
  986. #line 1049 "Python/generated_cases.c.h"
  987. stack_pointer[-1] = iter;
  988. DISPATCH();
  989. }
  990. TARGET(GET_ANEXT) {
  991. PyObject *aiter = stack_pointer[-1];
  992. PyObject *awaitable;
  993. #line 746 "Python/bytecodes.c"
  994. unaryfunc getter = NULL;
  995. PyObject *next_iter = NULL;
  996. PyTypeObject *type = Py_TYPE(aiter);
  997. if (PyAsyncGen_CheckExact(aiter)) {
  998. awaitable = type->tp_as_async->am_anext(aiter);
  999. if (awaitable == NULL) {
  1000. goto error;
  1001. }
  1002. } else {
  1003. if (type->tp_as_async != NULL){
  1004. getter = type->tp_as_async->am_anext;
  1005. }
  1006. if (getter != NULL) {
  1007. next_iter = (*getter)(aiter);
  1008. if (next_iter == NULL) {
  1009. goto error;
  1010. }
  1011. }
  1012. else {
  1013. _PyErr_Format(tstate, PyExc_TypeError,
  1014. "'async for' requires an iterator with "
  1015. "__anext__ method, got %.100s",
  1016. type->tp_name);
  1017. goto error;
  1018. }
  1019. awaitable = _PyCoro_GetAwaitableIter(next_iter);
  1020. if (awaitable == NULL) {
  1021. _PyErr_FormatFromCause(
  1022. PyExc_TypeError,
  1023. "'async for' received an invalid object "
  1024. "from __anext__: %.100s",
  1025. Py_TYPE(next_iter)->tp_name);
  1026. Py_DECREF(next_iter);
  1027. goto error;
  1028. } else {
  1029. Py_DECREF(next_iter);
  1030. }
  1031. }
  1032. #line 1101 "Python/generated_cases.c.h"
  1033. STACK_GROW(1);
  1034. stack_pointer[-1] = awaitable;
  1035. PREDICT(LOAD_CONST);
  1036. DISPATCH();
  1037. }
  1038. TARGET(GET_AWAITABLE) {
  1039. PREDICTED(GET_AWAITABLE);
  1040. PyObject *iterable = stack_pointer[-1];
  1041. PyObject *iter;
  1042. #line 793 "Python/bytecodes.c"
  1043. iter = _PyCoro_GetAwaitableIter(iterable);
  1044. if (iter == NULL) {
  1045. format_awaitable_error(tstate, Py_TYPE(iterable), oparg);
  1046. }
  1047. #line 1119 "Python/generated_cases.c.h"
  1048. Py_DECREF(iterable);
  1049. #line 800 "Python/bytecodes.c"
  1050. if (iter != NULL && PyCoro_CheckExact(iter)) {
  1051. PyObject *yf = _PyGen_yf((PyGenObject*)iter);
  1052. if (yf != NULL) {
  1053. /* `iter` is a coroutine object that is being
  1054. awaited, `yf` is a pointer to the current awaitable
  1055. being awaited on. */
  1056. Py_DECREF(yf);
  1057. Py_CLEAR(iter);
  1058. _PyErr_SetString(tstate, PyExc_RuntimeError,
  1059. "coroutine is being awaited already");
  1060. /* The code below jumps to `error` if `iter` is NULL. */
  1061. }
  1062. }
  1063. if (iter == NULL) goto pop_1_error;
  1064. #line 1139 "Python/generated_cases.c.h"
  1065. stack_pointer[-1] = iter;
  1066. PREDICT(LOAD_CONST);
  1067. DISPATCH();
  1068. }
  1069. TARGET(SEND) {
  1070. PREDICTED(SEND);
  1071. static_assert(INLINE_CACHE_ENTRIES_SEND == 1, "incorrect cache size");
  1072. PyObject *v = stack_pointer[-1];
  1073. PyObject *receiver = stack_pointer[-2];
  1074. PyObject *retval;
  1075. #line 826 "Python/bytecodes.c"
  1076. #if ENABLE_SPECIALIZATION
  1077. _PySendCache *cache = (_PySendCache *)next_instr;
  1078. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  1079. next_instr--;
  1080. _Py_Specialize_Send(receiver, next_instr);
  1081. DISPATCH_SAME_OPARG();
  1082. }
  1083. STAT_INC(SEND, deferred);
  1084. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  1085. #endif /* ENABLE_SPECIALIZATION */
  1086. assert(frame != &entry_frame);
  1087. if ((tstate->interp->eval_frame == NULL) &&
  1088. (Py_TYPE(receiver) == &PyGen_Type || Py_TYPE(receiver) == &PyCoro_Type) &&
  1089. ((PyGenObject *)receiver)->gi_frame_state < FRAME_EXECUTING)
  1090. {
  1091. PyGenObject *gen = (PyGenObject *)receiver;
  1092. _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
  1093. frame->return_offset = oparg;
  1094. STACK_SHRINK(1);
  1095. _PyFrame_StackPush(gen_frame, v);
  1096. gen->gi_frame_state = FRAME_EXECUTING;
  1097. gen->gi_exc_state.previous_item = tstate->exc_info;
  1098. tstate->exc_info = &gen->gi_exc_state;
  1099. JUMPBY(INLINE_CACHE_ENTRIES_SEND);
  1100. DISPATCH_INLINED(gen_frame);
  1101. }
  1102. if (Py_IsNone(v) && PyIter_Check(receiver)) {
  1103. retval = Py_TYPE(receiver)->tp_iternext(receiver);
  1104. }
  1105. else {
  1106. retval = PyObject_CallMethodOneArg(receiver, &_Py_ID(send), v);
  1107. }
  1108. if (retval == NULL) {
  1109. if (_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)
  1110. ) {
  1111. monitor_raise(tstate, frame, next_instr-1);
  1112. }
  1113. if (_PyGen_FetchStopIterationValue(&retval) == 0) {
  1114. assert(retval != NULL);
  1115. JUMPBY(oparg);
  1116. }
  1117. else {
  1118. goto error;
  1119. }
  1120. }
  1121. Py_DECREF(v);
  1122. #line 1198 "Python/generated_cases.c.h"
  1123. stack_pointer[-1] = retval;
  1124. next_instr += 1;
  1125. DISPATCH();
  1126. }
  1127. TARGET(SEND_GEN) {
  1128. PyObject *v = stack_pointer[-1];
  1129. PyObject *receiver = stack_pointer[-2];
  1130. #line 875 "Python/bytecodes.c"
  1131. DEOPT_IF(tstate->interp->eval_frame, SEND);
  1132. PyGenObject *gen = (PyGenObject *)receiver;
  1133. DEOPT_IF(Py_TYPE(gen) != &PyGen_Type &&
  1134. Py_TYPE(gen) != &PyCoro_Type, SEND);
  1135. DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, SEND);
  1136. STAT_INC(SEND, hit);
  1137. _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
  1138. frame->return_offset = oparg;
  1139. STACK_SHRINK(1);
  1140. _PyFrame_StackPush(gen_frame, v);
  1141. gen->gi_frame_state = FRAME_EXECUTING;
  1142. gen->gi_exc_state.previous_item = tstate->exc_info;
  1143. tstate->exc_info = &gen->gi_exc_state;
  1144. JUMPBY(INLINE_CACHE_ENTRIES_SEND);
  1145. DISPATCH_INLINED(gen_frame);
  1146. #line 1223 "Python/generated_cases.c.h"
  1147. }
  1148. TARGET(INSTRUMENTED_YIELD_VALUE) {
  1149. PyObject *retval = stack_pointer[-1];
  1150. #line 893 "Python/bytecodes.c"
  1151. assert(frame != &entry_frame);
  1152. PyGenObject *gen = _PyFrame_GetGenerator(frame);
  1153. gen->gi_frame_state = FRAME_SUSPENDED;
  1154. _PyFrame_SetStackPointer(frame, stack_pointer - 1);
  1155. int err = _Py_call_instrumentation_arg(
  1156. tstate, PY_MONITORING_EVENT_PY_YIELD,
  1157. frame, next_instr-1, retval);
  1158. if (err) goto error;
  1159. tstate->exc_info = gen->gi_exc_state.previous_item;
  1160. gen->gi_exc_state.previous_item = NULL;
  1161. _Py_LeaveRecursiveCallPy(tstate);
  1162. _PyInterpreterFrame *gen_frame = frame;
  1163. frame = cframe.current_frame = frame->previous;
  1164. gen_frame->previous = NULL;
  1165. _PyFrame_StackPush(frame, retval);
  1166. goto resume_frame;
  1167. #line 1245 "Python/generated_cases.c.h"
  1168. }
  1169. TARGET(YIELD_VALUE) {
  1170. PyObject *retval = stack_pointer[-1];
  1171. #line 912 "Python/bytecodes.c"
  1172. // NOTE: It's important that YIELD_VALUE never raises an exception!
  1173. // The compiler treats any exception raised here as a failed close()
  1174. // or throw() call.
  1175. assert(frame != &entry_frame);
  1176. PyGenObject *gen = _PyFrame_GetGenerator(frame);
  1177. gen->gi_frame_state = FRAME_SUSPENDED;
  1178. _PyFrame_SetStackPointer(frame, stack_pointer - 1);
  1179. tstate->exc_info = gen->gi_exc_state.previous_item;
  1180. gen->gi_exc_state.previous_item = NULL;
  1181. _Py_LeaveRecursiveCallPy(tstate);
  1182. _PyInterpreterFrame *gen_frame = frame;
  1183. frame = cframe.current_frame = frame->previous;
  1184. gen_frame->previous = NULL;
  1185. _PyFrame_StackPush(frame, retval);
  1186. goto resume_frame;
  1187. #line 1266 "Python/generated_cases.c.h"
  1188. }
  1189. TARGET(POP_EXCEPT) {
  1190. PyObject *exc_value = stack_pointer[-1];
  1191. #line 930 "Python/bytecodes.c"
  1192. _PyErr_StackItem *exc_info = tstate->exc_info;
  1193. Py_XSETREF(exc_info->exc_value, exc_value);
  1194. #line 1274 "Python/generated_cases.c.h"
  1195. STACK_SHRINK(1);
  1196. DISPATCH();
  1197. }
  1198. TARGET(RERAISE) {
  1199. PyObject *exc = stack_pointer[-1];
  1200. PyObject **values = (stack_pointer - (1 + oparg));
  1201. #line 935 "Python/bytecodes.c"
  1202. assert(oparg >= 0 && oparg <= 2);
  1203. if (oparg) {
  1204. PyObject *lasti = values[0];
  1205. if (PyLong_Check(lasti)) {
  1206. frame->prev_instr = _PyCode_CODE(frame->f_code) + PyLong_AsLong(lasti);
  1207. assert(!_PyErr_Occurred(tstate));
  1208. }
  1209. else {
  1210. assert(PyLong_Check(lasti));
  1211. _PyErr_SetString(tstate, PyExc_SystemError, "lasti is not an int");
  1212. goto error;
  1213. }
  1214. }
  1215. assert(exc && PyExceptionInstance_Check(exc));
  1216. Py_INCREF(exc);
  1217. _PyErr_SetRaisedException(tstate, exc);
  1218. monitor_reraise(tstate, frame, next_instr-1);
  1219. goto exception_unwind;
  1220. #line 1301 "Python/generated_cases.c.h"
  1221. }
  1222. TARGET(END_ASYNC_FOR) {
  1223. PyObject *exc = stack_pointer[-1];
  1224. PyObject *awaitable = stack_pointer[-2];
  1225. #line 956 "Python/bytecodes.c"
  1226. assert(exc && PyExceptionInstance_Check(exc));
  1227. if (PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) {
  1228. #line 1310 "Python/generated_cases.c.h"
  1229. Py_DECREF(awaitable);
  1230. Py_DECREF(exc);
  1231. #line 959 "Python/bytecodes.c"
  1232. }
  1233. else {
  1234. Py_INCREF(exc);
  1235. _PyErr_SetRaisedException(tstate, exc);
  1236. monitor_reraise(tstate, frame, next_instr-1);
  1237. goto exception_unwind;
  1238. }
  1239. #line 1321 "Python/generated_cases.c.h"
  1240. STACK_SHRINK(2);
  1241. DISPATCH();
  1242. }
  1243. TARGET(CLEANUP_THROW) {
  1244. PyObject *exc_value = stack_pointer[-1];
  1245. PyObject *last_sent_val = stack_pointer[-2];
  1246. PyObject *sub_iter = stack_pointer[-3];
  1247. PyObject *none;
  1248. PyObject *value;
  1249. #line 969 "Python/bytecodes.c"
  1250. assert(throwflag);
  1251. assert(exc_value && PyExceptionInstance_Check(exc_value));
  1252. if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) {
  1253. value = Py_NewRef(((PyStopIterationObject *)exc_value)->value);
  1254. #line 1337 "Python/generated_cases.c.h"
  1255. Py_DECREF(sub_iter);
  1256. Py_DECREF(last_sent_val);
  1257. Py_DECREF(exc_value);
  1258. #line 974 "Python/bytecodes.c"
  1259. none = Py_None;
  1260. }
  1261. else {
  1262. _PyErr_SetRaisedException(tstate, Py_NewRef(exc_value));
  1263. monitor_reraise(tstate, frame, next_instr-1);
  1264. goto exception_unwind;
  1265. }
  1266. #line 1349 "Python/generated_cases.c.h"
  1267. STACK_SHRINK(1);
  1268. stack_pointer[-1] = value;
  1269. stack_pointer[-2] = none;
  1270. DISPATCH();
  1271. }
  1272. TARGET(LOAD_ASSERTION_ERROR) {
  1273. PyObject *value;
  1274. #line 984 "Python/bytecodes.c"
  1275. value = Py_NewRef(PyExc_AssertionError);
  1276. #line 1360 "Python/generated_cases.c.h"
  1277. STACK_GROW(1);
  1278. stack_pointer[-1] = value;
  1279. DISPATCH();
  1280. }
  1281. TARGET(LOAD_BUILD_CLASS) {
  1282. PyObject *bc;
  1283. #line 988 "Python/bytecodes.c"
  1284. if (PyDict_CheckExact(BUILTINS())) {
  1285. bc = _PyDict_GetItemWithError(BUILTINS(),
  1286. &_Py_ID(__build_class__));
  1287. if (bc == NULL) {
  1288. if (!_PyErr_Occurred(tstate)) {
  1289. _PyErr_SetString(tstate, PyExc_NameError,
  1290. "__build_class__ not found");
  1291. }
  1292. if (true) goto error;
  1293. }
  1294. Py_INCREF(bc);
  1295. }
  1296. else {
  1297. bc = PyObject_GetItem(BUILTINS(), &_Py_ID(__build_class__));
  1298. if (bc == NULL) {
  1299. if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError))
  1300. _PyErr_SetString(tstate, PyExc_NameError,
  1301. "__build_class__ not found");
  1302. if (true) goto error;
  1303. }
  1304. }
  1305. #line 1390 "Python/generated_cases.c.h"
  1306. STACK_GROW(1);
  1307. stack_pointer[-1] = bc;
  1308. DISPATCH();
  1309. }
  1310. TARGET(STORE_NAME) {
  1311. PyObject *v = stack_pointer[-1];
  1312. #line 1013 "Python/bytecodes.c"
  1313. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1314. PyObject *ns = LOCALS();
  1315. int err;
  1316. if (ns == NULL) {
  1317. _PyErr_Format(tstate, PyExc_SystemError,
  1318. "no locals found when storing %R", name);
  1319. #line 1405 "Python/generated_cases.c.h"
  1320. Py_DECREF(v);
  1321. #line 1020 "Python/bytecodes.c"
  1322. if (true) goto pop_1_error;
  1323. }
  1324. if (PyDict_CheckExact(ns))
  1325. err = PyDict_SetItem(ns, name, v);
  1326. else
  1327. err = PyObject_SetItem(ns, name, v);
  1328. #line 1414 "Python/generated_cases.c.h"
  1329. Py_DECREF(v);
  1330. #line 1027 "Python/bytecodes.c"
  1331. if (err) goto pop_1_error;
  1332. #line 1418 "Python/generated_cases.c.h"
  1333. STACK_SHRINK(1);
  1334. DISPATCH();
  1335. }
  1336. TARGET(DELETE_NAME) {
  1337. #line 1031 "Python/bytecodes.c"
  1338. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1339. PyObject *ns = LOCALS();
  1340. int err;
  1341. if (ns == NULL) {
  1342. _PyErr_Format(tstate, PyExc_SystemError,
  1343. "no locals when deleting %R", name);
  1344. goto error;
  1345. }
  1346. err = PyObject_DelItem(ns, name);
  1347. // Can't use ERROR_IF here.
  1348. if (err != 0) {
  1349. format_exc_check_arg(tstate, PyExc_NameError,
  1350. NAME_ERROR_MSG,
  1351. name);
  1352. goto error;
  1353. }
  1354. #line 1441 "Python/generated_cases.c.h"
  1355. DISPATCH();
  1356. }
  1357. TARGET(UNPACK_SEQUENCE) {
  1358. PREDICTED(UNPACK_SEQUENCE);
  1359. static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size");
  1360. PyObject *seq = stack_pointer[-1];
  1361. #line 1057 "Python/bytecodes.c"
  1362. #if ENABLE_SPECIALIZATION
  1363. _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
  1364. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  1365. next_instr--;
  1366. _Py_Specialize_UnpackSequence(seq, next_instr, oparg);
  1367. DISPATCH_SAME_OPARG();
  1368. }
  1369. STAT_INC(UNPACK_SEQUENCE, deferred);
  1370. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  1371. #endif /* ENABLE_SPECIALIZATION */
  1372. PyObject **top = stack_pointer + oparg - 1;
  1373. int res = unpack_iterable(tstate, seq, oparg, -1, top);
  1374. #line 1462 "Python/generated_cases.c.h"
  1375. Py_DECREF(seq);
  1376. #line 1070 "Python/bytecodes.c"
  1377. if (res == 0) goto pop_1_error;
  1378. #line 1466 "Python/generated_cases.c.h"
  1379. STACK_SHRINK(1);
  1380. STACK_GROW(oparg);
  1381. next_instr += 1;
  1382. DISPATCH();
  1383. }
  1384. TARGET(UNPACK_SEQUENCE_TWO_TUPLE) {
  1385. PyObject *seq = stack_pointer[-1];
  1386. PyObject **values = stack_pointer - (1);
  1387. #line 1074 "Python/bytecodes.c"
  1388. DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE);
  1389. DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE);
  1390. assert(oparg == 2);
  1391. STAT_INC(UNPACK_SEQUENCE, hit);
  1392. values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1));
  1393. values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0));
  1394. #line 1483 "Python/generated_cases.c.h"
  1395. Py_DECREF(seq);
  1396. STACK_SHRINK(1);
  1397. STACK_GROW(oparg);
  1398. next_instr += 1;
  1399. DISPATCH();
  1400. }
  1401. TARGET(UNPACK_SEQUENCE_TUPLE) {
  1402. PyObject *seq = stack_pointer[-1];
  1403. PyObject **values = stack_pointer - (1);
  1404. #line 1084 "Python/bytecodes.c"
  1405. DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE);
  1406. DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE);
  1407. STAT_INC(UNPACK_SEQUENCE, hit);
  1408. PyObject **items = _PyTuple_ITEMS(seq);
  1409. for (int i = oparg; --i >= 0; ) {
  1410. *values++ = Py_NewRef(items[i]);
  1411. }
  1412. #line 1502 "Python/generated_cases.c.h"
  1413. Py_DECREF(seq);
  1414. STACK_SHRINK(1);
  1415. STACK_GROW(oparg);
  1416. next_instr += 1;
  1417. DISPATCH();
  1418. }
  1419. TARGET(UNPACK_SEQUENCE_LIST) {
  1420. PyObject *seq = stack_pointer[-1];
  1421. PyObject **values = stack_pointer - (1);
  1422. #line 1095 "Python/bytecodes.c"
  1423. DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE);
  1424. DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE);
  1425. STAT_INC(UNPACK_SEQUENCE, hit);
  1426. PyObject **items = _PyList_ITEMS(seq);
  1427. for (int i = oparg; --i >= 0; ) {
  1428. *values++ = Py_NewRef(items[i]);
  1429. }
  1430. #line 1521 "Python/generated_cases.c.h"
  1431. Py_DECREF(seq);
  1432. STACK_SHRINK(1);
  1433. STACK_GROW(oparg);
  1434. next_instr += 1;
  1435. DISPATCH();
  1436. }
  1437. TARGET(UNPACK_EX) {
  1438. PyObject *seq = stack_pointer[-1];
  1439. #line 1106 "Python/bytecodes.c"
  1440. int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8);
  1441. PyObject **top = stack_pointer + totalargs - 1;
  1442. int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top);
  1443. #line 1535 "Python/generated_cases.c.h"
  1444. Py_DECREF(seq);
  1445. #line 1110 "Python/bytecodes.c"
  1446. if (res == 0) goto pop_1_error;
  1447. #line 1539 "Python/generated_cases.c.h"
  1448. STACK_GROW((oparg & 0xFF) + (oparg >> 8));
  1449. DISPATCH();
  1450. }
  1451. TARGET(STORE_ATTR) {
  1452. PREDICTED(STORE_ATTR);
  1453. static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
  1454. PyObject *owner = stack_pointer[-1];
  1455. PyObject *v = stack_pointer[-2];
  1456. uint16_t counter = read_u16(&next_instr[0].cache);
  1457. #line 1121 "Python/bytecodes.c"
  1458. #if ENABLE_SPECIALIZATION
  1459. if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
  1460. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1461. next_instr--;
  1462. _Py_Specialize_StoreAttr(owner, next_instr, name);
  1463. DISPATCH_SAME_OPARG();
  1464. }
  1465. STAT_INC(STORE_ATTR, deferred);
  1466. _PyAttrCache *cache = (_PyAttrCache *)next_instr;
  1467. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  1468. #else
  1469. (void)counter; // Unused.
  1470. #endif /* ENABLE_SPECIALIZATION */
  1471. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1472. int err = PyObject_SetAttr(owner, name, v);
  1473. #line 1566 "Python/generated_cases.c.h"
  1474. Py_DECREF(v);
  1475. Py_DECREF(owner);
  1476. #line 1137 "Python/bytecodes.c"
  1477. if (err) goto pop_2_error;
  1478. #line 1571 "Python/generated_cases.c.h"
  1479. STACK_SHRINK(2);
  1480. next_instr += 4;
  1481. DISPATCH();
  1482. }
  1483. TARGET(DELETE_ATTR) {
  1484. PyObject *owner = stack_pointer[-1];
  1485. #line 1141 "Python/bytecodes.c"
  1486. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1487. int err = PyObject_SetAttr(owner, name, (PyObject *)NULL);
  1488. #line 1582 "Python/generated_cases.c.h"
  1489. Py_DECREF(owner);
  1490. #line 1144 "Python/bytecodes.c"
  1491. if (err) goto pop_1_error;
  1492. #line 1586 "Python/generated_cases.c.h"
  1493. STACK_SHRINK(1);
  1494. DISPATCH();
  1495. }
  1496. TARGET(STORE_GLOBAL) {
  1497. PyObject *v = stack_pointer[-1];
  1498. #line 1148 "Python/bytecodes.c"
  1499. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1500. int err = PyDict_SetItem(GLOBALS(), name, v);
  1501. #line 1596 "Python/generated_cases.c.h"
  1502. Py_DECREF(v);
  1503. #line 1151 "Python/bytecodes.c"
  1504. if (err) goto pop_1_error;
  1505. #line 1600 "Python/generated_cases.c.h"
  1506. STACK_SHRINK(1);
  1507. DISPATCH();
  1508. }
  1509. TARGET(DELETE_GLOBAL) {
  1510. #line 1155 "Python/bytecodes.c"
  1511. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1512. int err;
  1513. err = PyDict_DelItem(GLOBALS(), name);
  1514. // Can't use ERROR_IF here.
  1515. if (err != 0) {
  1516. if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1517. format_exc_check_arg(tstate, PyExc_NameError,
  1518. NAME_ERROR_MSG, name);
  1519. }
  1520. goto error;
  1521. }
  1522. #line 1618 "Python/generated_cases.c.h"
  1523. DISPATCH();
  1524. }
  1525. TARGET(LOAD_LOCALS) {
  1526. PyObject *locals;
  1527. #line 1169 "Python/bytecodes.c"
  1528. locals = LOCALS();
  1529. if (locals == NULL) {
  1530. _PyErr_SetString(tstate, PyExc_SystemError,
  1531. "no locals found");
  1532. if (true) goto error;
  1533. }
  1534. Py_INCREF(locals);
  1535. #line 1632 "Python/generated_cases.c.h"
  1536. STACK_GROW(1);
  1537. stack_pointer[-1] = locals;
  1538. DISPATCH();
  1539. }
  1540. TARGET(LOAD_FROM_DICT_OR_GLOBALS) {
  1541. PyObject *mod_or_class_dict = stack_pointer[-1];
  1542. PyObject *v;
  1543. #line 1179 "Python/bytecodes.c"
  1544. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1545. if (PyDict_CheckExact(mod_or_class_dict)) {
  1546. v = PyDict_GetItemWithError(mod_or_class_dict, name);
  1547. if (v != NULL) {
  1548. Py_INCREF(v);
  1549. }
  1550. else if (_PyErr_Occurred(tstate)) {
  1551. goto error;
  1552. }
  1553. }
  1554. else {
  1555. v = PyObject_GetItem(mod_or_class_dict, name);
  1556. if (v == NULL) {
  1557. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1558. goto error;
  1559. }
  1560. _PyErr_Clear(tstate);
  1561. }
  1562. }
  1563. if (v == NULL) {
  1564. if (PyDict_CheckExact(GLOBALS())
  1565. && PyDict_CheckExact(BUILTINS()))
  1566. {
  1567. v = _PyDict_LoadGlobal((PyDictObject *)GLOBALS(),
  1568. (PyDictObject *)BUILTINS(),
  1569. name);
  1570. if (v == NULL) {
  1571. if (!_PyErr_Occurred(tstate)) {
  1572. /* _PyDict_LoadGlobal() returns NULL without raising
  1573. * an exception if the key doesn't exist */
  1574. format_exc_check_arg(tstate, PyExc_NameError,
  1575. NAME_ERROR_MSG, name);
  1576. }
  1577. Py_DECREF(mod_or_class_dict);
  1578. if (true) goto pop_1_error;
  1579. }
  1580. Py_INCREF(v);
  1581. }
  1582. else {
  1583. /* Slow-path if globals or builtins is not a dict */
  1584. /* namespace 1: globals */
  1585. v = PyObject_GetItem(GLOBALS(), name);
  1586. if (v == NULL) {
  1587. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto pop_1_error;
  1588. _PyErr_Clear(tstate);
  1589. /* namespace 2: builtins */
  1590. v = PyObject_GetItem(BUILTINS(), name);
  1591. if (v == NULL) {
  1592. if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1593. format_exc_check_arg(
  1594. tstate, PyExc_NameError,
  1595. NAME_ERROR_MSG, name);
  1596. }
  1597. Py_DECREF(mod_or_class_dict);
  1598. if (true) goto pop_1_error;
  1599. }
  1600. }
  1601. }
  1602. }
  1603. #line 1703 "Python/generated_cases.c.h"
  1604. Py_DECREF(mod_or_class_dict);
  1605. stack_pointer[-1] = v;
  1606. DISPATCH();
  1607. }
  1608. TARGET(LOAD_NAME) {
  1609. PyObject *v;
  1610. #line 1244 "Python/bytecodes.c"
  1611. PyObject *mod_or_class_dict = LOCALS();
  1612. if (mod_or_class_dict == NULL) {
  1613. _PyErr_SetString(tstate, PyExc_SystemError,
  1614. "no locals found");
  1615. if (true) goto error;
  1616. }
  1617. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1618. if (PyDict_CheckExact(mod_or_class_dict)) {
  1619. v = PyDict_GetItemWithError(mod_or_class_dict, name);
  1620. if (v != NULL) {
  1621. Py_INCREF(v);
  1622. }
  1623. else if (_PyErr_Occurred(tstate)) {
  1624. goto error;
  1625. }
  1626. }
  1627. else {
  1628. v = PyObject_GetItem(mod_or_class_dict, name);
  1629. if (v == NULL) {
  1630. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1631. goto error;
  1632. }
  1633. _PyErr_Clear(tstate);
  1634. }
  1635. }
  1636. if (v == NULL) {
  1637. v = PyDict_GetItemWithError(GLOBALS(), name);
  1638. if (v != NULL) {
  1639. Py_INCREF(v);
  1640. }
  1641. else if (_PyErr_Occurred(tstate)) {
  1642. goto error;
  1643. }
  1644. else {
  1645. if (PyDict_CheckExact(BUILTINS())) {
  1646. v = PyDict_GetItemWithError(BUILTINS(), name);
  1647. if (v == NULL) {
  1648. if (!_PyErr_Occurred(tstate)) {
  1649. format_exc_check_arg(
  1650. tstate, PyExc_NameError,
  1651. NAME_ERROR_MSG, name);
  1652. }
  1653. goto error;
  1654. }
  1655. Py_INCREF(v);
  1656. }
  1657. else {
  1658. v = PyObject_GetItem(BUILTINS(), name);
  1659. if (v == NULL) {
  1660. if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1661. format_exc_check_arg(
  1662. tstate, PyExc_NameError,
  1663. NAME_ERROR_MSG, name);
  1664. }
  1665. goto error;
  1666. }
  1667. }
  1668. }
  1669. }
  1670. #line 1771 "Python/generated_cases.c.h"
  1671. STACK_GROW(1);
  1672. stack_pointer[-1] = v;
  1673. DISPATCH();
  1674. }
  1675. TARGET(LOAD_GLOBAL) {
  1676. PREDICTED(LOAD_GLOBAL);
  1677. static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
  1678. PyObject *null = NULL;
  1679. PyObject *v;
  1680. #line 1312 "Python/bytecodes.c"
  1681. #if ENABLE_SPECIALIZATION
  1682. _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
  1683. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  1684. PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
  1685. next_instr--;
  1686. _Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name);
  1687. DISPATCH_SAME_OPARG();
  1688. }
  1689. STAT_INC(LOAD_GLOBAL, deferred);
  1690. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  1691. #endif /* ENABLE_SPECIALIZATION */
  1692. PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
  1693. if (PyDict_CheckExact(GLOBALS())
  1694. && PyDict_CheckExact(BUILTINS()))
  1695. {
  1696. v = _PyDict_LoadGlobal((PyDictObject *)GLOBALS(),
  1697. (PyDictObject *)BUILTINS(),
  1698. name);
  1699. if (v == NULL) {
  1700. if (!_PyErr_Occurred(tstate)) {
  1701. /* _PyDict_LoadGlobal() returns NULL without raising
  1702. * an exception if the key doesn't exist */
  1703. format_exc_check_arg(tstate, PyExc_NameError,
  1704. NAME_ERROR_MSG, name);
  1705. }
  1706. if (true) goto error;
  1707. }
  1708. Py_INCREF(v);
  1709. }
  1710. else {
  1711. /* Slow-path if globals or builtins is not a dict */
  1712. /* namespace 1: globals */
  1713. v = PyObject_GetItem(GLOBALS(), name);
  1714. if (v == NULL) {
  1715. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error;
  1716. _PyErr_Clear(tstate);
  1717. /* namespace 2: builtins */
  1718. v = PyObject_GetItem(BUILTINS(), name);
  1719. if (v == NULL) {
  1720. if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1721. format_exc_check_arg(
  1722. tstate, PyExc_NameError,
  1723. NAME_ERROR_MSG, name);
  1724. }
  1725. if (true) goto error;
  1726. }
  1727. }
  1728. }
  1729. null = NULL;
  1730. #line 1834 "Python/generated_cases.c.h"
  1731. STACK_GROW(1);
  1732. STACK_GROW(((oparg & 1) ? 1 : 0));
  1733. stack_pointer[-1] = v;
  1734. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
  1735. next_instr += 4;
  1736. DISPATCH();
  1737. }
  1738. TARGET(LOAD_GLOBAL_MODULE) {
  1739. PyObject *null = NULL;
  1740. PyObject *res;
  1741. uint16_t index = read_u16(&next_instr[1].cache);
  1742. uint16_t version = read_u16(&next_instr[2].cache);
  1743. #line 1366 "Python/bytecodes.c"
  1744. DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
  1745. PyDictObject *dict = (PyDictObject *)GLOBALS();
  1746. DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL);
  1747. assert(DK_IS_UNICODE(dict->ma_keys));
  1748. PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(dict->ma_keys);
  1749. res = entries[index].me_value;
  1750. DEOPT_IF(res == NULL, LOAD_GLOBAL);
  1751. Py_INCREF(res);
  1752. STAT_INC(LOAD_GLOBAL, hit);
  1753. null = NULL;
  1754. #line 1859 "Python/generated_cases.c.h"
  1755. STACK_GROW(1);
  1756. STACK_GROW(((oparg & 1) ? 1 : 0));
  1757. stack_pointer[-1] = res;
  1758. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
  1759. next_instr += 4;
  1760. DISPATCH();
  1761. }
  1762. TARGET(LOAD_GLOBAL_BUILTIN) {
  1763. PyObject *null = NULL;
  1764. PyObject *res;
  1765. uint16_t index = read_u16(&next_instr[1].cache);
  1766. uint16_t mod_version = read_u16(&next_instr[2].cache);
  1767. uint16_t bltn_version = read_u16(&next_instr[3].cache);
  1768. #line 1379 "Python/bytecodes.c"
  1769. DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
  1770. DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL);
  1771. PyDictObject *mdict = (PyDictObject *)GLOBALS();
  1772. PyDictObject *bdict = (PyDictObject *)BUILTINS();
  1773. assert(opcode == LOAD_GLOBAL_BUILTIN);
  1774. DEOPT_IF(mdict->ma_keys->dk_version != mod_version, LOAD_GLOBAL);
  1775. DEOPT_IF(bdict->ma_keys->dk_version != bltn_version, LOAD_GLOBAL);
  1776. assert(DK_IS_UNICODE(bdict->ma_keys));
  1777. PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(bdict->ma_keys);
  1778. res = entries[index].me_value;
  1779. DEOPT_IF(res == NULL, LOAD_GLOBAL);
  1780. Py_INCREF(res);
  1781. STAT_INC(LOAD_GLOBAL, hit);
  1782. null = NULL;
  1783. #line 1889 "Python/generated_cases.c.h"
  1784. STACK_GROW(1);
  1785. STACK_GROW(((oparg & 1) ? 1 : 0));
  1786. stack_pointer[-1] = res;
  1787. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
  1788. next_instr += 4;
  1789. DISPATCH();
  1790. }
  1791. TARGET(DELETE_FAST) {
  1792. #line 1396 "Python/bytecodes.c"
  1793. PyObject *v = GETLOCAL(oparg);
  1794. if (v == NULL) goto unbound_local_error;
  1795. SETLOCAL(oparg, NULL);
  1796. #line 1903 "Python/generated_cases.c.h"
  1797. DISPATCH();
  1798. }
  1799. TARGET(MAKE_CELL) {
  1800. #line 1402 "Python/bytecodes.c"
  1801. // "initial" is probably NULL but not if it's an arg (or set
  1802. // via PyFrame_LocalsToFast() before MAKE_CELL has run).
  1803. PyObject *initial = GETLOCAL(oparg);
  1804. PyObject *cell = PyCell_New(initial);
  1805. if (cell == NULL) {
  1806. goto resume_with_error;
  1807. }
  1808. SETLOCAL(oparg, cell);
  1809. #line 1917 "Python/generated_cases.c.h"
  1810. DISPATCH();
  1811. }
  1812. TARGET(DELETE_DEREF) {
  1813. #line 1413 "Python/bytecodes.c"
  1814. PyObject *cell = GETLOCAL(oparg);
  1815. PyObject *oldobj = PyCell_GET(cell);
  1816. // Can't use ERROR_IF here.
  1817. // Fortunately we don't need its superpower.
  1818. if (oldobj == NULL) {
  1819. format_exc_unbound(tstate, frame->f_code, oparg);
  1820. goto error;
  1821. }
  1822. PyCell_SET(cell, NULL);
  1823. Py_DECREF(oldobj);
  1824. #line 1933 "Python/generated_cases.c.h"
  1825. DISPATCH();
  1826. }
  1827. TARGET(LOAD_FROM_DICT_OR_DEREF) {
  1828. PyObject *class_dict = stack_pointer[-1];
  1829. PyObject *value;
  1830. #line 1426 "Python/bytecodes.c"
  1831. PyObject *name;
  1832. assert(class_dict);
  1833. assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus);
  1834. name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg);
  1835. if (PyDict_CheckExact(class_dict)) {
  1836. value = PyDict_GetItemWithError(class_dict, name);
  1837. if (value != NULL) {
  1838. Py_INCREF(value);
  1839. }
  1840. else if (_PyErr_Occurred(tstate)) {
  1841. goto error;
  1842. }
  1843. }
  1844. else {
  1845. value = PyObject_GetItem(class_dict, name);
  1846. if (value == NULL) {
  1847. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1848. goto error;
  1849. }
  1850. _PyErr_Clear(tstate);
  1851. }
  1852. }
  1853. if (!value) {
  1854. PyObject *cell = GETLOCAL(oparg);
  1855. value = PyCell_GET(cell);
  1856. if (value == NULL) {
  1857. format_exc_unbound(tstate, frame->f_code, oparg);
  1858. goto error;
  1859. }
  1860. Py_INCREF(value);
  1861. }
  1862. Py_DECREF(class_dict);
  1863. #line 1973 "Python/generated_cases.c.h"
  1864. stack_pointer[-1] = value;
  1865. DISPATCH();
  1866. }
  1867. TARGET(LOAD_DEREF) {
  1868. PyObject *value;
  1869. #line 1461 "Python/bytecodes.c"
  1870. PyObject *cell = GETLOCAL(oparg);
  1871. value = PyCell_GET(cell);
  1872. if (value == NULL) {
  1873. format_exc_unbound(tstate, frame->f_code, oparg);
  1874. if (true) goto error;
  1875. }
  1876. Py_INCREF(value);
  1877. #line 1988 "Python/generated_cases.c.h"
  1878. STACK_GROW(1);
  1879. stack_pointer[-1] = value;
  1880. DISPATCH();
  1881. }
  1882. TARGET(STORE_DEREF) {
  1883. PyObject *v = stack_pointer[-1];
  1884. #line 1471 "Python/bytecodes.c"
  1885. PyObject *cell = GETLOCAL(oparg);
  1886. PyObject *oldobj = PyCell_GET(cell);
  1887. PyCell_SET(cell, v);
  1888. Py_XDECREF(oldobj);
  1889. #line 2001 "Python/generated_cases.c.h"
  1890. STACK_SHRINK(1);
  1891. DISPATCH();
  1892. }
  1893. TARGET(COPY_FREE_VARS) {
  1894. #line 1478 "Python/bytecodes.c"
  1895. /* Copy closure variables to free variables */
  1896. PyCodeObject *co = frame->f_code;
  1897. assert(PyFunction_Check(frame->f_funcobj));
  1898. PyObject *closure = ((PyFunctionObject *)frame->f_funcobj)->func_closure;
  1899. assert(oparg == co->co_nfreevars);
  1900. int offset = co->co_nlocalsplus - oparg;
  1901. for (int i = 0; i < oparg; ++i) {
  1902. PyObject *o = PyTuple_GET_ITEM(closure, i);
  1903. frame->localsplus[offset + i] = Py_NewRef(o);
  1904. }
  1905. #line 2018 "Python/generated_cases.c.h"
  1906. DISPATCH();
  1907. }
  1908. TARGET(BUILD_STRING) {
  1909. PyObject **pieces = (stack_pointer - oparg);
  1910. PyObject *str;
  1911. #line 1491 "Python/bytecodes.c"
  1912. str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg);
  1913. #line 2027 "Python/generated_cases.c.h"
  1914. for (int _i = oparg; --_i >= 0;) {
  1915. Py_DECREF(pieces[_i]);
  1916. }
  1917. #line 1493 "Python/bytecodes.c"
  1918. if (str == NULL) { STACK_SHRINK(oparg); goto error; }
  1919. #line 2033 "Python/generated_cases.c.h"
  1920. STACK_SHRINK(oparg);
  1921. STACK_GROW(1);
  1922. stack_pointer[-1] = str;
  1923. DISPATCH();
  1924. }
  1925. TARGET(BUILD_TUPLE) {
  1926. PyObject **values = (stack_pointer - oparg);
  1927. PyObject *tup;
  1928. #line 1497 "Python/bytecodes.c"
  1929. tup = _PyTuple_FromArraySteal(values, oparg);
  1930. if (tup == NULL) { STACK_SHRINK(oparg); goto error; }
  1931. #line 2046 "Python/generated_cases.c.h"
  1932. STACK_SHRINK(oparg);
  1933. STACK_GROW(1);
  1934. stack_pointer[-1] = tup;
  1935. DISPATCH();
  1936. }
  1937. TARGET(BUILD_LIST) {
  1938. PyObject **values = (stack_pointer - oparg);
  1939. PyObject *list;
  1940. #line 1502 "Python/bytecodes.c"
  1941. list = _PyList_FromArraySteal(values, oparg);
  1942. if (list == NULL) { STACK_SHRINK(oparg); goto error; }
  1943. #line 2059 "Python/generated_cases.c.h"
  1944. STACK_SHRINK(oparg);
  1945. STACK_GROW(1);
  1946. stack_pointer[-1] = list;
  1947. DISPATCH();
  1948. }
  1949. TARGET(LIST_EXTEND) {
  1950. PyObject *iterable = stack_pointer[-1];
  1951. PyObject *list = stack_pointer[-(2 + (oparg-1))];
  1952. #line 1507 "Python/bytecodes.c"
  1953. PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable);
  1954. if (none_val == NULL) {
  1955. if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) &&
  1956. (Py_TYPE(iterable)->tp_iter == NULL && !PySequence_Check(iterable)))
  1957. {
  1958. _PyErr_Clear(tstate);
  1959. _PyErr_Format(tstate, PyExc_TypeError,
  1960. "Value after * must be an iterable, not %.200s",
  1961. Py_TYPE(iterable)->tp_name);
  1962. }
  1963. #line 2080 "Python/generated_cases.c.h"
  1964. Py_DECREF(iterable);
  1965. #line 1518 "Python/bytecodes.c"
  1966. if (true) goto pop_1_error;
  1967. }
  1968. assert(Py_IsNone(none_val));
  1969. #line 2086 "Python/generated_cases.c.h"
  1970. Py_DECREF(iterable);
  1971. STACK_SHRINK(1);
  1972. DISPATCH();
  1973. }
  1974. TARGET(SET_UPDATE) {
  1975. PyObject *iterable = stack_pointer[-1];
  1976. PyObject *set = stack_pointer[-(2 + (oparg-1))];
  1977. #line 1525 "Python/bytecodes.c"
  1978. int err = _PySet_Update(set, iterable);
  1979. #line 2097 "Python/generated_cases.c.h"
  1980. Py_DECREF(iterable);
  1981. #line 1527 "Python/bytecodes.c"
  1982. if (err < 0) goto pop_1_error;
  1983. #line 2101 "Python/generated_cases.c.h"
  1984. STACK_SHRINK(1);
  1985. DISPATCH();
  1986. }
  1987. TARGET(BUILD_SET) {
  1988. PyObject **values = (stack_pointer - oparg);
  1989. PyObject *set;
  1990. #line 1531 "Python/bytecodes.c"
  1991. set = PySet_New(NULL);
  1992. if (set == NULL)
  1993. goto error;
  1994. int err = 0;
  1995. for (int i = 0; i < oparg; i++) {
  1996. PyObject *item = values[i];
  1997. if (err == 0)
  1998. err = PySet_Add(set, item);
  1999. Py_DECREF(item);
  2000. }
  2001. if (err != 0) {
  2002. Py_DECREF(set);
  2003. if (true) { STACK_SHRINK(oparg); goto error; }
  2004. }
  2005. #line 2124 "Python/generated_cases.c.h"
  2006. STACK_SHRINK(oparg);
  2007. STACK_GROW(1);
  2008. stack_pointer[-1] = set;
  2009. DISPATCH();
  2010. }
  2011. TARGET(BUILD_MAP) {
  2012. PyObject **values = (stack_pointer - oparg*2);
  2013. PyObject *map;
  2014. #line 1548 "Python/bytecodes.c"
  2015. map = _PyDict_FromItems(
  2016. values, 2,
  2017. values+1, 2,
  2018. oparg);
  2019. #line 2139 "Python/generated_cases.c.h"
  2020. for (int _i = oparg*2; --_i >= 0;) {
  2021. Py_DECREF(values[_i]);
  2022. }
  2023. #line 1553 "Python/bytecodes.c"
  2024. if (map == NULL) { STACK_SHRINK(oparg*2); goto error; }
  2025. #line 2145 "Python/generated_cases.c.h"
  2026. STACK_SHRINK(oparg*2);
  2027. STACK_GROW(1);
  2028. stack_pointer[-1] = map;
  2029. DISPATCH();
  2030. }
  2031. TARGET(SETUP_ANNOTATIONS) {
  2032. #line 1557 "Python/bytecodes.c"
  2033. int err;
  2034. PyObject *ann_dict;
  2035. if (LOCALS() == NULL) {
  2036. _PyErr_Format(tstate, PyExc_SystemError,
  2037. "no locals found when setting up annotations");
  2038. if (true) goto error;
  2039. }
  2040. /* check if __annotations__ in locals()... */
  2041. if (PyDict_CheckExact(LOCALS())) {
  2042. ann_dict = _PyDict_GetItemWithError(LOCALS(),
  2043. &_Py_ID(__annotations__));
  2044. if (ann_dict == NULL) {
  2045. if (_PyErr_Occurred(tstate)) goto error;
  2046. /* ...if not, create a new one */
  2047. ann_dict = PyDict_New();
  2048. if (ann_dict == NULL) goto error;
  2049. err = PyDict_SetItem(LOCALS(), &_Py_ID(__annotations__),
  2050. ann_dict);
  2051. Py_DECREF(ann_dict);
  2052. if (err) goto error;
  2053. }
  2054. }
  2055. else {
  2056. /* do the same if locals() is not a dict */
  2057. ann_dict = PyObject_GetItem(LOCALS(), &_Py_ID(__annotations__));
  2058. if (ann_dict == NULL) {
  2059. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error;
  2060. _PyErr_Clear(tstate);
  2061. ann_dict = PyDict_New();
  2062. if (ann_dict == NULL) goto error;
  2063. err = PyObject_SetItem(LOCALS(), &_Py_ID(__annotations__),
  2064. ann_dict);
  2065. Py_DECREF(ann_dict);
  2066. if (err) goto error;
  2067. }
  2068. else {
  2069. Py_DECREF(ann_dict);
  2070. }
  2071. }
  2072. #line 2193 "Python/generated_cases.c.h"
  2073. DISPATCH();
  2074. }
  2075. TARGET(BUILD_CONST_KEY_MAP) {
  2076. PyObject *keys = stack_pointer[-1];
  2077. PyObject **values = (stack_pointer - (1 + oparg));
  2078. PyObject *map;
  2079. #line 1599 "Python/bytecodes.c"
  2080. if (!PyTuple_CheckExact(keys) ||
  2081. PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) {
  2082. _PyErr_SetString(tstate, PyExc_SystemError,
  2083. "bad BUILD_CONST_KEY_MAP keys argument");
  2084. goto error; // Pop the keys and values.
  2085. }
  2086. map = _PyDict_FromItems(
  2087. &PyTuple_GET_ITEM(keys, 0), 1,
  2088. values, 1, oparg);
  2089. #line 2211 "Python/generated_cases.c.h"
  2090. for (int _i = oparg; --_i >= 0;) {
  2091. Py_DECREF(values[_i]);
  2092. }
  2093. Py_DECREF(keys);
  2094. #line 1609 "Python/bytecodes.c"
  2095. if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; }
  2096. #line 2218 "Python/generated_cases.c.h"
  2097. STACK_SHRINK(oparg);
  2098. stack_pointer[-1] = map;
  2099. DISPATCH();
  2100. }
  2101. TARGET(DICT_UPDATE) {
  2102. PyObject *update = stack_pointer[-1];
  2103. #line 1613 "Python/bytecodes.c"
  2104. PyObject *dict = PEEK(oparg + 1); // update is still on the stack
  2105. if (PyDict_Update(dict, update) < 0) {
  2106. if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) {
  2107. _PyErr_Format(tstate, PyExc_TypeError,
  2108. "'%.200s' object is not a mapping",
  2109. Py_TYPE(update)->tp_name);
  2110. }
  2111. #line 2234 "Python/generated_cases.c.h"
  2112. Py_DECREF(update);
  2113. #line 1621 "Python/bytecodes.c"
  2114. if (true) goto pop_1_error;
  2115. }
  2116. #line 2239 "Python/generated_cases.c.h"
  2117. Py_DECREF(update);
  2118. STACK_SHRINK(1);
  2119. DISPATCH();
  2120. }
  2121. TARGET(DICT_MERGE) {
  2122. PyObject *update = stack_pointer[-1];
  2123. #line 1627 "Python/bytecodes.c"
  2124. PyObject *dict = PEEK(oparg + 1); // update is still on the stack
  2125. if (_PyDict_MergeEx(dict, update, 2) < 0) {
  2126. format_kwargs_error(tstate, PEEK(3 + oparg), update);
  2127. #line 2252 "Python/generated_cases.c.h"
  2128. Py_DECREF(update);
  2129. #line 1632 "Python/bytecodes.c"
  2130. if (true) goto pop_1_error;
  2131. }
  2132. #line 2257 "Python/generated_cases.c.h"
  2133. Py_DECREF(update);
  2134. STACK_SHRINK(1);
  2135. PREDICT(CALL_FUNCTION_EX);
  2136. DISPATCH();
  2137. }
  2138. TARGET(MAP_ADD) {
  2139. PyObject *value = stack_pointer[-1];
  2140. PyObject *key = stack_pointer[-2];
  2141. #line 1639 "Python/bytecodes.c"
  2142. PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack
  2143. assert(PyDict_CheckExact(dict));
  2144. /* dict[key] = value */
  2145. // Do not DECREF INPUTS because the function steals the references
  2146. if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error;
  2147. #line 2273 "Python/generated_cases.c.h"
  2148. STACK_SHRINK(2);
  2149. PREDICT(JUMP_BACKWARD);
  2150. DISPATCH();
  2151. }
  2152. TARGET(INSTRUMENTED_LOAD_SUPER_ATTR) {
  2153. #line 1648 "Python/bytecodes.c"
  2154. _PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
  2155. // cancel out the decrement that will happen in LOAD_SUPER_ATTR; we
  2156. // don't want to specialize instrumented instructions
  2157. INCREMENT_ADAPTIVE_COUNTER(cache->counter);
  2158. GO_TO_INSTRUCTION(LOAD_SUPER_ATTR);
  2159. #line 2286 "Python/generated_cases.c.h"
  2160. }
  2161. TARGET(LOAD_SUPER_ATTR) {
  2162. PREDICTED(LOAD_SUPER_ATTR);
  2163. static_assert(INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR == 1, "incorrect cache size");
  2164. PyObject *self = stack_pointer[-1];
  2165. PyObject *class = stack_pointer[-2];
  2166. PyObject *global_super = stack_pointer[-3];
  2167. PyObject *res2 = NULL;
  2168. PyObject *res;
  2169. #line 1662 "Python/bytecodes.c"
  2170. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
  2171. int load_method = oparg & 1;
  2172. #if ENABLE_SPECIALIZATION
  2173. _PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
  2174. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  2175. next_instr--;
  2176. _Py_Specialize_LoadSuperAttr(global_super, class, next_instr, load_method);
  2177. DISPATCH_SAME_OPARG();
  2178. }
  2179. STAT_INC(LOAD_SUPER_ATTR, deferred);
  2180. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  2181. #endif /* ENABLE_SPECIALIZATION */
  2182. if (opcode == INSTRUMENTED_LOAD_SUPER_ATTR) {
  2183. PyObject *arg = oparg & 2 ? class : &_PyInstrumentation_MISSING;
  2184. int err = _Py_call_instrumentation_2args(
  2185. tstate, PY_MONITORING_EVENT_CALL,
  2186. frame, next_instr-1, global_super, arg);
  2187. if (err) goto pop_3_error;
  2188. }
  2189. // we make no attempt to optimize here; specializations should
  2190. // handle any case whose performance we care about
  2191. PyObject *stack[] = {class, self};
  2192. PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL);
  2193. if (opcode == INSTRUMENTED_LOAD_SUPER_ATTR) {
  2194. PyObject *arg = oparg & 2 ? class : &_PyInstrumentation_MISSING;
  2195. if (super == NULL) {
  2196. _Py_call_instrumentation_exc2(
  2197. tstate, PY_MONITORING_EVENT_C_RAISE,
  2198. frame, next_instr-1, global_super, arg);
  2199. }
  2200. else {
  2201. int err = _Py_call_instrumentation_2args(
  2202. tstate, PY_MONITORING_EVENT_C_RETURN,
  2203. frame, next_instr-1, global_super, arg);
  2204. if (err < 0) {
  2205. Py_CLEAR(super);
  2206. }
  2207. }
  2208. }
  2209. #line 2339 "Python/generated_cases.c.h"
  2210. Py_DECREF(global_super);
  2211. Py_DECREF(class);
  2212. Py_DECREF(self);
  2213. #line 1704 "Python/bytecodes.c"
  2214. if (super == NULL) goto pop_3_error;
  2215. res = PyObject_GetAttr(super, name);
  2216. Py_DECREF(super);
  2217. if (res == NULL) goto pop_3_error;
  2218. #line 2348 "Python/generated_cases.c.h"
  2219. STACK_SHRINK(2);
  2220. STACK_GROW(((oparg & 1) ? 1 : 0));
  2221. stack_pointer[-1] = res;
  2222. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2223. next_instr += 1;
  2224. DISPATCH();
  2225. }
  2226. TARGET(LOAD_SUPER_ATTR_ATTR) {
  2227. PyObject *self = stack_pointer[-1];
  2228. PyObject *class = stack_pointer[-2];
  2229. PyObject *global_super = stack_pointer[-3];
  2230. PyObject *res2 = NULL;
  2231. PyObject *res;
  2232. #line 1711 "Python/bytecodes.c"
  2233. assert(!(oparg & 1));
  2234. DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR);
  2235. DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR);
  2236. STAT_INC(LOAD_SUPER_ATTR, hit);
  2237. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
  2238. res = _PySuper_Lookup((PyTypeObject *)class, self, name, NULL);
  2239. #line 2370 "Python/generated_cases.c.h"
  2240. Py_DECREF(global_super);
  2241. Py_DECREF(class);
  2242. Py_DECREF(self);
  2243. #line 1718 "Python/bytecodes.c"
  2244. if (res == NULL) goto pop_3_error;
  2245. #line 2376 "Python/generated_cases.c.h"
  2246. STACK_SHRINK(2);
  2247. STACK_GROW(((oparg & 1) ? 1 : 0));
  2248. stack_pointer[-1] = res;
  2249. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2250. next_instr += 1;
  2251. DISPATCH();
  2252. }
  2253. TARGET(LOAD_SUPER_ATTR_METHOD) {
  2254. PyObject *self = stack_pointer[-1];
  2255. PyObject *class = stack_pointer[-2];
  2256. PyObject *global_super = stack_pointer[-3];
  2257. PyObject *res2;
  2258. PyObject *res;
  2259. #line 1722 "Python/bytecodes.c"
  2260. assert(oparg & 1);
  2261. DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR);
  2262. DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR);
  2263. STAT_INC(LOAD_SUPER_ATTR, hit);
  2264. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
  2265. PyTypeObject *cls = (PyTypeObject *)class;
  2266. int method_found = 0;
  2267. res2 = _PySuper_Lookup(cls, self, name,
  2268. Py_TYPE(self)->tp_getattro == PyObject_GenericGetAttr ? &method_found : NULL);
  2269. Py_DECREF(global_super);
  2270. Py_DECREF(class);
  2271. if (res2 == NULL) {
  2272. Py_DECREF(self);
  2273. if (true) goto pop_3_error;
  2274. }
  2275. if (method_found) {
  2276. res = self; // transfer ownership
  2277. } else {
  2278. Py_DECREF(self);
  2279. res = res2;
  2280. res2 = NULL;
  2281. }
  2282. #line 2414 "Python/generated_cases.c.h"
  2283. STACK_SHRINK(1);
  2284. stack_pointer[-1] = res;
  2285. stack_pointer[-2] = res2;
  2286. next_instr += 1;
  2287. DISPATCH();
  2288. }
  2289. TARGET(LOAD_ATTR) {
  2290. PREDICTED(LOAD_ATTR);
  2291. static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
  2292. PyObject *owner = stack_pointer[-1];
  2293. PyObject *res2 = NULL;
  2294. PyObject *res;
  2295. #line 1761 "Python/bytecodes.c"
  2296. #if ENABLE_SPECIALIZATION
  2297. _PyAttrCache *cache = (_PyAttrCache *)next_instr;
  2298. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  2299. PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
  2300. next_instr--;
  2301. _Py_Specialize_LoadAttr(owner, next_instr, name);
  2302. DISPATCH_SAME_OPARG();
  2303. }
  2304. STAT_INC(LOAD_ATTR, deferred);
  2305. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  2306. #endif /* ENABLE_SPECIALIZATION */
  2307. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 1);
  2308. if (oparg & 1) {
  2309. /* Designed to work in tandem with CALL, pushes two values. */
  2310. PyObject* meth = NULL;
  2311. if (_PyObject_GetMethod(owner, name, &meth)) {
  2312. /* We can bypass temporary bound method object.
  2313. meth is unbound method and obj is self.
  2314. meth | self | arg1 | ... | argN
  2315. */
  2316. assert(meth != NULL); // No errors on this branch
  2317. res2 = meth;
  2318. res = owner; // Transfer ownership
  2319. }
  2320. else {
  2321. /* meth is not an unbound method (but a regular attr, or
  2322. something was returned by a descriptor protocol). Set
  2323. the second element of the stack to NULL, to signal
  2324. CALL that it's not a method call.
  2325. NULL | meth | arg1 | ... | argN
  2326. */
  2327. #line 2462 "Python/generated_cases.c.h"
  2328. Py_DECREF(owner);
  2329. #line 1795 "Python/bytecodes.c"
  2330. if (meth == NULL) goto pop_1_error;
  2331. res2 = NULL;
  2332. res = meth;
  2333. }
  2334. }
  2335. else {
  2336. /* Classic, pushes one value. */
  2337. res = PyObject_GetAttr(owner, name);
  2338. #line 2473 "Python/generated_cases.c.h"
  2339. Py_DECREF(owner);
  2340. #line 1804 "Python/bytecodes.c"
  2341. if (res == NULL) goto pop_1_error;
  2342. }
  2343. #line 2478 "Python/generated_cases.c.h"
  2344. STACK_GROW(((oparg & 1) ? 1 : 0));
  2345. stack_pointer[-1] = res;
  2346. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2347. next_instr += 9;
  2348. DISPATCH();
  2349. }
  2350. TARGET(LOAD_ATTR_INSTANCE_VALUE) {
  2351. PyObject *owner = stack_pointer[-1];
  2352. PyObject *res2 = NULL;
  2353. PyObject *res;
  2354. uint32_t type_version = read_u32(&next_instr[1].cache);
  2355. uint16_t index = read_u16(&next_instr[3].cache);
  2356. #line 1809 "Python/bytecodes.c"
  2357. PyTypeObject *tp = Py_TYPE(owner);
  2358. assert(type_version != 0);
  2359. DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
  2360. assert(tp->tp_dictoffset < 0);
  2361. assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  2362. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
  2363. DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
  2364. res = _PyDictOrValues_GetValues(dorv)->values[index];
  2365. DEOPT_IF(res == NULL, LOAD_ATTR);
  2366. STAT_INC(LOAD_ATTR, hit);
  2367. Py_INCREF(res);
  2368. res2 = NULL;
  2369. #line 2505 "Python/generated_cases.c.h"
  2370. Py_DECREF(owner);
  2371. STACK_GROW(((oparg & 1) ? 1 : 0));
  2372. stack_pointer[-1] = res;
  2373. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2374. next_instr += 9;
  2375. DISPATCH();
  2376. }
  2377. TARGET(LOAD_ATTR_MODULE) {
  2378. PyObject *owner = stack_pointer[-1];
  2379. PyObject *res2 = NULL;
  2380. PyObject *res;
  2381. uint32_t type_version = read_u32(&next_instr[1].cache);
  2382. uint16_t index = read_u16(&next_instr[3].cache);
  2383. #line 1825 "Python/bytecodes.c"
  2384. DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR);
  2385. PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict;
  2386. assert(dict != NULL);
  2387. DEOPT_IF(dict->ma_keys->dk_version != type_version, LOAD_ATTR);
  2388. assert(dict->ma_keys->dk_kind == DICT_KEYS_UNICODE);
  2389. assert(index < dict->ma_keys->dk_nentries);
  2390. PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + index;
  2391. res = ep->me_value;
  2392. DEOPT_IF(res == NULL, LOAD_ATTR);
  2393. STAT_INC(LOAD_ATTR, hit);
  2394. Py_INCREF(res);
  2395. res2 = NULL;
  2396. #line 2533 "Python/generated_cases.c.h"
  2397. Py_DECREF(owner);
  2398. STACK_GROW(((oparg & 1) ? 1 : 0));
  2399. stack_pointer[-1] = res;
  2400. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2401. next_instr += 9;
  2402. DISPATCH();
  2403. }
  2404. TARGET(LOAD_ATTR_WITH_HINT) {
  2405. PyObject *owner = stack_pointer[-1];
  2406. PyObject *res2 = NULL;
  2407. PyObject *res;
  2408. uint32_t type_version = read_u32(&next_instr[1].cache);
  2409. uint16_t index = read_u16(&next_instr[3].cache);
  2410. #line 1841 "Python/bytecodes.c"
  2411. PyTypeObject *tp = Py_TYPE(owner);
  2412. assert(type_version != 0);
  2413. DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
  2414. assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  2415. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
  2416. DEOPT_IF(_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
  2417. PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
  2418. DEOPT_IF(dict == NULL, LOAD_ATTR);
  2419. assert(PyDict_CheckExact((PyObject *)dict));
  2420. PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
  2421. uint16_t hint = index;
  2422. DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, LOAD_ATTR);
  2423. if (DK_IS_UNICODE(dict->ma_keys)) {
  2424. PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + hint;
  2425. DEOPT_IF(ep->me_key != name, LOAD_ATTR);
  2426. res = ep->me_value;
  2427. }
  2428. else {
  2429. PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + hint;
  2430. DEOPT_IF(ep->me_key != name, LOAD_ATTR);
  2431. res = ep->me_value;
  2432. }
  2433. DEOPT_IF(res == NULL, LOAD_ATTR);
  2434. STAT_INC(LOAD_ATTR, hit);
  2435. Py_INCREF(res);
  2436. res2 = NULL;
  2437. #line 2575 "Python/generated_cases.c.h"
  2438. Py_DECREF(owner);
  2439. STACK_GROW(((oparg & 1) ? 1 : 0));
  2440. stack_pointer[-1] = res;
  2441. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2442. next_instr += 9;
  2443. DISPATCH();
  2444. }
  2445. TARGET(LOAD_ATTR_SLOT) {
  2446. PyObject *owner = stack_pointer[-1];
  2447. PyObject *res2 = NULL;
  2448. PyObject *res;
  2449. uint32_t type_version = read_u32(&next_instr[1].cache);
  2450. uint16_t index = read_u16(&next_instr[3].cache);
  2451. #line 1871 "Python/bytecodes.c"
  2452. PyTypeObject *tp = Py_TYPE(owner);
  2453. assert(type_version != 0);
  2454. DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
  2455. char *addr = (char *)owner + index;
  2456. res = *(PyObject **)addr;
  2457. DEOPT_IF(res == NULL, LOAD_ATTR);
  2458. STAT_INC(LOAD_ATTR, hit);
  2459. Py_INCREF(res);
  2460. res2 = NULL;
  2461. #line 2600 "Python/generated_cases.c.h"
  2462. Py_DECREF(owner);
  2463. STACK_GROW(((oparg & 1) ? 1 : 0));
  2464. stack_pointer[-1] = res;
  2465. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2466. next_instr += 9;
  2467. DISPATCH();
  2468. }
  2469. TARGET(LOAD_ATTR_CLASS) {
  2470. PyObject *cls = stack_pointer[-1];
  2471. PyObject *res2 = NULL;
  2472. PyObject *res;
  2473. uint32_t type_version = read_u32(&next_instr[1].cache);
  2474. PyObject *descr = read_obj(&next_instr[5].cache);
  2475. #line 1884 "Python/bytecodes.c"
  2476. DEOPT_IF(!PyType_Check(cls), LOAD_ATTR);
  2477. DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version,
  2478. LOAD_ATTR);
  2479. assert(type_version != 0);
  2480. STAT_INC(LOAD_ATTR, hit);
  2481. res2 = NULL;
  2482. res = descr;
  2483. assert(res != NULL);
  2484. Py_INCREF(res);
  2485. #line 2627 "Python/generated_cases.c.h"
  2486. Py_DECREF(cls);
  2487. STACK_GROW(((oparg & 1) ? 1 : 0));
  2488. stack_pointer[-1] = res;
  2489. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2490. next_instr += 9;
  2491. DISPATCH();
  2492. }
  2493. TARGET(LOAD_ATTR_PROPERTY) {
  2494. PyObject *owner = stack_pointer[-1];
  2495. uint32_t type_version = read_u32(&next_instr[1].cache);
  2496. uint32_t func_version = read_u32(&next_instr[3].cache);
  2497. PyObject *fget = read_obj(&next_instr[5].cache);
  2498. #line 1899 "Python/bytecodes.c"
  2499. DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
  2500. PyTypeObject *cls = Py_TYPE(owner);
  2501. DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
  2502. assert(type_version != 0);
  2503. assert(Py_IS_TYPE(fget, &PyFunction_Type));
  2504. PyFunctionObject *f = (PyFunctionObject *)fget;
  2505. assert(func_version != 0);
  2506. DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
  2507. PyCodeObject *code = (PyCodeObject *)f->func_code;
  2508. assert(code->co_argcount == 1);
  2509. DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
  2510. STAT_INC(LOAD_ATTR, hit);
  2511. Py_INCREF(fget);
  2512. _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 1);
  2513. // Manipulate stack directly because we exit with DISPATCH_INLINED().
  2514. SET_TOP(NULL);
  2515. int shrink_stack = !(oparg & 1);
  2516. STACK_SHRINK(shrink_stack);
  2517. new_frame->localsplus[0] = owner;
  2518. JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR);
  2519. frame->return_offset = 0;
  2520. DISPATCH_INLINED(new_frame);
  2521. #line 2665 "Python/generated_cases.c.h"
  2522. }
  2523. TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) {
  2524. PyObject *owner = stack_pointer[-1];
  2525. uint32_t type_version = read_u32(&next_instr[1].cache);
  2526. uint32_t func_version = read_u32(&next_instr[3].cache);
  2527. PyObject *getattribute = read_obj(&next_instr[5].cache);
  2528. #line 1925 "Python/bytecodes.c"
  2529. DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
  2530. PyTypeObject *cls = Py_TYPE(owner);
  2531. DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
  2532. assert(type_version != 0);
  2533. assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
  2534. PyFunctionObject *f = (PyFunctionObject *)getattribute;
  2535. assert(func_version != 0);
  2536. DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
  2537. PyCodeObject *code = (PyCodeObject *)f->func_code;
  2538. assert(code->co_argcount == 2);
  2539. DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
  2540. STAT_INC(LOAD_ATTR, hit);
  2541. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 1);
  2542. Py_INCREF(f);
  2543. _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 2);
  2544. // Manipulate stack directly because we exit with DISPATCH_INLINED().
  2545. SET_TOP(NULL);
  2546. int shrink_stack = !(oparg & 1);
  2547. STACK_SHRINK(shrink_stack);
  2548. new_frame->localsplus[0] = owner;
  2549. new_frame->localsplus[1] = Py_NewRef(name);
  2550. JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR);
  2551. frame->return_offset = 0;
  2552. DISPATCH_INLINED(new_frame);
  2553. #line 2699 "Python/generated_cases.c.h"
  2554. }
  2555. TARGET(STORE_ATTR_INSTANCE_VALUE) {
  2556. PyObject *owner = stack_pointer[-1];
  2557. PyObject *value = stack_pointer[-2];
  2558. uint32_t type_version = read_u32(&next_instr[1].cache);
  2559. uint16_t index = read_u16(&next_instr[3].cache);
  2560. #line 1953 "Python/bytecodes.c"
  2561. PyTypeObject *tp = Py_TYPE(owner);
  2562. assert(type_version != 0);
  2563. DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
  2564. assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  2565. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
  2566. DEOPT_IF(!_PyDictOrValues_IsValues(dorv), STORE_ATTR);
  2567. STAT_INC(STORE_ATTR, hit);
  2568. PyDictValues *values = _PyDictOrValues_GetValues(dorv);
  2569. PyObject *old_value = values->values[index];
  2570. values->values[index] = value;
  2571. if (old_value == NULL) {
  2572. _PyDictValues_AddToInsertionOrder(values, index);
  2573. }
  2574. else {
  2575. Py_DECREF(old_value);
  2576. }
  2577. Py_DECREF(owner);
  2578. #line 2725 "Python/generated_cases.c.h"
  2579. STACK_SHRINK(2);
  2580. next_instr += 4;
  2581. DISPATCH();
  2582. }
  2583. TARGET(STORE_ATTR_WITH_HINT) {
  2584. PyObject *owner = stack_pointer[-1];
  2585. PyObject *value = stack_pointer[-2];
  2586. uint32_t type_version = read_u32(&next_instr[1].cache);
  2587. uint16_t hint = read_u16(&next_instr[3].cache);
  2588. #line 1973 "Python/bytecodes.c"
  2589. PyTypeObject *tp = Py_TYPE(owner);
  2590. assert(type_version != 0);
  2591. DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
  2592. assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  2593. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
  2594. DEOPT_IF(_PyDictOrValues_IsValues(dorv), STORE_ATTR);
  2595. PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
  2596. DEOPT_IF(dict == NULL, STORE_ATTR);
  2597. assert(PyDict_CheckExact((PyObject *)dict));
  2598. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  2599. DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, STORE_ATTR);
  2600. PyObject *old_value;
  2601. uint64_t new_version;
  2602. if (DK_IS_UNICODE(dict->ma_keys)) {
  2603. PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + hint;
  2604. DEOPT_IF(ep->me_key != name, STORE_ATTR);
  2605. old_value = ep->me_value;
  2606. DEOPT_IF(old_value == NULL, STORE_ATTR);
  2607. new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value);
  2608. ep->me_value = value;
  2609. }
  2610. else {
  2611. PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + hint;
  2612. DEOPT_IF(ep->me_key != name, STORE_ATTR);
  2613. old_value = ep->me_value;
  2614. DEOPT_IF(old_value == NULL, STORE_ATTR);
  2615. new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value);
  2616. ep->me_value = value;
  2617. }
  2618. /* Ensure dict is GC tracked if it needs to be */
  2619. if (!_PyObject_GC_IS_TRACKED(dict) && _PyObject_GC_MAY_BE_TRACKED(value)) {
  2620. _PyObject_GC_TRACK(dict);
  2621. }
  2622. dict->ma_version_tag = new_version; // PEP 509
  2623. // old_value should be DECREFed after GC track checking is done, if not, it could raise a segmentation fault,
  2624. // when dict only holds the strong reference to value in ep->me_value.
  2625. Py_DECREF(old_value);
  2626. STAT_INC(STORE_ATTR, hit);
  2627. Py_DECREF(owner);
  2628. #line 2776 "Python/generated_cases.c.h"
  2629. STACK_SHRINK(2);
  2630. next_instr += 4;
  2631. DISPATCH();
  2632. }
  2633. TARGET(STORE_ATTR_SLOT) {
  2634. PyObject *owner = stack_pointer[-1];
  2635. PyObject *value = stack_pointer[-2];
  2636. uint32_t type_version = read_u32(&next_instr[1].cache);
  2637. uint16_t index = read_u16(&next_instr[3].cache);
  2638. #line 2015 "Python/bytecodes.c"
  2639. PyTypeObject *tp = Py_TYPE(owner);
  2640. assert(type_version != 0);
  2641. DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
  2642. char *addr = (char *)owner + index;
  2643. STAT_INC(STORE_ATTR, hit);
  2644. PyObject *old_value = *(PyObject **)addr;
  2645. *(PyObject **)addr = value;
  2646. Py_XDECREF(old_value);
  2647. Py_DECREF(owner);
  2648. #line 2797 "Python/generated_cases.c.h"
  2649. STACK_SHRINK(2);
  2650. next_instr += 4;
  2651. DISPATCH();
  2652. }
  2653. TARGET(COMPARE_OP) {
  2654. PREDICTED(COMPARE_OP);
  2655. static_assert(INLINE_CACHE_ENTRIES_COMPARE_OP == 1, "incorrect cache size");
  2656. PyObject *right = stack_pointer[-1];
  2657. PyObject *left = stack_pointer[-2];
  2658. PyObject *res;
  2659. #line 2034 "Python/bytecodes.c"
  2660. #if ENABLE_SPECIALIZATION
  2661. _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
  2662. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  2663. next_instr--;
  2664. _Py_Specialize_CompareOp(left, right, next_instr, oparg);
  2665. DISPATCH_SAME_OPARG();
  2666. }
  2667. STAT_INC(COMPARE_OP, deferred);
  2668. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  2669. #endif /* ENABLE_SPECIALIZATION */
  2670. assert((oparg >> 4) <= Py_GE);
  2671. res = PyObject_RichCompare(left, right, oparg>>4);
  2672. #line 2822 "Python/generated_cases.c.h"
  2673. Py_DECREF(left);
  2674. Py_DECREF(right);
  2675. #line 2047 "Python/bytecodes.c"
  2676. if (res == NULL) goto pop_2_error;
  2677. #line 2827 "Python/generated_cases.c.h"
  2678. STACK_SHRINK(1);
  2679. stack_pointer[-1] = res;
  2680. next_instr += 1;
  2681. DISPATCH();
  2682. }
  2683. TARGET(COMPARE_OP_FLOAT) {
  2684. PyObject *right = stack_pointer[-1];
  2685. PyObject *left = stack_pointer[-2];
  2686. PyObject *res;
  2687. #line 2051 "Python/bytecodes.c"
  2688. DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP);
  2689. DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP);
  2690. STAT_INC(COMPARE_OP, hit);
  2691. double dleft = PyFloat_AS_DOUBLE(left);
  2692. double dright = PyFloat_AS_DOUBLE(right);
  2693. // 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
  2694. int sign_ish = COMPARISON_BIT(dleft, dright);
  2695. _Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
  2696. _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
  2697. res = (sign_ish & oparg) ? Py_True : Py_False;
  2698. #line 2849 "Python/generated_cases.c.h"
  2699. STACK_SHRINK(1);
  2700. stack_pointer[-1] = res;
  2701. next_instr += 1;
  2702. DISPATCH();
  2703. }
  2704. TARGET(COMPARE_OP_INT) {
  2705. PyObject *right = stack_pointer[-1];
  2706. PyObject *left = stack_pointer[-2];
  2707. PyObject *res;
  2708. #line 2065 "Python/bytecodes.c"
  2709. DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP);
  2710. DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP);
  2711. DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP);
  2712. DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)right), COMPARE_OP);
  2713. STAT_INC(COMPARE_OP, hit);
  2714. assert(_PyLong_DigitCount((PyLongObject *)left) <= 1 &&
  2715. _PyLong_DigitCount((PyLongObject *)right) <= 1);
  2716. Py_ssize_t ileft = _PyLong_CompactValue((PyLongObject *)left);
  2717. Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right);
  2718. // 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
  2719. int sign_ish = COMPARISON_BIT(ileft, iright);
  2720. _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
  2721. _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
  2722. res = (sign_ish & oparg) ? Py_True : Py_False;
  2723. #line 2875 "Python/generated_cases.c.h"
  2724. STACK_SHRINK(1);
  2725. stack_pointer[-1] = res;
  2726. next_instr += 1;
  2727. DISPATCH();
  2728. }
  2729. TARGET(COMPARE_OP_STR) {
  2730. PyObject *right = stack_pointer[-1];
  2731. PyObject *left = stack_pointer[-2];
  2732. PyObject *res;
  2733. #line 2083 "Python/bytecodes.c"
  2734. DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP);
  2735. DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP);
  2736. STAT_INC(COMPARE_OP, hit);
  2737. int eq = _PyUnicode_Equal(left, right);
  2738. assert((oparg >>4) == Py_EQ || (oparg >>4) == Py_NE);
  2739. _Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc);
  2740. _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
  2741. assert(eq == 0 || eq == 1);
  2742. assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
  2743. assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
  2744. res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False;
  2745. #line 2898 "Python/generated_cases.c.h"
  2746. STACK_SHRINK(1);
  2747. stack_pointer[-1] = res;
  2748. next_instr += 1;
  2749. DISPATCH();
  2750. }
  2751. TARGET(IS_OP) {
  2752. PyObject *right = stack_pointer[-1];
  2753. PyObject *left = stack_pointer[-2];
  2754. PyObject *b;
  2755. #line 2097 "Python/bytecodes.c"
  2756. int res = Py_Is(left, right) ^ oparg;
  2757. #line 2911 "Python/generated_cases.c.h"
  2758. Py_DECREF(left);
  2759. Py_DECREF(right);
  2760. #line 2099 "Python/bytecodes.c"
  2761. b = res ? Py_True : Py_False;
  2762. #line 2916 "Python/generated_cases.c.h"
  2763. STACK_SHRINK(1);
  2764. stack_pointer[-1] = b;
  2765. DISPATCH();
  2766. }
  2767. TARGET(CONTAINS_OP) {
  2768. PyObject *right = stack_pointer[-1];
  2769. PyObject *left = stack_pointer[-2];
  2770. PyObject *b;
  2771. #line 2103 "Python/bytecodes.c"
  2772. int res = PySequence_Contains(right, left);
  2773. #line 2928 "Python/generated_cases.c.h"
  2774. Py_DECREF(left);
  2775. Py_DECREF(right);
  2776. #line 2105 "Python/bytecodes.c"
  2777. if (res < 0) goto pop_2_error;
  2778. b = (res ^ oparg) ? Py_True : Py_False;
  2779. #line 2934 "Python/generated_cases.c.h"
  2780. STACK_SHRINK(1);
  2781. stack_pointer[-1] = b;
  2782. DISPATCH();
  2783. }
  2784. TARGET(CHECK_EG_MATCH) {
  2785. PyObject *match_type = stack_pointer[-1];
  2786. PyObject *exc_value = stack_pointer[-2];
  2787. PyObject *rest;
  2788. PyObject *match;
  2789. #line 2110 "Python/bytecodes.c"
  2790. if (check_except_star_type_valid(tstate, match_type) < 0) {
  2791. #line 2947 "Python/generated_cases.c.h"
  2792. Py_DECREF(exc_value);
  2793. Py_DECREF(match_type);
  2794. #line 2112 "Python/bytecodes.c"
  2795. if (true) goto pop_2_error;
  2796. }
  2797. match = NULL;
  2798. rest = NULL;
  2799. int res = exception_group_match(exc_value, match_type,
  2800. &match, &rest);
  2801. #line 2958 "Python/generated_cases.c.h"
  2802. Py_DECREF(exc_value);
  2803. Py_DECREF(match_type);
  2804. #line 2120 "Python/bytecodes.c"
  2805. if (res < 0) goto pop_2_error;
  2806. assert((match == NULL) == (rest == NULL));
  2807. if (match == NULL) goto pop_2_error;
  2808. if (!Py_IsNone(match)) {
  2809. PyErr_SetHandledException(match);
  2810. }
  2811. #line 2970 "Python/generated_cases.c.h"
  2812. stack_pointer[-1] = match;
  2813. stack_pointer[-2] = rest;
  2814. DISPATCH();
  2815. }
  2816. TARGET(CHECK_EXC_MATCH) {
  2817. PyObject *right = stack_pointer[-1];
  2818. PyObject *left = stack_pointer[-2];
  2819. PyObject *b;
  2820. #line 2131 "Python/bytecodes.c"
  2821. assert(PyExceptionInstance_Check(left));
  2822. if (check_except_type_valid(tstate, right) < 0) {
  2823. #line 2983 "Python/generated_cases.c.h"
  2824. Py_DECREF(right);
  2825. #line 2134 "Python/bytecodes.c"
  2826. if (true) goto pop_1_error;
  2827. }
  2828. int res = PyErr_GivenExceptionMatches(left, right);
  2829. #line 2990 "Python/generated_cases.c.h"
  2830. Py_DECREF(right);
  2831. #line 2139 "Python/bytecodes.c"
  2832. b = res ? Py_True : Py_False;
  2833. #line 2994 "Python/generated_cases.c.h"
  2834. stack_pointer[-1] = b;
  2835. DISPATCH();
  2836. }
  2837. TARGET(IMPORT_NAME) {
  2838. PyObject *fromlist = stack_pointer[-1];
  2839. PyObject *level = stack_pointer[-2];
  2840. PyObject *res;
  2841. #line 2143 "Python/bytecodes.c"
  2842. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  2843. res = import_name(tstate, frame, name, fromlist, level);
  2844. #line 3006 "Python/generated_cases.c.h"
  2845. Py_DECREF(level);
  2846. Py_DECREF(fromlist);
  2847. #line 2146 "Python/bytecodes.c"
  2848. if (res == NULL) goto pop_2_error;
  2849. #line 3011 "Python/generated_cases.c.h"
  2850. STACK_SHRINK(1);
  2851. stack_pointer[-1] = res;
  2852. DISPATCH();
  2853. }
  2854. TARGET(IMPORT_FROM) {
  2855. PyObject *from = stack_pointer[-1];
  2856. PyObject *res;
  2857. #line 2150 "Python/bytecodes.c"
  2858. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  2859. res = import_from(tstate, from, name);
  2860. if (res == NULL) goto error;
  2861. #line 3024 "Python/generated_cases.c.h"
  2862. STACK_GROW(1);
  2863. stack_pointer[-1] = res;
  2864. DISPATCH();
  2865. }
  2866. TARGET(JUMP_FORWARD) {
  2867. #line 2156 "Python/bytecodes.c"
  2868. JUMPBY(oparg);
  2869. #line 3033 "Python/generated_cases.c.h"
  2870. DISPATCH();
  2871. }
  2872. TARGET(JUMP_BACKWARD) {
  2873. PREDICTED(JUMP_BACKWARD);
  2874. #line 2160 "Python/bytecodes.c"
  2875. assert(oparg < INSTR_OFFSET());
  2876. JUMPBY(-oparg);
  2877. #line 3042 "Python/generated_cases.c.h"
  2878. CHECK_EVAL_BREAKER();
  2879. DISPATCH();
  2880. }
  2881. TARGET(POP_JUMP_IF_FALSE) {
  2882. PREDICTED(POP_JUMP_IF_FALSE);
  2883. PyObject *cond = stack_pointer[-1];
  2884. #line 2166 "Python/bytecodes.c"
  2885. if (Py_IsFalse(cond)) {
  2886. JUMPBY(oparg);
  2887. }
  2888. else if (!Py_IsTrue(cond)) {
  2889. int err = PyObject_IsTrue(cond);
  2890. #line 3056 "Python/generated_cases.c.h"
  2891. Py_DECREF(cond);
  2892. #line 2172 "Python/bytecodes.c"
  2893. if (err == 0) {
  2894. JUMPBY(oparg);
  2895. }
  2896. else {
  2897. if (err < 0) goto pop_1_error;
  2898. }
  2899. }
  2900. #line 3066 "Python/generated_cases.c.h"
  2901. STACK_SHRINK(1);
  2902. DISPATCH();
  2903. }
  2904. TARGET(POP_JUMP_IF_TRUE) {
  2905. PyObject *cond = stack_pointer[-1];
  2906. #line 2182 "Python/bytecodes.c"
  2907. if (Py_IsTrue(cond)) {
  2908. JUMPBY(oparg);
  2909. }
  2910. else if (!Py_IsFalse(cond)) {
  2911. int err = PyObject_IsTrue(cond);
  2912. #line 3079 "Python/generated_cases.c.h"
  2913. Py_DECREF(cond);
  2914. #line 2188 "Python/bytecodes.c"
  2915. if (err > 0) {
  2916. JUMPBY(oparg);
  2917. }
  2918. else {
  2919. if (err < 0) goto pop_1_error;
  2920. }
  2921. }
  2922. #line 3089 "Python/generated_cases.c.h"
  2923. STACK_SHRINK(1);
  2924. DISPATCH();
  2925. }
  2926. TARGET(POP_JUMP_IF_NOT_NONE) {
  2927. PyObject *value = stack_pointer[-1];
  2928. #line 2198 "Python/bytecodes.c"
  2929. if (!Py_IsNone(value)) {
  2930. #line 3098 "Python/generated_cases.c.h"
  2931. Py_DECREF(value);
  2932. #line 2200 "Python/bytecodes.c"
  2933. JUMPBY(oparg);
  2934. }
  2935. #line 3103 "Python/generated_cases.c.h"
  2936. STACK_SHRINK(1);
  2937. DISPATCH();
  2938. }
  2939. TARGET(POP_JUMP_IF_NONE) {
  2940. PyObject *value = stack_pointer[-1];
  2941. #line 2205 "Python/bytecodes.c"
  2942. if (Py_IsNone(value)) {
  2943. JUMPBY(oparg);
  2944. }
  2945. else {
  2946. #line 3115 "Python/generated_cases.c.h"
  2947. Py_DECREF(value);
  2948. #line 2210 "Python/bytecodes.c"
  2949. }
  2950. #line 3119 "Python/generated_cases.c.h"
  2951. STACK_SHRINK(1);
  2952. DISPATCH();
  2953. }
  2954. TARGET(JUMP_BACKWARD_NO_INTERRUPT) {
  2955. #line 2214 "Python/bytecodes.c"
  2956. /* This bytecode is used in the `yield from` or `await` loop.
  2957. * If there is an interrupt, we want it handled in the innermost
  2958. * generator or coroutine, so we deliberately do not check it here.
  2959. * (see bpo-30039).
  2960. */
  2961. JUMPBY(-oparg);
  2962. #line 3132 "Python/generated_cases.c.h"
  2963. DISPATCH();
  2964. }
  2965. TARGET(GET_LEN) {
  2966. PyObject *obj = stack_pointer[-1];
  2967. PyObject *len_o;
  2968. #line 2223 "Python/bytecodes.c"
  2969. // PUSH(len(TOS))
  2970. Py_ssize_t len_i = PyObject_Length(obj);
  2971. if (len_i < 0) goto error;
  2972. len_o = PyLong_FromSsize_t(len_i);
  2973. if (len_o == NULL) goto error;
  2974. #line 3145 "Python/generated_cases.c.h"
  2975. STACK_GROW(1);
  2976. stack_pointer[-1] = len_o;
  2977. DISPATCH();
  2978. }
  2979. TARGET(MATCH_CLASS) {
  2980. PyObject *names = stack_pointer[-1];
  2981. PyObject *type = stack_pointer[-2];
  2982. PyObject *subject = stack_pointer[-3];
  2983. PyObject *attrs;
  2984. #line 2231 "Python/bytecodes.c"
  2985. // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or
  2986. // None on failure.
  2987. assert(PyTuple_CheckExact(names));
  2988. attrs = match_class(tstate, subject, type, oparg, names);
  2989. #line 3161 "Python/generated_cases.c.h"
  2990. Py_DECREF(subject);
  2991. Py_DECREF(type);
  2992. Py_DECREF(names);
  2993. #line 2236 "Python/bytecodes.c"
  2994. if (attrs) {
  2995. assert(PyTuple_CheckExact(attrs)); // Success!
  2996. }
  2997. else {
  2998. if (_PyErr_Occurred(tstate)) goto pop_3_error;
  2999. attrs = Py_None; // Failure!
  3000. }
  3001. #line 3173 "Python/generated_cases.c.h"
  3002. STACK_SHRINK(2);
  3003. stack_pointer[-1] = attrs;
  3004. DISPATCH();
  3005. }
  3006. TARGET(MATCH_MAPPING) {
  3007. PyObject *subject = stack_pointer[-1];
  3008. PyObject *res;
  3009. #line 2246 "Python/bytecodes.c"
  3010. int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING;
  3011. res = match ? Py_True : Py_False;
  3012. #line 3185 "Python/generated_cases.c.h"
  3013. STACK_GROW(1);
  3014. stack_pointer[-1] = res;
  3015. PREDICT(POP_JUMP_IF_FALSE);
  3016. DISPATCH();
  3017. }
  3018. TARGET(MATCH_SEQUENCE) {
  3019. PyObject *subject = stack_pointer[-1];
  3020. PyObject *res;
  3021. #line 2252 "Python/bytecodes.c"
  3022. int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE;
  3023. res = match ? Py_True : Py_False;
  3024. #line 3198 "Python/generated_cases.c.h"
  3025. STACK_GROW(1);
  3026. stack_pointer[-1] = res;
  3027. PREDICT(POP_JUMP_IF_FALSE);
  3028. DISPATCH();
  3029. }
  3030. TARGET(MATCH_KEYS) {
  3031. PyObject *keys = stack_pointer[-1];
  3032. PyObject *subject = stack_pointer[-2];
  3033. PyObject *values_or_none;
  3034. #line 2258 "Python/bytecodes.c"
  3035. // On successful match, PUSH(values). Otherwise, PUSH(None).
  3036. values_or_none = match_keys(tstate, subject, keys);
  3037. if (values_or_none == NULL) goto error;
  3038. #line 3213 "Python/generated_cases.c.h"
  3039. STACK_GROW(1);
  3040. stack_pointer[-1] = values_or_none;
  3041. DISPATCH();
  3042. }
  3043. TARGET(GET_ITER) {
  3044. PyObject *iterable = stack_pointer[-1];
  3045. PyObject *iter;
  3046. #line 2264 "Python/bytecodes.c"
  3047. /* before: [obj]; after [getiter(obj)] */
  3048. iter = PyObject_GetIter(iterable);
  3049. #line 3225 "Python/generated_cases.c.h"
  3050. Py_DECREF(iterable);
  3051. #line 2267 "Python/bytecodes.c"
  3052. if (iter == NULL) goto pop_1_error;
  3053. #line 3229 "Python/generated_cases.c.h"
  3054. stack_pointer[-1] = iter;
  3055. DISPATCH();
  3056. }
  3057. TARGET(GET_YIELD_FROM_ITER) {
  3058. PyObject *iterable = stack_pointer[-1];
  3059. PyObject *iter;
  3060. #line 2271 "Python/bytecodes.c"
  3061. /* before: [obj]; after [getiter(obj)] */
  3062. if (PyCoro_CheckExact(iterable)) {
  3063. /* `iterable` is a coroutine */
  3064. if (!(frame->f_code->co_flags & (CO_COROUTINE | CO_ITERABLE_COROUTINE))) {
  3065. /* and it is used in a 'yield from' expression of a
  3066. regular generator. */
  3067. _PyErr_SetString(tstate, PyExc_TypeError,
  3068. "cannot 'yield from' a coroutine object "
  3069. "in a non-coroutine generator");
  3070. goto error;
  3071. }
  3072. iter = iterable;
  3073. }
  3074. else if (PyGen_CheckExact(iterable)) {
  3075. iter = iterable;
  3076. }
  3077. else {
  3078. /* `iterable` is not a generator. */
  3079. iter = PyObject_GetIter(iterable);
  3080. if (iter == NULL) {
  3081. goto error;
  3082. }
  3083. #line 3260 "Python/generated_cases.c.h"
  3084. Py_DECREF(iterable);
  3085. #line 2294 "Python/bytecodes.c"
  3086. }
  3087. #line 3264 "Python/generated_cases.c.h"
  3088. stack_pointer[-1] = iter;
  3089. PREDICT(LOAD_CONST);
  3090. DISPATCH();
  3091. }
  3092. TARGET(FOR_ITER) {
  3093. PREDICTED(FOR_ITER);
  3094. static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size");
  3095. PyObject *iter = stack_pointer[-1];
  3096. PyObject *next;
  3097. #line 2313 "Python/bytecodes.c"
  3098. #if ENABLE_SPECIALIZATION
  3099. _PyForIterCache *cache = (_PyForIterCache *)next_instr;
  3100. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  3101. next_instr--;
  3102. _Py_Specialize_ForIter(iter, next_instr, oparg);
  3103. DISPATCH_SAME_OPARG();
  3104. }
  3105. STAT_INC(FOR_ITER, deferred);
  3106. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  3107. #endif /* ENABLE_SPECIALIZATION */
  3108. /* before: [iter]; after: [iter, iter()] *or* [] (and jump over END_FOR.) */
  3109. next = (*Py_TYPE(iter)->tp_iternext)(iter);
  3110. if (next == NULL) {
  3111. if (_PyErr_Occurred(tstate)) {
  3112. if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
  3113. goto error;
  3114. }
  3115. monitor_raise(tstate, frame, next_instr-1);
  3116. _PyErr_Clear(tstate);
  3117. }
  3118. /* iterator ended normally */
  3119. assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
  3120. next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
  3121. Py_DECREF(iter);
  3122. STACK_SHRINK(1);
  3123. /* Jump forward oparg, then skip following END_FOR instruction */
  3124. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
  3125. DISPATCH();
  3126. }
  3127. // Common case: no jump, leave it to the code generator
  3128. #line 3306 "Python/generated_cases.c.h"
  3129. STACK_GROW(1);
  3130. stack_pointer[-1] = next;
  3131. next_instr += 1;
  3132. DISPATCH();
  3133. }
  3134. TARGET(INSTRUMENTED_FOR_ITER) {
  3135. #line 2346 "Python/bytecodes.c"
  3136. _Py_CODEUNIT *here = next_instr-1;
  3137. _Py_CODEUNIT *target;
  3138. PyObject *iter = TOP();
  3139. PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
  3140. if (next != NULL) {
  3141. PUSH(next);
  3142. target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER;
  3143. }
  3144. else {
  3145. if (_PyErr_Occurred(tstate)) {
  3146. if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
  3147. goto error;
  3148. }
  3149. monitor_raise(tstate, frame, here);
  3150. _PyErr_Clear(tstate);
  3151. }
  3152. /* iterator ended normally */
  3153. assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
  3154. next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
  3155. STACK_SHRINK(1);
  3156. Py_DECREF(iter);
  3157. /* Skip END_FOR */
  3158. target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1;
  3159. }
  3160. INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH);
  3161. #line 3340 "Python/generated_cases.c.h"
  3162. DISPATCH();
  3163. }
  3164. TARGET(FOR_ITER_LIST) {
  3165. PyObject *iter = stack_pointer[-1];
  3166. PyObject *next;
  3167. #line 2374 "Python/bytecodes.c"
  3168. DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER);
  3169. _PyListIterObject *it = (_PyListIterObject *)iter;
  3170. STAT_INC(FOR_ITER, hit);
  3171. PyListObject *seq = it->it_seq;
  3172. if (seq) {
  3173. if (it->it_index < PyList_GET_SIZE(seq)) {
  3174. next = Py_NewRef(PyList_GET_ITEM(seq, it->it_index++));
  3175. goto end_for_iter_list; // End of this instruction
  3176. }
  3177. it->it_seq = NULL;
  3178. Py_DECREF(seq);
  3179. }
  3180. Py_DECREF(iter);
  3181. STACK_SHRINK(1);
  3182. /* Jump forward oparg, then skip following END_FOR instruction */
  3183. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
  3184. DISPATCH();
  3185. end_for_iter_list:
  3186. // Common case: no jump, leave it to the code generator
  3187. #line 3367 "Python/generated_cases.c.h"
  3188. STACK_GROW(1);
  3189. stack_pointer[-1] = next;
  3190. next_instr += 1;
  3191. DISPATCH();
  3192. }
  3193. TARGET(FOR_ITER_TUPLE) {
  3194. PyObject *iter = stack_pointer[-1];
  3195. PyObject *next;
  3196. #line 2396 "Python/bytecodes.c"
  3197. _PyTupleIterObject *it = (_PyTupleIterObject *)iter;
  3198. DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER);
  3199. STAT_INC(FOR_ITER, hit);
  3200. PyTupleObject *seq = it->it_seq;
  3201. if (seq) {
  3202. if (it->it_index < PyTuple_GET_SIZE(seq)) {
  3203. next = Py_NewRef(PyTuple_GET_ITEM(seq, it->it_index++));
  3204. goto end_for_iter_tuple; // End of this instruction
  3205. }
  3206. it->it_seq = NULL;
  3207. Py_DECREF(seq);
  3208. }
  3209. Py_DECREF(iter);
  3210. STACK_SHRINK(1);
  3211. /* Jump forward oparg, then skip following END_FOR instruction */
  3212. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
  3213. DISPATCH();
  3214. end_for_iter_tuple:
  3215. // Common case: no jump, leave it to the code generator
  3216. #line 3397 "Python/generated_cases.c.h"
  3217. STACK_GROW(1);
  3218. stack_pointer[-1] = next;
  3219. next_instr += 1;
  3220. DISPATCH();
  3221. }
  3222. TARGET(FOR_ITER_RANGE) {
  3223. PyObject *iter = stack_pointer[-1];
  3224. PyObject *next;
  3225. #line 2418 "Python/bytecodes.c"
  3226. _PyRangeIterObject *r = (_PyRangeIterObject *)iter;
  3227. DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER);
  3228. STAT_INC(FOR_ITER, hit);
  3229. if (r->len <= 0) {
  3230. STACK_SHRINK(1);
  3231. Py_DECREF(r);
  3232. // Jump over END_FOR instruction.
  3233. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
  3234. DISPATCH();
  3235. }
  3236. long value = r->start;
  3237. r->start = value + r->step;
  3238. r->len--;
  3239. next = PyLong_FromLong(value);
  3240. if (next == NULL) {
  3241. goto error;
  3242. }
  3243. #line 3425 "Python/generated_cases.c.h"
  3244. STACK_GROW(1);
  3245. stack_pointer[-1] = next;
  3246. next_instr += 1;
  3247. DISPATCH();
  3248. }
  3249. TARGET(FOR_ITER_GEN) {
  3250. PyObject *iter = stack_pointer[-1];
  3251. #line 2438 "Python/bytecodes.c"
  3252. DEOPT_IF(tstate->interp->eval_frame, FOR_ITER);
  3253. PyGenObject *gen = (PyGenObject *)iter;
  3254. DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER);
  3255. DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER);
  3256. STAT_INC(FOR_ITER, hit);
  3257. _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
  3258. frame->return_offset = oparg;
  3259. _PyFrame_StackPush(gen_frame, Py_None);
  3260. gen->gi_frame_state = FRAME_EXECUTING;
  3261. gen->gi_exc_state.previous_item = tstate->exc_info;
  3262. tstate->exc_info = &gen->gi_exc_state;
  3263. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER);
  3264. assert(next_instr[oparg].op.code == END_FOR ||
  3265. next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
  3266. DISPATCH_INLINED(gen_frame);
  3267. #line 3450 "Python/generated_cases.c.h"
  3268. }
  3269. TARGET(BEFORE_ASYNC_WITH) {
  3270. PyObject *mgr = stack_pointer[-1];
  3271. PyObject *exit;
  3272. PyObject *res;
  3273. #line 2456 "Python/bytecodes.c"
  3274. PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__));
  3275. if (enter == NULL) {
  3276. if (!_PyErr_Occurred(tstate)) {
  3277. _PyErr_Format(tstate, PyExc_TypeError,
  3278. "'%.200s' object does not support the "
  3279. "asynchronous context manager protocol",
  3280. Py_TYPE(mgr)->tp_name);
  3281. }
  3282. goto error;
  3283. }
  3284. exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__aexit__));
  3285. if (exit == NULL) {
  3286. if (!_PyErr_Occurred(tstate)) {
  3287. _PyErr_Format(tstate, PyExc_TypeError,
  3288. "'%.200s' object does not support the "
  3289. "asynchronous context manager protocol "
  3290. "(missed __aexit__ method)",
  3291. Py_TYPE(mgr)->tp_name);
  3292. }
  3293. Py_DECREF(enter);
  3294. goto error;
  3295. }
  3296. #line 3480 "Python/generated_cases.c.h"
  3297. Py_DECREF(mgr);
  3298. #line 2479 "Python/bytecodes.c"
  3299. res = _PyObject_CallNoArgs(enter);
  3300. Py_DECREF(enter);
  3301. if (res == NULL) {
  3302. Py_DECREF(exit);
  3303. if (true) goto pop_1_error;
  3304. }
  3305. #line 3489 "Python/generated_cases.c.h"
  3306. STACK_GROW(1);
  3307. stack_pointer[-1] = res;
  3308. stack_pointer[-2] = exit;
  3309. PREDICT(GET_AWAITABLE);
  3310. DISPATCH();
  3311. }
  3312. TARGET(BEFORE_WITH) {
  3313. PyObject *mgr = stack_pointer[-1];
  3314. PyObject *exit;
  3315. PyObject *res;
  3316. #line 2489 "Python/bytecodes.c"
  3317. /* pop the context manager, push its __exit__ and the
  3318. * value returned from calling its __enter__
  3319. */
  3320. PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__enter__));
  3321. if (enter == NULL) {
  3322. if (!_PyErr_Occurred(tstate)) {
  3323. _PyErr_Format(tstate, PyExc_TypeError,
  3324. "'%.200s' object does not support the "
  3325. "context manager protocol",
  3326. Py_TYPE(mgr)->tp_name);
  3327. }
  3328. goto error;
  3329. }
  3330. exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
  3331. if (exit == NULL) {
  3332. if (!_PyErr_Occurred(tstate)) {
  3333. _PyErr_Format(tstate, PyExc_TypeError,
  3334. "'%.200s' object does not support the "
  3335. "context manager protocol "
  3336. "(missed __exit__ method)",
  3337. Py_TYPE(mgr)->tp_name);
  3338. }
  3339. Py_DECREF(enter);
  3340. goto error;
  3341. }
  3342. #line 3527 "Python/generated_cases.c.h"
  3343. Py_DECREF(mgr);
  3344. #line 2515 "Python/bytecodes.c"
  3345. res = _PyObject_CallNoArgs(enter);
  3346. Py_DECREF(enter);
  3347. if (res == NULL) {
  3348. Py_DECREF(exit);
  3349. if (true) goto pop_1_error;
  3350. }
  3351. #line 3536 "Python/generated_cases.c.h"
  3352. STACK_GROW(1);
  3353. stack_pointer[-1] = res;
  3354. stack_pointer[-2] = exit;
  3355. DISPATCH();
  3356. }
  3357. TARGET(WITH_EXCEPT_START) {
  3358. PyObject *val = stack_pointer[-1];
  3359. PyObject *lasti = stack_pointer[-3];
  3360. PyObject *exit_func = stack_pointer[-4];
  3361. PyObject *res;
  3362. #line 2524 "Python/bytecodes.c"
  3363. /* At the top of the stack are 4 values:
  3364. - val: TOP = exc_info()
  3365. - unused: SECOND = previous exception
  3366. - lasti: THIRD = lasti of exception in exc_info()
  3367. - exit_func: FOURTH = the context.__exit__ bound method
  3368. We call FOURTH(type(TOP), TOP, GetTraceback(TOP)).
  3369. Then we push the __exit__ return value.
  3370. */
  3371. PyObject *exc, *tb;
  3372. assert(val && PyExceptionInstance_Check(val));
  3373. exc = PyExceptionInstance_Class(val);
  3374. tb = PyException_GetTraceback(val);
  3375. if (tb == NULL) {
  3376. tb = Py_None;
  3377. }
  3378. else {
  3379. Py_DECREF(tb);
  3380. }
  3381. assert(PyLong_Check(lasti));
  3382. (void)lasti; // Shut up compiler warning if asserts are off
  3383. PyObject *stack[4] = {NULL, exc, val, tb};
  3384. res = PyObject_Vectorcall(exit_func, stack + 1,
  3385. 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  3386. if (res == NULL) goto error;
  3387. #line 3574 "Python/generated_cases.c.h"
  3388. STACK_GROW(1);
  3389. stack_pointer[-1] = res;
  3390. DISPATCH();
  3391. }
  3392. TARGET(PUSH_EXC_INFO) {
  3393. PyObject *new_exc = stack_pointer[-1];
  3394. PyObject *prev_exc;
  3395. #line 2552 "Python/bytecodes.c"
  3396. _PyErr_StackItem *exc_info = tstate->exc_info;
  3397. if (exc_info->exc_value != NULL) {
  3398. prev_exc = exc_info->exc_value;
  3399. }
  3400. else {
  3401. prev_exc = Py_None;
  3402. }
  3403. assert(PyExceptionInstance_Check(new_exc));
  3404. exc_info->exc_value = Py_NewRef(new_exc);
  3405. #line 3593 "Python/generated_cases.c.h"
  3406. STACK_GROW(1);
  3407. stack_pointer[-1] = new_exc;
  3408. stack_pointer[-2] = prev_exc;
  3409. DISPATCH();
  3410. }
  3411. TARGET(LOAD_ATTR_METHOD_WITH_VALUES) {
  3412. PyObject *self = stack_pointer[-1];
  3413. PyObject *res2 = NULL;
  3414. PyObject *res;
  3415. uint32_t type_version = read_u32(&next_instr[1].cache);
  3416. uint32_t keys_version = read_u32(&next_instr[3].cache);
  3417. PyObject *descr = read_obj(&next_instr[5].cache);
  3418. #line 2564 "Python/bytecodes.c"
  3419. /* Cached method object */
  3420. PyTypeObject *self_cls = Py_TYPE(self);
  3421. assert(type_version != 0);
  3422. DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
  3423. assert(self_cls->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  3424. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(self);
  3425. DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
  3426. PyHeapTypeObject *self_heap_type = (PyHeapTypeObject *)self_cls;
  3427. DEOPT_IF(self_heap_type->ht_cached_keys->dk_version !=
  3428. keys_version, LOAD_ATTR);
  3429. STAT_INC(LOAD_ATTR, hit);
  3430. assert(descr != NULL);
  3431. res2 = Py_NewRef(descr);
  3432. assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR));
  3433. res = self;
  3434. assert(oparg & 1);
  3435. #line 3624 "Python/generated_cases.c.h"
  3436. STACK_GROW(((oparg & 1) ? 1 : 0));
  3437. stack_pointer[-1] = res;
  3438. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  3439. next_instr += 9;
  3440. DISPATCH();
  3441. }
  3442. TARGET(LOAD_ATTR_METHOD_NO_DICT) {
  3443. PyObject *self = stack_pointer[-1];
  3444. PyObject *res2 = NULL;
  3445. PyObject *res;
  3446. uint32_t type_version = read_u32(&next_instr[1].cache);
  3447. PyObject *descr = read_obj(&next_instr[5].cache);
  3448. #line 2583 "Python/bytecodes.c"
  3449. PyTypeObject *self_cls = Py_TYPE(self);
  3450. DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
  3451. assert(self_cls->tp_dictoffset == 0);
  3452. STAT_INC(LOAD_ATTR, hit);
  3453. assert(descr != NULL);
  3454. assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR));
  3455. res2 = Py_NewRef(descr);
  3456. res = self;
  3457. assert(oparg & 1);
  3458. #line 3648 "Python/generated_cases.c.h"
  3459. STACK_GROW(((oparg & 1) ? 1 : 0));
  3460. stack_pointer[-1] = res;
  3461. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  3462. next_instr += 9;
  3463. DISPATCH();
  3464. }
  3465. TARGET(LOAD_ATTR_METHOD_LAZY_DICT) {
  3466. PyObject *self = stack_pointer[-1];
  3467. PyObject *res2 = NULL;
  3468. PyObject *res;
  3469. uint32_t type_version = read_u32(&next_instr[1].cache);
  3470. PyObject *descr = read_obj(&next_instr[5].cache);
  3471. #line 2595 "Python/bytecodes.c"
  3472. PyTypeObject *self_cls = Py_TYPE(self);
  3473. DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
  3474. Py_ssize_t dictoffset = self_cls->tp_dictoffset;
  3475. assert(dictoffset > 0);
  3476. PyObject *dict = *(PyObject **)((char *)self + dictoffset);
  3477. /* This object has a __dict__, just not yet created */
  3478. DEOPT_IF(dict != NULL, LOAD_ATTR);
  3479. STAT_INC(LOAD_ATTR, hit);
  3480. assert(descr != NULL);
  3481. assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR));
  3482. res2 = Py_NewRef(descr);
  3483. res = self;
  3484. assert(oparg & 1);
  3485. #line 3676 "Python/generated_cases.c.h"
  3486. STACK_GROW(((oparg & 1) ? 1 : 0));
  3487. stack_pointer[-1] = res;
  3488. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  3489. next_instr += 9;
  3490. DISPATCH();
  3491. }
  3492. TARGET(KW_NAMES) {
  3493. #line 2611 "Python/bytecodes.c"
  3494. assert(kwnames == NULL);
  3495. assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts));
  3496. kwnames = GETITEM(frame->f_code->co_consts, oparg);
  3497. #line 3689 "Python/generated_cases.c.h"
  3498. DISPATCH();
  3499. }
  3500. TARGET(INSTRUMENTED_CALL) {
  3501. #line 2617 "Python/bytecodes.c"
  3502. int is_meth = PEEK(oparg+2) != NULL;
  3503. int total_args = oparg + is_meth;
  3504. PyObject *function = PEEK(total_args + 1);
  3505. PyObject *arg = total_args == 0 ?
  3506. &_PyInstrumentation_MISSING : PEEK(total_args);
  3507. int err = _Py_call_instrumentation_2args(
  3508. tstate, PY_MONITORING_EVENT_CALL,
  3509. frame, next_instr-1, function, arg);
  3510. if (err) goto error;
  3511. _PyCallCache *cache = (_PyCallCache *)next_instr;
  3512. INCREMENT_ADAPTIVE_COUNTER(cache->counter);
  3513. GO_TO_INSTRUCTION(CALL);
  3514. #line 3707 "Python/generated_cases.c.h"
  3515. }
  3516. TARGET(CALL) {
  3517. PREDICTED(CALL);
  3518. static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
  3519. PyObject **args = (stack_pointer - oparg);
  3520. PyObject *callable = stack_pointer[-(1 + oparg)];
  3521. PyObject *method = stack_pointer[-(2 + oparg)];
  3522. PyObject *res;
  3523. #line 2662 "Python/bytecodes.c"
  3524. int is_meth = method != NULL;
  3525. int total_args = oparg;
  3526. if (is_meth) {
  3527. callable = method;
  3528. args--;
  3529. total_args++;
  3530. }
  3531. #if ENABLE_SPECIALIZATION
  3532. _PyCallCache *cache = (_PyCallCache *)next_instr;
  3533. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  3534. next_instr--;
  3535. _Py_Specialize_Call(callable, next_instr, total_args, kwnames);
  3536. DISPATCH_SAME_OPARG();
  3537. }
  3538. STAT_INC(CALL, deferred);
  3539. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  3540. #endif /* ENABLE_SPECIALIZATION */
  3541. if (!is_meth && Py_TYPE(callable) == &PyMethod_Type) {
  3542. is_meth = 1; // For consistenct; it's dead, though
  3543. args--;
  3544. total_args++;
  3545. PyObject *self = ((PyMethodObject *)callable)->im_self;
  3546. args[0] = Py_NewRef(self);
  3547. method = ((PyMethodObject *)callable)->im_func;
  3548. args[-1] = Py_NewRef(method);
  3549. Py_DECREF(callable);
  3550. callable = method;
  3551. }
  3552. int positional_args = total_args - KWNAMES_LEN();
  3553. // Check if the call can be inlined or not
  3554. if (Py_TYPE(callable) == &PyFunction_Type &&
  3555. tstate->interp->eval_frame == NULL &&
  3556. ((PyFunctionObject *)callable)->vectorcall == _PyFunction_Vectorcall)
  3557. {
  3558. int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(callable))->co_flags;
  3559. PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(callable));
  3560. _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit(
  3561. tstate, (PyFunctionObject *)callable, locals,
  3562. args, positional_args, kwnames
  3563. );
  3564. kwnames = NULL;
  3565. // Manipulate stack directly since we leave using DISPATCH_INLINED().
  3566. STACK_SHRINK(oparg + 2);
  3567. // The frame has stolen all the arguments from the stack,
  3568. // so there is no need to clean them up.
  3569. if (new_frame == NULL) {
  3570. goto error;
  3571. }
  3572. JUMPBY(INLINE_CACHE_ENTRIES_CALL);
  3573. frame->return_offset = 0;
  3574. DISPATCH_INLINED(new_frame);
  3575. }
  3576. /* Callable is not a normal Python function */
  3577. res = PyObject_Vectorcall(
  3578. callable, args,
  3579. positional_args | PY_VECTORCALL_ARGUMENTS_OFFSET,
  3580. kwnames);
  3581. if (opcode == INSTRUMENTED_CALL) {
  3582. PyObject *arg = total_args == 0 ?
  3583. &_PyInstrumentation_MISSING : PEEK(total_args);
  3584. if (res == NULL) {
  3585. _Py_call_instrumentation_exc2(
  3586. tstate, PY_MONITORING_EVENT_C_RAISE,
  3587. frame, next_instr-1, callable, arg);
  3588. }
  3589. else {
  3590. int err = _Py_call_instrumentation_2args(
  3591. tstate, PY_MONITORING_EVENT_C_RETURN,
  3592. frame, next_instr-1, callable, arg);
  3593. if (err < 0) {
  3594. Py_CLEAR(res);
  3595. }
  3596. }
  3597. }
  3598. kwnames = NULL;
  3599. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3600. Py_DECREF(callable);
  3601. for (int i = 0; i < total_args; i++) {
  3602. Py_DECREF(args[i]);
  3603. }
  3604. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3605. #line 3799 "Python/generated_cases.c.h"
  3606. STACK_SHRINK(oparg);
  3607. STACK_SHRINK(1);
  3608. stack_pointer[-1] = res;
  3609. next_instr += 3;
  3610. CHECK_EVAL_BREAKER();
  3611. DISPATCH();
  3612. }
  3613. TARGET(CALL_BOUND_METHOD_EXACT_ARGS) {
  3614. PyObject *callable = stack_pointer[-(1 + oparg)];
  3615. PyObject *method = stack_pointer[-(2 + oparg)];
  3616. #line 2750 "Python/bytecodes.c"
  3617. DEOPT_IF(method != NULL, CALL);
  3618. DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL);
  3619. STAT_INC(CALL, hit);
  3620. PyObject *self = ((PyMethodObject *)callable)->im_self;
  3621. PEEK(oparg + 1) = Py_NewRef(self); // callable
  3622. PyObject *meth = ((PyMethodObject *)callable)->im_func;
  3623. PEEK(oparg + 2) = Py_NewRef(meth); // method
  3624. Py_DECREF(callable);
  3625. GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS);
  3626. #line 3821 "Python/generated_cases.c.h"
  3627. }
  3628. TARGET(CALL_PY_EXACT_ARGS) {
  3629. PREDICTED(CALL_PY_EXACT_ARGS);
  3630. PyObject **args = (stack_pointer - oparg);
  3631. PyObject *callable = stack_pointer[-(1 + oparg)];
  3632. PyObject *method = stack_pointer[-(2 + oparg)];
  3633. uint32_t func_version = read_u32(&next_instr[1].cache);
  3634. #line 2762 "Python/bytecodes.c"
  3635. assert(kwnames == NULL);
  3636. DEOPT_IF(tstate->interp->eval_frame, CALL);
  3637. int is_meth = method != NULL;
  3638. int argcount = oparg;
  3639. if (is_meth) {
  3640. callable = method;
  3641. args--;
  3642. argcount++;
  3643. }
  3644. DEOPT_IF(!PyFunction_Check(callable), CALL);
  3645. PyFunctionObject *func = (PyFunctionObject *)callable;
  3646. DEOPT_IF(func->func_version != func_version, CALL);
  3647. PyCodeObject *code = (PyCodeObject *)func->func_code;
  3648. DEOPT_IF(code->co_argcount != argcount, CALL);
  3649. DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
  3650. STAT_INC(CALL, hit);
  3651. _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, func, argcount);
  3652. for (int i = 0; i < argcount; i++) {
  3653. new_frame->localsplus[i] = args[i];
  3654. }
  3655. // Manipulate stack directly since we leave using DISPATCH_INLINED().
  3656. STACK_SHRINK(oparg + 2);
  3657. JUMPBY(INLINE_CACHE_ENTRIES_CALL);
  3658. frame->return_offset = 0;
  3659. DISPATCH_INLINED(new_frame);
  3660. #line 3856 "Python/generated_cases.c.h"
  3661. }
  3662. TARGET(CALL_PY_WITH_DEFAULTS) {
  3663. PyObject **args = (stack_pointer - oparg);
  3664. PyObject *callable = stack_pointer[-(1 + oparg)];
  3665. PyObject *method = stack_pointer[-(2 + oparg)];
  3666. uint32_t func_version = read_u32(&next_instr[1].cache);
  3667. #line 2790 "Python/bytecodes.c"
  3668. assert(kwnames == NULL);
  3669. DEOPT_IF(tstate->interp->eval_frame, CALL);
  3670. int is_meth = method != NULL;
  3671. int argcount = oparg;
  3672. if (is_meth) {
  3673. callable = method;
  3674. args--;
  3675. argcount++;
  3676. }
  3677. DEOPT_IF(!PyFunction_Check(callable), CALL);
  3678. PyFunctionObject *func = (PyFunctionObject *)callable;
  3679. DEOPT_IF(func->func_version != func_version, CALL);
  3680. PyCodeObject *code = (PyCodeObject *)func->func_code;
  3681. assert(func->func_defaults);
  3682. assert(PyTuple_CheckExact(func->func_defaults));
  3683. int defcount = (int)PyTuple_GET_SIZE(func->func_defaults);
  3684. assert(defcount <= code->co_argcount);
  3685. int min_args = code->co_argcount - defcount;
  3686. DEOPT_IF(argcount > code->co_argcount, CALL);
  3687. DEOPT_IF(argcount < min_args, CALL);
  3688. DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
  3689. STAT_INC(CALL, hit);
  3690. _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, func, code->co_argcount);
  3691. for (int i = 0; i < argcount; i++) {
  3692. new_frame->localsplus[i] = args[i];
  3693. }
  3694. for (int i = argcount; i < code->co_argcount; i++) {
  3695. PyObject *def = PyTuple_GET_ITEM(func->func_defaults, i - min_args);
  3696. new_frame->localsplus[i] = Py_NewRef(def);
  3697. }
  3698. // Manipulate stack and cache directly since we leave using DISPATCH_INLINED().
  3699. STACK_SHRINK(oparg + 2);
  3700. JUMPBY(INLINE_CACHE_ENTRIES_CALL);
  3701. frame->return_offset = 0;
  3702. DISPATCH_INLINED(new_frame);
  3703. #line 3900 "Python/generated_cases.c.h"
  3704. }
  3705. TARGET(CALL_NO_KW_TYPE_1) {
  3706. PyObject **args = (stack_pointer - oparg);
  3707. PyObject *callable = stack_pointer[-(1 + oparg)];
  3708. PyObject *null = stack_pointer[-(2 + oparg)];
  3709. PyObject *res;
  3710. #line 2828 "Python/bytecodes.c"
  3711. assert(kwnames == NULL);
  3712. assert(oparg == 1);
  3713. DEOPT_IF(null != NULL, CALL);
  3714. PyObject *obj = args[0];
  3715. DEOPT_IF(callable != (PyObject *)&PyType_Type, CALL);
  3716. STAT_INC(CALL, hit);
  3717. res = Py_NewRef(Py_TYPE(obj));
  3718. Py_DECREF(obj);
  3719. Py_DECREF(&PyType_Type); // I.e., callable
  3720. #line 3918 "Python/generated_cases.c.h"
  3721. STACK_SHRINK(oparg);
  3722. STACK_SHRINK(1);
  3723. stack_pointer[-1] = res;
  3724. next_instr += 3;
  3725. DISPATCH();
  3726. }
  3727. TARGET(CALL_NO_KW_STR_1) {
  3728. PyObject **args = (stack_pointer - oparg);
  3729. PyObject *callable = stack_pointer[-(1 + oparg)];
  3730. PyObject *null = stack_pointer[-(2 + oparg)];
  3731. PyObject *res;
  3732. #line 2840 "Python/bytecodes.c"
  3733. assert(kwnames == NULL);
  3734. assert(oparg == 1);
  3735. DEOPT_IF(null != NULL, CALL);
  3736. DEOPT_IF(callable != (PyObject *)&PyUnicode_Type, CALL);
  3737. STAT_INC(CALL, hit);
  3738. PyObject *arg = args[0];
  3739. res = PyObject_Str(arg);
  3740. Py_DECREF(arg);
  3741. Py_DECREF(&PyUnicode_Type); // I.e., callable
  3742. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3743. #line 3942 "Python/generated_cases.c.h"
  3744. STACK_SHRINK(oparg);
  3745. STACK_SHRINK(1);
  3746. stack_pointer[-1] = res;
  3747. next_instr += 3;
  3748. CHECK_EVAL_BREAKER();
  3749. DISPATCH();
  3750. }
  3751. TARGET(CALL_NO_KW_TUPLE_1) {
  3752. PyObject **args = (stack_pointer - oparg);
  3753. PyObject *callable = stack_pointer[-(1 + oparg)];
  3754. PyObject *null = stack_pointer[-(2 + oparg)];
  3755. PyObject *res;
  3756. #line 2854 "Python/bytecodes.c"
  3757. assert(kwnames == NULL);
  3758. assert(oparg == 1);
  3759. DEOPT_IF(null != NULL, CALL);
  3760. DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL);
  3761. STAT_INC(CALL, hit);
  3762. PyObject *arg = args[0];
  3763. res = PySequence_Tuple(arg);
  3764. Py_DECREF(arg);
  3765. Py_DECREF(&PyTuple_Type); // I.e., tuple
  3766. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3767. #line 3967 "Python/generated_cases.c.h"
  3768. STACK_SHRINK(oparg);
  3769. STACK_SHRINK(1);
  3770. stack_pointer[-1] = res;
  3771. next_instr += 3;
  3772. CHECK_EVAL_BREAKER();
  3773. DISPATCH();
  3774. }
  3775. TARGET(CALL_BUILTIN_CLASS) {
  3776. PyObject **args = (stack_pointer - oparg);
  3777. PyObject *callable = stack_pointer[-(1 + oparg)];
  3778. PyObject *method = stack_pointer[-(2 + oparg)];
  3779. PyObject *res;
  3780. #line 2868 "Python/bytecodes.c"
  3781. int is_meth = method != NULL;
  3782. int total_args = oparg;
  3783. if (is_meth) {
  3784. callable = method;
  3785. args--;
  3786. total_args++;
  3787. }
  3788. int kwnames_len = KWNAMES_LEN();
  3789. DEOPT_IF(!PyType_Check(callable), CALL);
  3790. PyTypeObject *tp = (PyTypeObject *)callable;
  3791. DEOPT_IF(tp->tp_vectorcall == NULL, CALL);
  3792. STAT_INC(CALL, hit);
  3793. res = tp->tp_vectorcall((PyObject *)tp, args,
  3794. total_args - kwnames_len, kwnames);
  3795. kwnames = NULL;
  3796. /* Free the arguments. */
  3797. for (int i = 0; i < total_args; i++) {
  3798. Py_DECREF(args[i]);
  3799. }
  3800. Py_DECREF(tp);
  3801. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3802. #line 4003 "Python/generated_cases.c.h"
  3803. STACK_SHRINK(oparg);
  3804. STACK_SHRINK(1);
  3805. stack_pointer[-1] = res;
  3806. next_instr += 3;
  3807. CHECK_EVAL_BREAKER();
  3808. DISPATCH();
  3809. }
  3810. TARGET(CALL_NO_KW_BUILTIN_O) {
  3811. PyObject **args = (stack_pointer - oparg);
  3812. PyObject *callable = stack_pointer[-(1 + oparg)];
  3813. PyObject *method = stack_pointer[-(2 + oparg)];
  3814. PyObject *res;
  3815. #line 2893 "Python/bytecodes.c"
  3816. /* Builtin METH_O functions */
  3817. assert(kwnames == NULL);
  3818. int is_meth = method != NULL;
  3819. int total_args = oparg;
  3820. if (is_meth) {
  3821. callable = method;
  3822. args--;
  3823. total_args++;
  3824. }
  3825. DEOPT_IF(total_args != 1, CALL);
  3826. DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
  3827. DEOPT_IF(PyCFunction_GET_FLAGS(callable) != METH_O, CALL);
  3828. STAT_INC(CALL, hit);
  3829. PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
  3830. // This is slower but CPython promises to check all non-vectorcall
  3831. // function calls.
  3832. if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
  3833. goto error;
  3834. }
  3835. PyObject *arg = args[0];
  3836. res = _PyCFunction_TrampolineCall(cfunc, PyCFunction_GET_SELF(callable), arg);
  3837. _Py_LeaveRecursiveCallTstate(tstate);
  3838. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3839. Py_DECREF(arg);
  3840. Py_DECREF(callable);
  3841. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3842. #line 4045 "Python/generated_cases.c.h"
  3843. STACK_SHRINK(oparg);
  3844. STACK_SHRINK(1);
  3845. stack_pointer[-1] = res;
  3846. next_instr += 3;
  3847. CHECK_EVAL_BREAKER();
  3848. DISPATCH();
  3849. }
  3850. TARGET(CALL_NO_KW_BUILTIN_FAST) {
  3851. PyObject **args = (stack_pointer - oparg);
  3852. PyObject *callable = stack_pointer[-(1 + oparg)];
  3853. PyObject *method = stack_pointer[-(2 + oparg)];
  3854. PyObject *res;
  3855. #line 2924 "Python/bytecodes.c"
  3856. /* Builtin METH_FASTCALL functions, without keywords */
  3857. assert(kwnames == NULL);
  3858. int is_meth = method != NULL;
  3859. int total_args = oparg;
  3860. if (is_meth) {
  3861. callable = method;
  3862. args--;
  3863. total_args++;
  3864. }
  3865. DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
  3866. DEOPT_IF(PyCFunction_GET_FLAGS(callable) != METH_FASTCALL, CALL);
  3867. STAT_INC(CALL, hit);
  3868. PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
  3869. /* res = func(self, args, nargs) */
  3870. res = ((_PyCFunctionFast)(void(*)(void))cfunc)(
  3871. PyCFunction_GET_SELF(callable),
  3872. args,
  3873. total_args);
  3874. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3875. /* Free the arguments. */
  3876. for (int i = 0; i < total_args; i++) {
  3877. Py_DECREF(args[i]);
  3878. }
  3879. Py_DECREF(callable);
  3880. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3881. /* Not deopting because this doesn't mean our optimization was
  3882. wrong. `res` can be NULL for valid reasons. Eg. getattr(x,
  3883. 'invalid'). In those cases an exception is set, so we must
  3884. handle it.
  3885. */
  3886. #line 4091 "Python/generated_cases.c.h"
  3887. STACK_SHRINK(oparg);
  3888. STACK_SHRINK(1);
  3889. stack_pointer[-1] = res;
  3890. next_instr += 3;
  3891. CHECK_EVAL_BREAKER();
  3892. DISPATCH();
  3893. }
  3894. TARGET(CALL_BUILTIN_FAST_WITH_KEYWORDS) {
  3895. PyObject **args = (stack_pointer - oparg);
  3896. PyObject *callable = stack_pointer[-(1 + oparg)];
  3897. PyObject *method = stack_pointer[-(2 + oparg)];
  3898. PyObject *res;
  3899. #line 2959 "Python/bytecodes.c"
  3900. /* Builtin METH_FASTCALL | METH_KEYWORDS functions */
  3901. int is_meth = method != NULL;
  3902. int total_args = oparg;
  3903. if (is_meth) {
  3904. callable = method;
  3905. args--;
  3906. total_args++;
  3907. }
  3908. DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
  3909. DEOPT_IF(PyCFunction_GET_FLAGS(callable) !=
  3910. (METH_FASTCALL | METH_KEYWORDS), CALL);
  3911. STAT_INC(CALL, hit);
  3912. /* res = func(self, args, nargs, kwnames) */
  3913. _PyCFunctionFastWithKeywords cfunc =
  3914. (_PyCFunctionFastWithKeywords)(void(*)(void))
  3915. PyCFunction_GET_FUNCTION(callable);
  3916. res = cfunc(
  3917. PyCFunction_GET_SELF(callable),
  3918. args,
  3919. total_args - KWNAMES_LEN(),
  3920. kwnames
  3921. );
  3922. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3923. kwnames = NULL;
  3924. /* Free the arguments. */
  3925. for (int i = 0; i < total_args; i++) {
  3926. Py_DECREF(args[i]);
  3927. }
  3928. Py_DECREF(callable);
  3929. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3930. #line 4137 "Python/generated_cases.c.h"
  3931. STACK_SHRINK(oparg);
  3932. STACK_SHRINK(1);
  3933. stack_pointer[-1] = res;
  3934. next_instr += 3;
  3935. CHECK_EVAL_BREAKER();
  3936. DISPATCH();
  3937. }
  3938. TARGET(CALL_NO_KW_LEN) {
  3939. PyObject **args = (stack_pointer - oparg);
  3940. PyObject *callable = stack_pointer[-(1 + oparg)];
  3941. PyObject *method = stack_pointer[-(2 + oparg)];
  3942. PyObject *res;
  3943. #line 2994 "Python/bytecodes.c"
  3944. assert(kwnames == NULL);
  3945. /* len(o) */
  3946. int is_meth = method != NULL;
  3947. int total_args = oparg;
  3948. if (is_meth) {
  3949. callable = method;
  3950. args--;
  3951. total_args++;
  3952. }
  3953. DEOPT_IF(total_args != 1, CALL);
  3954. PyInterpreterState *interp = _PyInterpreterState_GET();
  3955. DEOPT_IF(callable != interp->callable_cache.len, CALL);
  3956. STAT_INC(CALL, hit);
  3957. PyObject *arg = args[0];
  3958. Py_ssize_t len_i = PyObject_Length(arg);
  3959. if (len_i < 0) {
  3960. goto error;
  3961. }
  3962. res = PyLong_FromSsize_t(len_i);
  3963. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3964. Py_DECREF(callable);
  3965. Py_DECREF(arg);
  3966. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3967. #line 4176 "Python/generated_cases.c.h"
  3968. STACK_SHRINK(oparg);
  3969. STACK_SHRINK(1);
  3970. stack_pointer[-1] = res;
  3971. next_instr += 3;
  3972. DISPATCH();
  3973. }
  3974. TARGET(CALL_NO_KW_ISINSTANCE) {
  3975. PyObject **args = (stack_pointer - oparg);
  3976. PyObject *callable = stack_pointer[-(1 + oparg)];
  3977. PyObject *method = stack_pointer[-(2 + oparg)];
  3978. PyObject *res;
  3979. #line 3021 "Python/bytecodes.c"
  3980. assert(kwnames == NULL);
  3981. /* isinstance(o, o2) */
  3982. int is_meth = method != NULL;
  3983. int total_args = oparg;
  3984. if (is_meth) {
  3985. callable = method;
  3986. args--;
  3987. total_args++;
  3988. }
  3989. DEOPT_IF(total_args != 2, CALL);
  3990. PyInterpreterState *interp = _PyInterpreterState_GET();
  3991. DEOPT_IF(callable != interp->callable_cache.isinstance, CALL);
  3992. STAT_INC(CALL, hit);
  3993. PyObject *cls = args[1];
  3994. PyObject *inst = args[0];
  3995. int retval = PyObject_IsInstance(inst, cls);
  3996. if (retval < 0) {
  3997. goto error;
  3998. }
  3999. res = PyBool_FromLong(retval);
  4000. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  4001. Py_DECREF(inst);
  4002. Py_DECREF(cls);
  4003. Py_DECREF(callable);
  4004. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  4005. #line 4216 "Python/generated_cases.c.h"
  4006. STACK_SHRINK(oparg);
  4007. STACK_SHRINK(1);
  4008. stack_pointer[-1] = res;
  4009. next_instr += 3;
  4010. DISPATCH();
  4011. }
  4012. TARGET(CALL_NO_KW_LIST_APPEND) {
  4013. PyObject **args = (stack_pointer - oparg);
  4014. PyObject *self = stack_pointer[-(1 + oparg)];
  4015. PyObject *method = stack_pointer[-(2 + oparg)];
  4016. #line 3051 "Python/bytecodes.c"
  4017. assert(kwnames == NULL);
  4018. assert(oparg == 1);
  4019. PyInterpreterState *interp = _PyInterpreterState_GET();
  4020. DEOPT_IF(method != interp->callable_cache.list_append, CALL);
  4021. assert(self != NULL);
  4022. DEOPT_IF(!PyList_Check(self), CALL);
  4023. STAT_INC(CALL, hit);
  4024. if (_PyList_AppendTakeRef((PyListObject *)self, args[0]) < 0) {
  4025. goto pop_1_error; // Since arg is DECREF'ed already
  4026. }
  4027. Py_DECREF(self);
  4028. Py_DECREF(method);
  4029. STACK_SHRINK(3);
  4030. // CALL + POP_TOP
  4031. JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1);
  4032. assert(next_instr[-1].op.code == POP_TOP);
  4033. DISPATCH();
  4034. #line 4246 "Python/generated_cases.c.h"
  4035. }
  4036. TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) {
  4037. PyObject **args = (stack_pointer - oparg);
  4038. PyObject *method = stack_pointer[-(2 + oparg)];
  4039. PyObject *res;
  4040. #line 3071 "Python/bytecodes.c"
  4041. assert(kwnames == NULL);
  4042. int is_meth = method != NULL;
  4043. int total_args = oparg;
  4044. if (is_meth) {
  4045. args--;
  4046. total_args++;
  4047. }
  4048. PyMethodDescrObject *callable =
  4049. (PyMethodDescrObject *)PEEK(total_args + 1);
  4050. DEOPT_IF(total_args != 2, CALL);
  4051. DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
  4052. PyMethodDef *meth = callable->d_method;
  4053. DEOPT_IF(meth->ml_flags != METH_O, CALL);
  4054. PyObject *arg = args[1];
  4055. PyObject *self = args[0];
  4056. DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
  4057. STAT_INC(CALL, hit);
  4058. PyCFunction cfunc = meth->ml_meth;
  4059. // This is slower but CPython promises to check all non-vectorcall
  4060. // function calls.
  4061. if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
  4062. goto error;
  4063. }
  4064. res = _PyCFunction_TrampolineCall(cfunc, self, arg);
  4065. _Py_LeaveRecursiveCallTstate(tstate);
  4066. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  4067. Py_DECREF(self);
  4068. Py_DECREF(arg);
  4069. Py_DECREF(callable);
  4070. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  4071. #line 4284 "Python/generated_cases.c.h"
  4072. STACK_SHRINK(oparg);
  4073. STACK_SHRINK(1);
  4074. stack_pointer[-1] = res;
  4075. next_instr += 3;
  4076. CHECK_EVAL_BREAKER();
  4077. DISPATCH();
  4078. }
  4079. TARGET(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS) {
  4080. PyObject **args = (stack_pointer - oparg);
  4081. PyObject *method = stack_pointer[-(2 + oparg)];
  4082. PyObject *res;
  4083. #line 3105 "Python/bytecodes.c"
  4084. int is_meth = method != NULL;
  4085. int total_args = oparg;
  4086. if (is_meth) {
  4087. args--;
  4088. total_args++;
  4089. }
  4090. PyMethodDescrObject *callable =
  4091. (PyMethodDescrObject *)PEEK(total_args + 1);
  4092. DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
  4093. PyMethodDef *meth = callable->d_method;
  4094. DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL);
  4095. PyTypeObject *d_type = callable->d_common.d_type;
  4096. PyObject *self = args[0];
  4097. DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL);
  4098. STAT_INC(CALL, hit);
  4099. int nargs = total_args - 1;
  4100. _PyCFunctionFastWithKeywords cfunc =
  4101. (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth;
  4102. res = cfunc(self, args + 1, nargs - KWNAMES_LEN(), kwnames);
  4103. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  4104. kwnames = NULL;
  4105. /* Free the arguments. */
  4106. for (int i = 0; i < total_args; i++) {
  4107. Py_DECREF(args[i]);
  4108. }
  4109. Py_DECREF(callable);
  4110. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  4111. #line 4326 "Python/generated_cases.c.h"
  4112. STACK_SHRINK(oparg);
  4113. STACK_SHRINK(1);
  4114. stack_pointer[-1] = res;
  4115. next_instr += 3;
  4116. CHECK_EVAL_BREAKER();
  4117. DISPATCH();
  4118. }
  4119. TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS) {
  4120. PyObject **args = (stack_pointer - oparg);
  4121. PyObject *method = stack_pointer[-(2 + oparg)];
  4122. PyObject *res;
  4123. #line 3137 "Python/bytecodes.c"
  4124. assert(kwnames == NULL);
  4125. assert(oparg == 0 || oparg == 1);
  4126. int is_meth = method != NULL;
  4127. int total_args = oparg;
  4128. if (is_meth) {
  4129. args--;
  4130. total_args++;
  4131. }
  4132. DEOPT_IF(total_args != 1, CALL);
  4133. PyMethodDescrObject *callable = (PyMethodDescrObject *)SECOND();
  4134. DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
  4135. PyMethodDef *meth = callable->d_method;
  4136. PyObject *self = args[0];
  4137. DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
  4138. DEOPT_IF(meth->ml_flags != METH_NOARGS, CALL);
  4139. STAT_INC(CALL, hit);
  4140. PyCFunction cfunc = meth->ml_meth;
  4141. // This is slower but CPython promises to check all non-vectorcall
  4142. // function calls.
  4143. if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
  4144. goto error;
  4145. }
  4146. res = _PyCFunction_TrampolineCall(cfunc, self, NULL);
  4147. _Py_LeaveRecursiveCallTstate(tstate);
  4148. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  4149. Py_DECREF(self);
  4150. Py_DECREF(callable);
  4151. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  4152. #line 4368 "Python/generated_cases.c.h"
  4153. STACK_SHRINK(oparg);
  4154. STACK_SHRINK(1);
  4155. stack_pointer[-1] = res;
  4156. next_instr += 3;
  4157. CHECK_EVAL_BREAKER();
  4158. DISPATCH();
  4159. }
  4160. TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_FAST) {
  4161. PyObject **args = (stack_pointer - oparg);
  4162. PyObject *method = stack_pointer[-(2 + oparg)];
  4163. PyObject *res;
  4164. #line 3169 "Python/bytecodes.c"
  4165. assert(kwnames == NULL);
  4166. int is_meth = method != NULL;
  4167. int total_args = oparg;
  4168. if (is_meth) {
  4169. args--;
  4170. total_args++;
  4171. }
  4172. PyMethodDescrObject *callable =
  4173. (PyMethodDescrObject *)PEEK(total_args + 1);
  4174. /* Builtin METH_FASTCALL methods, without keywords */
  4175. DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
  4176. PyMethodDef *meth = callable->d_method;
  4177. DEOPT_IF(meth->ml_flags != METH_FASTCALL, CALL);
  4178. PyObject *self = args[0];
  4179. DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
  4180. STAT_INC(CALL, hit);
  4181. _PyCFunctionFast cfunc =
  4182. (_PyCFunctionFast)(void(*)(void))meth->ml_meth;
  4183. int nargs = total_args - 1;
  4184. res = cfunc(self, args + 1, nargs);
  4185. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  4186. /* Clear the stack of the arguments. */
  4187. for (int i = 0; i < total_args; i++) {
  4188. Py_DECREF(args[i]);
  4189. }
  4190. Py_DECREF(callable);
  4191. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  4192. #line 4409 "Python/generated_cases.c.h"
  4193. STACK_SHRINK(oparg);
  4194. STACK_SHRINK(1);
  4195. stack_pointer[-1] = res;
  4196. next_instr += 3;
  4197. CHECK_EVAL_BREAKER();
  4198. DISPATCH();
  4199. }
  4200. TARGET(INSTRUMENTED_CALL_FUNCTION_EX) {
  4201. #line 3200 "Python/bytecodes.c"
  4202. GO_TO_INSTRUCTION(CALL_FUNCTION_EX);
  4203. #line 4421 "Python/generated_cases.c.h"
  4204. }
  4205. TARGET(CALL_FUNCTION_EX) {
  4206. PREDICTED(CALL_FUNCTION_EX);
  4207. PyObject *kwargs = (oparg & 1) ? stack_pointer[-(((oparg & 1) ? 1 : 0))] : NULL;
  4208. PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))];
  4209. PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))];
  4210. PyObject *result;
  4211. #line 3204 "Python/bytecodes.c"
  4212. // DICT_MERGE is called before this opcode if there are kwargs.
  4213. // It converts all dict subtypes in kwargs into regular dicts.
  4214. assert(kwargs == NULL || PyDict_CheckExact(kwargs));
  4215. if (!PyTuple_CheckExact(callargs)) {
  4216. if (check_args_iterable(tstate, func, callargs) < 0) {
  4217. goto error;
  4218. }
  4219. PyObject *tuple = PySequence_Tuple(callargs);
  4220. if (tuple == NULL) {
  4221. goto error;
  4222. }
  4223. Py_SETREF(callargs, tuple);
  4224. }
  4225. assert(PyTuple_CheckExact(callargs));
  4226. EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
  4227. if (opcode == INSTRUMENTED_CALL_FUNCTION_EX) {
  4228. PyObject *arg = PyTuple_GET_SIZE(callargs) > 0 ?
  4229. PyTuple_GET_ITEM(callargs, 0) : &_PyInstrumentation_MISSING;
  4230. int err = _Py_call_instrumentation_2args(
  4231. tstate, PY_MONITORING_EVENT_CALL,
  4232. frame, next_instr-1, func, arg);
  4233. if (err) goto error;
  4234. result = PyObject_Call(func, callargs, kwargs);
  4235. if (!PyFunction_Check(func) && !PyMethod_Check(func)) {
  4236. if (result == NULL) {
  4237. _Py_call_instrumentation_exc2(
  4238. tstate, PY_MONITORING_EVENT_C_RAISE,
  4239. frame, next_instr-1, func, arg);
  4240. }
  4241. else {
  4242. int err = _Py_call_instrumentation_2args(
  4243. tstate, PY_MONITORING_EVENT_C_RETURN,
  4244. frame, next_instr-1, func, arg);
  4245. if (err < 0) {
  4246. Py_CLEAR(result);
  4247. }
  4248. }
  4249. }
  4250. }
  4251. else {
  4252. if (Py_TYPE(func) == &PyFunction_Type &&
  4253. tstate->interp->eval_frame == NULL &&
  4254. ((PyFunctionObject *)func)->vectorcall == _PyFunction_Vectorcall) {
  4255. assert(PyTuple_CheckExact(callargs));
  4256. Py_ssize_t nargs = PyTuple_GET_SIZE(callargs);
  4257. int code_flags = ((PyCodeObject *)PyFunction_GET_CODE(func))->co_flags;
  4258. PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(func));
  4259. _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit_Ex(tstate,
  4260. (PyFunctionObject *)func, locals,
  4261. nargs, callargs, kwargs);
  4262. // Need to manually shrink the stack since we exit with DISPATCH_INLINED.
  4263. STACK_SHRINK(oparg + 3);
  4264. if (new_frame == NULL) {
  4265. goto error;
  4266. }
  4267. frame->return_offset = 0;
  4268. DISPATCH_INLINED(new_frame);
  4269. }
  4270. result = PyObject_Call(func, callargs, kwargs);
  4271. }
  4272. #line 4492 "Python/generated_cases.c.h"
  4273. Py_DECREF(func);
  4274. Py_DECREF(callargs);
  4275. Py_XDECREF(kwargs);
  4276. #line 3266 "Python/bytecodes.c"
  4277. assert(PEEK(3 + (oparg & 1)) == NULL);
  4278. if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; }
  4279. #line 4499 "Python/generated_cases.c.h"
  4280. STACK_SHRINK(((oparg & 1) ? 1 : 0));
  4281. STACK_SHRINK(2);
  4282. stack_pointer[-1] = result;
  4283. CHECK_EVAL_BREAKER();
  4284. DISPATCH();
  4285. }
  4286. TARGET(MAKE_FUNCTION) {
  4287. PyObject *codeobj = stack_pointer[-1];
  4288. PyObject *closure = (oparg & 0x08) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0))] : NULL;
  4289. PyObject *annotations = (oparg & 0x04) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0))] : NULL;
  4290. PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL;
  4291. PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL;
  4292. PyObject *func;
  4293. #line 3276 "Python/bytecodes.c"
  4294. PyFunctionObject *func_obj = (PyFunctionObject *)
  4295. PyFunction_New(codeobj, GLOBALS());
  4296. Py_DECREF(codeobj);
  4297. if (func_obj == NULL) {
  4298. goto error;
  4299. }
  4300. if (oparg & 0x08) {
  4301. assert(PyTuple_CheckExact(closure));
  4302. func_obj->func_closure = closure;
  4303. }
  4304. if (oparg & 0x04) {
  4305. assert(PyTuple_CheckExact(annotations));
  4306. func_obj->func_annotations = annotations;
  4307. }
  4308. if (oparg & 0x02) {
  4309. assert(PyDict_CheckExact(kwdefaults));
  4310. func_obj->func_kwdefaults = kwdefaults;
  4311. }
  4312. if (oparg & 0x01) {
  4313. assert(PyTuple_CheckExact(defaults));
  4314. func_obj->func_defaults = defaults;
  4315. }
  4316. func_obj->func_version = ((PyCodeObject *)codeobj)->co_version;
  4317. func = (PyObject *)func_obj;
  4318. #line 4543 "Python/generated_cases.c.h"
  4319. STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0));
  4320. stack_pointer[-1] = func;
  4321. DISPATCH();
  4322. }
  4323. TARGET(RETURN_GENERATOR) {
  4324. #line 3307 "Python/bytecodes.c"
  4325. assert(PyFunction_Check(frame->f_funcobj));
  4326. PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj;
  4327. PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func);
  4328. if (gen == NULL) {
  4329. goto error;
  4330. }
  4331. assert(EMPTY());
  4332. _PyFrame_SetStackPointer(frame, stack_pointer);
  4333. _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
  4334. _PyFrame_Copy(frame, gen_frame);
  4335. assert(frame->frame_obj == NULL);
  4336. gen->gi_frame_state = FRAME_CREATED;
  4337. gen_frame->owner = FRAME_OWNED_BY_GENERATOR;
  4338. _Py_LeaveRecursiveCallPy(tstate);
  4339. assert(frame != &entry_frame);
  4340. _PyInterpreterFrame *prev = frame->previous;
  4341. _PyThreadState_PopFrame(tstate, frame);
  4342. frame = cframe.current_frame = prev;
  4343. _PyFrame_StackPush(frame, (PyObject *)gen);
  4344. goto resume_frame;
  4345. #line 4571 "Python/generated_cases.c.h"
  4346. }
  4347. TARGET(BUILD_SLICE) {
  4348. PyObject *step = (oparg == 3) ? stack_pointer[-(((oparg == 3) ? 1 : 0))] : NULL;
  4349. PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))];
  4350. PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))];
  4351. PyObject *slice;
  4352. #line 3330 "Python/bytecodes.c"
  4353. slice = PySlice_New(start, stop, step);
  4354. #line 4581 "Python/generated_cases.c.h"
  4355. Py_DECREF(start);
  4356. Py_DECREF(stop);
  4357. Py_XDECREF(step);
  4358. #line 3332 "Python/bytecodes.c"
  4359. if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; }
  4360. #line 4587 "Python/generated_cases.c.h"
  4361. STACK_SHRINK(((oparg == 3) ? 1 : 0));
  4362. STACK_SHRINK(1);
  4363. stack_pointer[-1] = slice;
  4364. DISPATCH();
  4365. }
  4366. TARGET(FORMAT_VALUE) {
  4367. PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL;
  4368. PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))];
  4369. PyObject *result;
  4370. #line 3336 "Python/bytecodes.c"
  4371. /* Handles f-string value formatting. */
  4372. PyObject *(*conv_fn)(PyObject *);
  4373. int which_conversion = oparg & FVC_MASK;
  4374. /* See if any conversion is specified. */
  4375. switch (which_conversion) {
  4376. case FVC_NONE: conv_fn = NULL; break;
  4377. case FVC_STR: conv_fn = PyObject_Str; break;
  4378. case FVC_REPR: conv_fn = PyObject_Repr; break;
  4379. case FVC_ASCII: conv_fn = PyObject_ASCII; break;
  4380. default:
  4381. _PyErr_Format(tstate, PyExc_SystemError,
  4382. "unexpected conversion flag %d",
  4383. which_conversion);
  4384. goto error;
  4385. }
  4386. /* If there's a conversion function, call it and replace
  4387. value with that result. Otherwise, just use value,
  4388. without conversion. */
  4389. if (conv_fn != NULL) {
  4390. result = conv_fn(value);
  4391. Py_DECREF(value);
  4392. if (result == NULL) {
  4393. Py_XDECREF(fmt_spec);
  4394. if (true) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; }
  4395. }
  4396. value = result;
  4397. }
  4398. result = PyObject_Format(value, fmt_spec);
  4399. Py_DECREF(value);
  4400. Py_XDECREF(fmt_spec);
  4401. if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; }
  4402. #line 4633 "Python/generated_cases.c.h"
  4403. STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0));
  4404. stack_pointer[-1] = result;
  4405. DISPATCH();
  4406. }
  4407. TARGET(COPY) {
  4408. PyObject *bottom = stack_pointer[-(1 + (oparg-1))];
  4409. PyObject *top;
  4410. #line 3373 "Python/bytecodes.c"
  4411. assert(oparg > 0);
  4412. top = Py_NewRef(bottom);
  4413. #line 4645 "Python/generated_cases.c.h"
  4414. STACK_GROW(1);
  4415. stack_pointer[-1] = top;
  4416. DISPATCH();
  4417. }
  4418. TARGET(BINARY_OP) {
  4419. PREDICTED(BINARY_OP);
  4420. static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 1, "incorrect cache size");
  4421. PyObject *rhs = stack_pointer[-1];
  4422. PyObject *lhs = stack_pointer[-2];
  4423. PyObject *res;
  4424. #line 3378 "Python/bytecodes.c"
  4425. #if ENABLE_SPECIALIZATION
  4426. _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
  4427. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  4428. next_instr--;
  4429. _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, &GETLOCAL(0));
  4430. DISPATCH_SAME_OPARG();
  4431. }
  4432. STAT_INC(BINARY_OP, deferred);
  4433. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  4434. #endif /* ENABLE_SPECIALIZATION */
  4435. assert(0 <= oparg);
  4436. assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops));
  4437. assert(binary_ops[oparg]);
  4438. res = binary_ops[oparg](lhs, rhs);
  4439. #line 4672 "Python/generated_cases.c.h"
  4440. Py_DECREF(lhs);
  4441. Py_DECREF(rhs);
  4442. #line 3393 "Python/bytecodes.c"
  4443. if (res == NULL) goto pop_2_error;
  4444. #line 4677 "Python/generated_cases.c.h"
  4445. STACK_SHRINK(1);
  4446. stack_pointer[-1] = res;
  4447. next_instr += 1;
  4448. DISPATCH();
  4449. }
  4450. TARGET(SWAP) {
  4451. PyObject *top = stack_pointer[-1];
  4452. PyObject *bottom = stack_pointer[-(2 + (oparg-2))];
  4453. #line 3398 "Python/bytecodes.c"
  4454. assert(oparg >= 2);
  4455. #line 4689 "Python/generated_cases.c.h"
  4456. stack_pointer[-1] = bottom;
  4457. stack_pointer[-(2 + (oparg-2))] = top;
  4458. DISPATCH();
  4459. }
  4460. TARGET(INSTRUMENTED_INSTRUCTION) {
  4461. #line 3402 "Python/bytecodes.c"
  4462. int next_opcode = _Py_call_instrumentation_instruction(
  4463. tstate, frame, next_instr-1);
  4464. if (next_opcode < 0) goto error;
  4465. next_instr--;
  4466. if (_PyOpcode_Caches[next_opcode]) {
  4467. _PyBinaryOpCache *cache = (_PyBinaryOpCache *)(next_instr+1);
  4468. INCREMENT_ADAPTIVE_COUNTER(cache->counter);
  4469. }
  4470. assert(next_opcode > 0 && next_opcode < 256);
  4471. opcode = next_opcode;
  4472. DISPATCH_GOTO();
  4473. #line 4708 "Python/generated_cases.c.h"
  4474. }
  4475. TARGET(INSTRUMENTED_JUMP_FORWARD) {
  4476. #line 3416 "Python/bytecodes.c"
  4477. INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP);
  4478. #line 4714 "Python/generated_cases.c.h"
  4479. DISPATCH();
  4480. }
  4481. TARGET(INSTRUMENTED_JUMP_BACKWARD) {
  4482. #line 3420 "Python/bytecodes.c"
  4483. INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP);
  4484. #line 4721 "Python/generated_cases.c.h"
  4485. CHECK_EVAL_BREAKER();
  4486. DISPATCH();
  4487. }
  4488. TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) {
  4489. #line 3425 "Python/bytecodes.c"
  4490. PyObject *cond = POP();
  4491. int err = PyObject_IsTrue(cond);
  4492. Py_DECREF(cond);
  4493. if (err < 0) goto error;
  4494. _Py_CODEUNIT *here = next_instr-1;
  4495. assert(err == 0 || err == 1);
  4496. int offset = err*oparg;
  4497. INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
  4498. #line 4736 "Python/generated_cases.c.h"
  4499. DISPATCH();
  4500. }
  4501. TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) {
  4502. #line 3436 "Python/bytecodes.c"
  4503. PyObject *cond = POP();
  4504. int err = PyObject_IsTrue(cond);
  4505. Py_DECREF(cond);
  4506. if (err < 0) goto error;
  4507. _Py_CODEUNIT *here = next_instr-1;
  4508. assert(err == 0 || err == 1);
  4509. int offset = (1-err)*oparg;
  4510. INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
  4511. #line 4750 "Python/generated_cases.c.h"
  4512. DISPATCH();
  4513. }
  4514. TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) {
  4515. #line 3447 "Python/bytecodes.c"
  4516. PyObject *value = POP();
  4517. _Py_CODEUNIT *here = next_instr-1;
  4518. int offset;
  4519. if (Py_IsNone(value)) {
  4520. offset = oparg;
  4521. }
  4522. else {
  4523. Py_DECREF(value);
  4524. offset = 0;
  4525. }
  4526. INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
  4527. #line 4767 "Python/generated_cases.c.h"
  4528. DISPATCH();
  4529. }
  4530. TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) {
  4531. #line 3461 "Python/bytecodes.c"
  4532. PyObject *value = POP();
  4533. _Py_CODEUNIT *here = next_instr-1;
  4534. int offset;
  4535. if (Py_IsNone(value)) {
  4536. offset = 0;
  4537. }
  4538. else {
  4539. Py_DECREF(value);
  4540. offset = oparg;
  4541. }
  4542. INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
  4543. #line 4784 "Python/generated_cases.c.h"
  4544. DISPATCH();
  4545. }
  4546. TARGET(EXTENDED_ARG) {
  4547. #line 3475 "Python/bytecodes.c"
  4548. assert(oparg);
  4549. opcode = next_instr->op.code;
  4550. oparg = oparg << 8 | next_instr->op.arg;
  4551. PRE_DISPATCH_GOTO();
  4552. DISPATCH_GOTO();
  4553. #line 4795 "Python/generated_cases.c.h"
  4554. }
  4555. TARGET(CACHE) {
  4556. #line 3483 "Python/bytecodes.c"
  4557. assert(0 && "Executing a cache.");
  4558. Py_UNREACHABLE();
  4559. #line 4802 "Python/generated_cases.c.h"
  4560. }
  4561. TARGET(RESERVED) {
  4562. #line 3488 "Python/bytecodes.c"
  4563. assert(0 && "Executing RESERVED instruction.");
  4564. Py_UNREACHABLE();
  4565. #line 4809 "Python/generated_cases.c.h"
  4566. }