generated_cases.c.h 190 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800
  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. v = PyDict_GetItemWithError(GLOBALS(), name);
  1565. if (v != NULL) {
  1566. Py_INCREF(v);
  1567. }
  1568. else if (_PyErr_Occurred(tstate)) {
  1569. goto error;
  1570. }
  1571. else {
  1572. if (PyDict_CheckExact(BUILTINS())) {
  1573. v = PyDict_GetItemWithError(BUILTINS(), name);
  1574. if (v == NULL) {
  1575. if (!_PyErr_Occurred(tstate)) {
  1576. format_exc_check_arg(
  1577. tstate, PyExc_NameError,
  1578. NAME_ERROR_MSG, name);
  1579. }
  1580. goto error;
  1581. }
  1582. Py_INCREF(v);
  1583. }
  1584. else {
  1585. v = PyObject_GetItem(BUILTINS(), name);
  1586. if (v == NULL) {
  1587. if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1588. format_exc_check_arg(
  1589. tstate, PyExc_NameError,
  1590. NAME_ERROR_MSG, name);
  1591. }
  1592. goto error;
  1593. }
  1594. }
  1595. }
  1596. }
  1597. #line 1695 "Python/generated_cases.c.h"
  1598. Py_DECREF(mod_or_class_dict);
  1599. stack_pointer[-1] = v;
  1600. DISPATCH();
  1601. }
  1602. TARGET(LOAD_NAME) {
  1603. PyObject *v;
  1604. #line 1236 "Python/bytecodes.c"
  1605. PyObject *mod_or_class_dict = LOCALS();
  1606. if (mod_or_class_dict == NULL) {
  1607. _PyErr_SetString(tstate, PyExc_SystemError,
  1608. "no locals found");
  1609. if (true) goto error;
  1610. }
  1611. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  1612. if (PyDict_CheckExact(mod_or_class_dict)) {
  1613. v = PyDict_GetItemWithError(mod_or_class_dict, name);
  1614. if (v != NULL) {
  1615. Py_INCREF(v);
  1616. }
  1617. else if (_PyErr_Occurred(tstate)) {
  1618. goto error;
  1619. }
  1620. }
  1621. else {
  1622. v = PyObject_GetItem(mod_or_class_dict, name);
  1623. if (v == NULL) {
  1624. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1625. goto error;
  1626. }
  1627. _PyErr_Clear(tstate);
  1628. }
  1629. }
  1630. if (v == NULL) {
  1631. v = PyDict_GetItemWithError(GLOBALS(), name);
  1632. if (v != NULL) {
  1633. Py_INCREF(v);
  1634. }
  1635. else if (_PyErr_Occurred(tstate)) {
  1636. goto error;
  1637. }
  1638. else {
  1639. if (PyDict_CheckExact(BUILTINS())) {
  1640. v = PyDict_GetItemWithError(BUILTINS(), name);
  1641. if (v == NULL) {
  1642. if (!_PyErr_Occurred(tstate)) {
  1643. format_exc_check_arg(
  1644. tstate, PyExc_NameError,
  1645. NAME_ERROR_MSG, name);
  1646. }
  1647. goto error;
  1648. }
  1649. Py_INCREF(v);
  1650. }
  1651. else {
  1652. v = PyObject_GetItem(BUILTINS(), name);
  1653. if (v == NULL) {
  1654. if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1655. format_exc_check_arg(
  1656. tstate, PyExc_NameError,
  1657. NAME_ERROR_MSG, name);
  1658. }
  1659. goto error;
  1660. }
  1661. }
  1662. }
  1663. }
  1664. #line 1763 "Python/generated_cases.c.h"
  1665. STACK_GROW(1);
  1666. stack_pointer[-1] = v;
  1667. DISPATCH();
  1668. }
  1669. TARGET(LOAD_GLOBAL) {
  1670. PREDICTED(LOAD_GLOBAL);
  1671. static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
  1672. PyObject *null = NULL;
  1673. PyObject *v;
  1674. #line 1304 "Python/bytecodes.c"
  1675. #if ENABLE_SPECIALIZATION
  1676. _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
  1677. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  1678. PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
  1679. next_instr--;
  1680. _Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name);
  1681. DISPATCH_SAME_OPARG();
  1682. }
  1683. STAT_INC(LOAD_GLOBAL, deferred);
  1684. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  1685. #endif /* ENABLE_SPECIALIZATION */
  1686. PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
  1687. if (PyDict_CheckExact(GLOBALS())
  1688. && PyDict_CheckExact(BUILTINS()))
  1689. {
  1690. v = _PyDict_LoadGlobal((PyDictObject *)GLOBALS(),
  1691. (PyDictObject *)BUILTINS(),
  1692. name);
  1693. if (v == NULL) {
  1694. if (!_PyErr_Occurred(tstate)) {
  1695. /* _PyDict_LoadGlobal() returns NULL without raising
  1696. * an exception if the key doesn't exist */
  1697. format_exc_check_arg(tstate, PyExc_NameError,
  1698. NAME_ERROR_MSG, name);
  1699. }
  1700. if (true) goto error;
  1701. }
  1702. Py_INCREF(v);
  1703. }
  1704. else {
  1705. /* Slow-path if globals or builtins is not a dict */
  1706. /* namespace 1: globals */
  1707. v = PyObject_GetItem(GLOBALS(), name);
  1708. if (v == NULL) {
  1709. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error;
  1710. _PyErr_Clear(tstate);
  1711. /* namespace 2: builtins */
  1712. v = PyObject_GetItem(BUILTINS(), name);
  1713. if (v == NULL) {
  1714. if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1715. format_exc_check_arg(
  1716. tstate, PyExc_NameError,
  1717. NAME_ERROR_MSG, name);
  1718. }
  1719. if (true) goto error;
  1720. }
  1721. }
  1722. }
  1723. null = NULL;
  1724. #line 1826 "Python/generated_cases.c.h"
  1725. STACK_GROW(1);
  1726. STACK_GROW(((oparg & 1) ? 1 : 0));
  1727. stack_pointer[-1] = v;
  1728. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
  1729. next_instr += 4;
  1730. DISPATCH();
  1731. }
  1732. TARGET(LOAD_GLOBAL_MODULE) {
  1733. PyObject *null = NULL;
  1734. PyObject *res;
  1735. uint16_t index = read_u16(&next_instr[1].cache);
  1736. uint16_t version = read_u16(&next_instr[2].cache);
  1737. #line 1358 "Python/bytecodes.c"
  1738. DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
  1739. PyDictObject *dict = (PyDictObject *)GLOBALS();
  1740. DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL);
  1741. assert(DK_IS_UNICODE(dict->ma_keys));
  1742. PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(dict->ma_keys);
  1743. res = entries[index].me_value;
  1744. DEOPT_IF(res == NULL, LOAD_GLOBAL);
  1745. Py_INCREF(res);
  1746. STAT_INC(LOAD_GLOBAL, hit);
  1747. null = NULL;
  1748. #line 1851 "Python/generated_cases.c.h"
  1749. STACK_GROW(1);
  1750. STACK_GROW(((oparg & 1) ? 1 : 0));
  1751. stack_pointer[-1] = res;
  1752. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
  1753. next_instr += 4;
  1754. DISPATCH();
  1755. }
  1756. TARGET(LOAD_GLOBAL_BUILTIN) {
  1757. PyObject *null = NULL;
  1758. PyObject *res;
  1759. uint16_t index = read_u16(&next_instr[1].cache);
  1760. uint16_t mod_version = read_u16(&next_instr[2].cache);
  1761. uint16_t bltn_version = read_u16(&next_instr[3].cache);
  1762. #line 1371 "Python/bytecodes.c"
  1763. DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
  1764. DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL);
  1765. PyDictObject *mdict = (PyDictObject *)GLOBALS();
  1766. PyDictObject *bdict = (PyDictObject *)BUILTINS();
  1767. assert(opcode == LOAD_GLOBAL_BUILTIN);
  1768. DEOPT_IF(mdict->ma_keys->dk_version != mod_version, LOAD_GLOBAL);
  1769. DEOPT_IF(bdict->ma_keys->dk_version != bltn_version, LOAD_GLOBAL);
  1770. assert(DK_IS_UNICODE(bdict->ma_keys));
  1771. PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(bdict->ma_keys);
  1772. res = entries[index].me_value;
  1773. DEOPT_IF(res == NULL, LOAD_GLOBAL);
  1774. Py_INCREF(res);
  1775. STAT_INC(LOAD_GLOBAL, hit);
  1776. null = NULL;
  1777. #line 1881 "Python/generated_cases.c.h"
  1778. STACK_GROW(1);
  1779. STACK_GROW(((oparg & 1) ? 1 : 0));
  1780. stack_pointer[-1] = res;
  1781. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
  1782. next_instr += 4;
  1783. DISPATCH();
  1784. }
  1785. TARGET(DELETE_FAST) {
  1786. #line 1388 "Python/bytecodes.c"
  1787. PyObject *v = GETLOCAL(oparg);
  1788. if (v == NULL) goto unbound_local_error;
  1789. SETLOCAL(oparg, NULL);
  1790. #line 1895 "Python/generated_cases.c.h"
  1791. DISPATCH();
  1792. }
  1793. TARGET(MAKE_CELL) {
  1794. #line 1394 "Python/bytecodes.c"
  1795. // "initial" is probably NULL but not if it's an arg (or set
  1796. // via PyFrame_LocalsToFast() before MAKE_CELL has run).
  1797. PyObject *initial = GETLOCAL(oparg);
  1798. PyObject *cell = PyCell_New(initial);
  1799. if (cell == NULL) {
  1800. goto resume_with_error;
  1801. }
  1802. SETLOCAL(oparg, cell);
  1803. #line 1909 "Python/generated_cases.c.h"
  1804. DISPATCH();
  1805. }
  1806. TARGET(DELETE_DEREF) {
  1807. #line 1405 "Python/bytecodes.c"
  1808. PyObject *cell = GETLOCAL(oparg);
  1809. PyObject *oldobj = PyCell_GET(cell);
  1810. // Can't use ERROR_IF here.
  1811. // Fortunately we don't need its superpower.
  1812. if (oldobj == NULL) {
  1813. format_exc_unbound(tstate, frame->f_code, oparg);
  1814. goto error;
  1815. }
  1816. PyCell_SET(cell, NULL);
  1817. Py_DECREF(oldobj);
  1818. #line 1925 "Python/generated_cases.c.h"
  1819. DISPATCH();
  1820. }
  1821. TARGET(LOAD_FROM_DICT_OR_DEREF) {
  1822. PyObject *class_dict = stack_pointer[-1];
  1823. PyObject *value;
  1824. #line 1418 "Python/bytecodes.c"
  1825. PyObject *name;
  1826. assert(class_dict);
  1827. assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus);
  1828. name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg);
  1829. if (PyDict_CheckExact(class_dict)) {
  1830. value = PyDict_GetItemWithError(class_dict, name);
  1831. if (value != NULL) {
  1832. Py_INCREF(value);
  1833. }
  1834. else if (_PyErr_Occurred(tstate)) {
  1835. goto error;
  1836. }
  1837. }
  1838. else {
  1839. value = PyObject_GetItem(class_dict, name);
  1840. if (value == NULL) {
  1841. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
  1842. goto error;
  1843. }
  1844. _PyErr_Clear(tstate);
  1845. }
  1846. }
  1847. if (!value) {
  1848. PyObject *cell = GETLOCAL(oparg);
  1849. value = PyCell_GET(cell);
  1850. if (value == NULL) {
  1851. format_exc_unbound(tstate, frame->f_code, oparg);
  1852. goto error;
  1853. }
  1854. Py_INCREF(value);
  1855. }
  1856. Py_DECREF(class_dict);
  1857. #line 1965 "Python/generated_cases.c.h"
  1858. stack_pointer[-1] = value;
  1859. DISPATCH();
  1860. }
  1861. TARGET(LOAD_DEREF) {
  1862. PyObject *value;
  1863. #line 1453 "Python/bytecodes.c"
  1864. PyObject *cell = GETLOCAL(oparg);
  1865. value = PyCell_GET(cell);
  1866. if (value == NULL) {
  1867. format_exc_unbound(tstate, frame->f_code, oparg);
  1868. if (true) goto error;
  1869. }
  1870. Py_INCREF(value);
  1871. #line 1980 "Python/generated_cases.c.h"
  1872. STACK_GROW(1);
  1873. stack_pointer[-1] = value;
  1874. DISPATCH();
  1875. }
  1876. TARGET(STORE_DEREF) {
  1877. PyObject *v = stack_pointer[-1];
  1878. #line 1463 "Python/bytecodes.c"
  1879. PyObject *cell = GETLOCAL(oparg);
  1880. PyObject *oldobj = PyCell_GET(cell);
  1881. PyCell_SET(cell, v);
  1882. Py_XDECREF(oldobj);
  1883. #line 1993 "Python/generated_cases.c.h"
  1884. STACK_SHRINK(1);
  1885. DISPATCH();
  1886. }
  1887. TARGET(COPY_FREE_VARS) {
  1888. #line 1470 "Python/bytecodes.c"
  1889. /* Copy closure variables to free variables */
  1890. PyCodeObject *co = frame->f_code;
  1891. assert(PyFunction_Check(frame->f_funcobj));
  1892. PyObject *closure = ((PyFunctionObject *)frame->f_funcobj)->func_closure;
  1893. assert(oparg == co->co_nfreevars);
  1894. int offset = co->co_nlocalsplus - oparg;
  1895. for (int i = 0; i < oparg; ++i) {
  1896. PyObject *o = PyTuple_GET_ITEM(closure, i);
  1897. frame->localsplus[offset + i] = Py_NewRef(o);
  1898. }
  1899. #line 2010 "Python/generated_cases.c.h"
  1900. DISPATCH();
  1901. }
  1902. TARGET(BUILD_STRING) {
  1903. PyObject **pieces = (stack_pointer - oparg);
  1904. PyObject *str;
  1905. #line 1483 "Python/bytecodes.c"
  1906. str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg);
  1907. #line 2019 "Python/generated_cases.c.h"
  1908. for (int _i = oparg; --_i >= 0;) {
  1909. Py_DECREF(pieces[_i]);
  1910. }
  1911. #line 1485 "Python/bytecodes.c"
  1912. if (str == NULL) { STACK_SHRINK(oparg); goto error; }
  1913. #line 2025 "Python/generated_cases.c.h"
  1914. STACK_SHRINK(oparg);
  1915. STACK_GROW(1);
  1916. stack_pointer[-1] = str;
  1917. DISPATCH();
  1918. }
  1919. TARGET(BUILD_TUPLE) {
  1920. PyObject **values = (stack_pointer - oparg);
  1921. PyObject *tup;
  1922. #line 1489 "Python/bytecodes.c"
  1923. tup = _PyTuple_FromArraySteal(values, oparg);
  1924. if (tup == NULL) { STACK_SHRINK(oparg); goto error; }
  1925. #line 2038 "Python/generated_cases.c.h"
  1926. STACK_SHRINK(oparg);
  1927. STACK_GROW(1);
  1928. stack_pointer[-1] = tup;
  1929. DISPATCH();
  1930. }
  1931. TARGET(BUILD_LIST) {
  1932. PyObject **values = (stack_pointer - oparg);
  1933. PyObject *list;
  1934. #line 1494 "Python/bytecodes.c"
  1935. list = _PyList_FromArraySteal(values, oparg);
  1936. if (list == NULL) { STACK_SHRINK(oparg); goto error; }
  1937. #line 2051 "Python/generated_cases.c.h"
  1938. STACK_SHRINK(oparg);
  1939. STACK_GROW(1);
  1940. stack_pointer[-1] = list;
  1941. DISPATCH();
  1942. }
  1943. TARGET(LIST_EXTEND) {
  1944. PyObject *iterable = stack_pointer[-1];
  1945. PyObject *list = stack_pointer[-(2 + (oparg-1))];
  1946. #line 1499 "Python/bytecodes.c"
  1947. PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable);
  1948. if (none_val == NULL) {
  1949. if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) &&
  1950. (Py_TYPE(iterable)->tp_iter == NULL && !PySequence_Check(iterable)))
  1951. {
  1952. _PyErr_Clear(tstate);
  1953. _PyErr_Format(tstate, PyExc_TypeError,
  1954. "Value after * must be an iterable, not %.200s",
  1955. Py_TYPE(iterable)->tp_name);
  1956. }
  1957. #line 2072 "Python/generated_cases.c.h"
  1958. Py_DECREF(iterable);
  1959. #line 1510 "Python/bytecodes.c"
  1960. if (true) goto pop_1_error;
  1961. }
  1962. assert(Py_IsNone(none_val));
  1963. #line 2078 "Python/generated_cases.c.h"
  1964. Py_DECREF(iterable);
  1965. STACK_SHRINK(1);
  1966. DISPATCH();
  1967. }
  1968. TARGET(SET_UPDATE) {
  1969. PyObject *iterable = stack_pointer[-1];
  1970. PyObject *set = stack_pointer[-(2 + (oparg-1))];
  1971. #line 1517 "Python/bytecodes.c"
  1972. int err = _PySet_Update(set, iterable);
  1973. #line 2089 "Python/generated_cases.c.h"
  1974. Py_DECREF(iterable);
  1975. #line 1519 "Python/bytecodes.c"
  1976. if (err < 0) goto pop_1_error;
  1977. #line 2093 "Python/generated_cases.c.h"
  1978. STACK_SHRINK(1);
  1979. DISPATCH();
  1980. }
  1981. TARGET(BUILD_SET) {
  1982. PyObject **values = (stack_pointer - oparg);
  1983. PyObject *set;
  1984. #line 1523 "Python/bytecodes.c"
  1985. set = PySet_New(NULL);
  1986. if (set == NULL)
  1987. goto error;
  1988. int err = 0;
  1989. for (int i = 0; i < oparg; i++) {
  1990. PyObject *item = values[i];
  1991. if (err == 0)
  1992. err = PySet_Add(set, item);
  1993. Py_DECREF(item);
  1994. }
  1995. if (err != 0) {
  1996. Py_DECREF(set);
  1997. if (true) { STACK_SHRINK(oparg); goto error; }
  1998. }
  1999. #line 2116 "Python/generated_cases.c.h"
  2000. STACK_SHRINK(oparg);
  2001. STACK_GROW(1);
  2002. stack_pointer[-1] = set;
  2003. DISPATCH();
  2004. }
  2005. TARGET(BUILD_MAP) {
  2006. PyObject **values = (stack_pointer - oparg*2);
  2007. PyObject *map;
  2008. #line 1540 "Python/bytecodes.c"
  2009. map = _PyDict_FromItems(
  2010. values, 2,
  2011. values+1, 2,
  2012. oparg);
  2013. #line 2131 "Python/generated_cases.c.h"
  2014. for (int _i = oparg*2; --_i >= 0;) {
  2015. Py_DECREF(values[_i]);
  2016. }
  2017. #line 1545 "Python/bytecodes.c"
  2018. if (map == NULL) { STACK_SHRINK(oparg*2); goto error; }
  2019. #line 2137 "Python/generated_cases.c.h"
  2020. STACK_SHRINK(oparg*2);
  2021. STACK_GROW(1);
  2022. stack_pointer[-1] = map;
  2023. DISPATCH();
  2024. }
  2025. TARGET(SETUP_ANNOTATIONS) {
  2026. #line 1549 "Python/bytecodes.c"
  2027. int err;
  2028. PyObject *ann_dict;
  2029. if (LOCALS() == NULL) {
  2030. _PyErr_Format(tstate, PyExc_SystemError,
  2031. "no locals found when setting up annotations");
  2032. if (true) goto error;
  2033. }
  2034. /* check if __annotations__ in locals()... */
  2035. if (PyDict_CheckExact(LOCALS())) {
  2036. ann_dict = _PyDict_GetItemWithError(LOCALS(),
  2037. &_Py_ID(__annotations__));
  2038. if (ann_dict == NULL) {
  2039. if (_PyErr_Occurred(tstate)) goto error;
  2040. /* ...if not, create a new one */
  2041. ann_dict = PyDict_New();
  2042. if (ann_dict == NULL) goto error;
  2043. err = PyDict_SetItem(LOCALS(), &_Py_ID(__annotations__),
  2044. ann_dict);
  2045. Py_DECREF(ann_dict);
  2046. if (err) goto error;
  2047. }
  2048. }
  2049. else {
  2050. /* do the same if locals() is not a dict */
  2051. ann_dict = PyObject_GetItem(LOCALS(), &_Py_ID(__annotations__));
  2052. if (ann_dict == NULL) {
  2053. if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error;
  2054. _PyErr_Clear(tstate);
  2055. ann_dict = PyDict_New();
  2056. if (ann_dict == NULL) goto error;
  2057. err = PyObject_SetItem(LOCALS(), &_Py_ID(__annotations__),
  2058. ann_dict);
  2059. Py_DECREF(ann_dict);
  2060. if (err) goto error;
  2061. }
  2062. else {
  2063. Py_DECREF(ann_dict);
  2064. }
  2065. }
  2066. #line 2185 "Python/generated_cases.c.h"
  2067. DISPATCH();
  2068. }
  2069. TARGET(BUILD_CONST_KEY_MAP) {
  2070. PyObject *keys = stack_pointer[-1];
  2071. PyObject **values = (stack_pointer - (1 + oparg));
  2072. PyObject *map;
  2073. #line 1591 "Python/bytecodes.c"
  2074. if (!PyTuple_CheckExact(keys) ||
  2075. PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) {
  2076. _PyErr_SetString(tstate, PyExc_SystemError,
  2077. "bad BUILD_CONST_KEY_MAP keys argument");
  2078. goto error; // Pop the keys and values.
  2079. }
  2080. map = _PyDict_FromItems(
  2081. &PyTuple_GET_ITEM(keys, 0), 1,
  2082. values, 1, oparg);
  2083. #line 2203 "Python/generated_cases.c.h"
  2084. for (int _i = oparg; --_i >= 0;) {
  2085. Py_DECREF(values[_i]);
  2086. }
  2087. Py_DECREF(keys);
  2088. #line 1601 "Python/bytecodes.c"
  2089. if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; }
  2090. #line 2210 "Python/generated_cases.c.h"
  2091. STACK_SHRINK(oparg);
  2092. stack_pointer[-1] = map;
  2093. DISPATCH();
  2094. }
  2095. TARGET(DICT_UPDATE) {
  2096. PyObject *update = stack_pointer[-1];
  2097. #line 1605 "Python/bytecodes.c"
  2098. PyObject *dict = PEEK(oparg + 1); // update is still on the stack
  2099. if (PyDict_Update(dict, update) < 0) {
  2100. if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) {
  2101. _PyErr_Format(tstate, PyExc_TypeError,
  2102. "'%.200s' object is not a mapping",
  2103. Py_TYPE(update)->tp_name);
  2104. }
  2105. #line 2226 "Python/generated_cases.c.h"
  2106. Py_DECREF(update);
  2107. #line 1613 "Python/bytecodes.c"
  2108. if (true) goto pop_1_error;
  2109. }
  2110. #line 2231 "Python/generated_cases.c.h"
  2111. Py_DECREF(update);
  2112. STACK_SHRINK(1);
  2113. DISPATCH();
  2114. }
  2115. TARGET(DICT_MERGE) {
  2116. PyObject *update = stack_pointer[-1];
  2117. #line 1619 "Python/bytecodes.c"
  2118. PyObject *dict = PEEK(oparg + 1); // update is still on the stack
  2119. if (_PyDict_MergeEx(dict, update, 2) < 0) {
  2120. format_kwargs_error(tstate, PEEK(3 + oparg), update);
  2121. #line 2244 "Python/generated_cases.c.h"
  2122. Py_DECREF(update);
  2123. #line 1624 "Python/bytecodes.c"
  2124. if (true) goto pop_1_error;
  2125. }
  2126. #line 2249 "Python/generated_cases.c.h"
  2127. Py_DECREF(update);
  2128. STACK_SHRINK(1);
  2129. PREDICT(CALL_FUNCTION_EX);
  2130. DISPATCH();
  2131. }
  2132. TARGET(MAP_ADD) {
  2133. PyObject *value = stack_pointer[-1];
  2134. PyObject *key = stack_pointer[-2];
  2135. #line 1631 "Python/bytecodes.c"
  2136. PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack
  2137. assert(PyDict_CheckExact(dict));
  2138. /* dict[key] = value */
  2139. // Do not DECREF INPUTS because the function steals the references
  2140. if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error;
  2141. #line 2265 "Python/generated_cases.c.h"
  2142. STACK_SHRINK(2);
  2143. PREDICT(JUMP_BACKWARD);
  2144. DISPATCH();
  2145. }
  2146. TARGET(INSTRUMENTED_LOAD_SUPER_ATTR) {
  2147. #line 1640 "Python/bytecodes.c"
  2148. _PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
  2149. // cancel out the decrement that will happen in LOAD_SUPER_ATTR; we
  2150. // don't want to specialize instrumented instructions
  2151. INCREMENT_ADAPTIVE_COUNTER(cache->counter);
  2152. GO_TO_INSTRUCTION(LOAD_SUPER_ATTR);
  2153. #line 2278 "Python/generated_cases.c.h"
  2154. }
  2155. TARGET(LOAD_SUPER_ATTR) {
  2156. PREDICTED(LOAD_SUPER_ATTR);
  2157. static_assert(INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR == 1, "incorrect cache size");
  2158. PyObject *self = stack_pointer[-1];
  2159. PyObject *class = stack_pointer[-2];
  2160. PyObject *global_super = stack_pointer[-3];
  2161. PyObject *res2 = NULL;
  2162. PyObject *res;
  2163. #line 1654 "Python/bytecodes.c"
  2164. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
  2165. int load_method = oparg & 1;
  2166. #if ENABLE_SPECIALIZATION
  2167. _PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
  2168. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  2169. next_instr--;
  2170. _Py_Specialize_LoadSuperAttr(global_super, class, next_instr, load_method);
  2171. DISPATCH_SAME_OPARG();
  2172. }
  2173. STAT_INC(LOAD_SUPER_ATTR, deferred);
  2174. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  2175. #endif /* ENABLE_SPECIALIZATION */
  2176. if (opcode == INSTRUMENTED_LOAD_SUPER_ATTR) {
  2177. PyObject *arg = oparg & 2 ? class : &_PyInstrumentation_MISSING;
  2178. int err = _Py_call_instrumentation_2args(
  2179. tstate, PY_MONITORING_EVENT_CALL,
  2180. frame, next_instr-1, global_super, arg);
  2181. if (err) goto pop_3_error;
  2182. }
  2183. // we make no attempt to optimize here; specializations should
  2184. // handle any case whose performance we care about
  2185. PyObject *stack[] = {class, self};
  2186. PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL);
  2187. if (opcode == INSTRUMENTED_LOAD_SUPER_ATTR) {
  2188. PyObject *arg = oparg & 2 ? class : &_PyInstrumentation_MISSING;
  2189. if (super == NULL) {
  2190. _Py_call_instrumentation_exc2(
  2191. tstate, PY_MONITORING_EVENT_C_RAISE,
  2192. frame, next_instr-1, global_super, arg);
  2193. }
  2194. else {
  2195. int err = _Py_call_instrumentation_2args(
  2196. tstate, PY_MONITORING_EVENT_C_RETURN,
  2197. frame, next_instr-1, global_super, arg);
  2198. if (err < 0) {
  2199. Py_CLEAR(super);
  2200. }
  2201. }
  2202. }
  2203. #line 2331 "Python/generated_cases.c.h"
  2204. Py_DECREF(global_super);
  2205. Py_DECREF(class);
  2206. Py_DECREF(self);
  2207. #line 1696 "Python/bytecodes.c"
  2208. if (super == NULL) goto pop_3_error;
  2209. res = PyObject_GetAttr(super, name);
  2210. Py_DECREF(super);
  2211. if (res == NULL) goto pop_3_error;
  2212. #line 2340 "Python/generated_cases.c.h"
  2213. STACK_SHRINK(2);
  2214. STACK_GROW(((oparg & 1) ? 1 : 0));
  2215. stack_pointer[-1] = res;
  2216. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2217. next_instr += 1;
  2218. DISPATCH();
  2219. }
  2220. TARGET(LOAD_SUPER_ATTR_ATTR) {
  2221. PyObject *self = stack_pointer[-1];
  2222. PyObject *class = stack_pointer[-2];
  2223. PyObject *global_super = stack_pointer[-3];
  2224. PyObject *res2 = NULL;
  2225. PyObject *res;
  2226. #line 1703 "Python/bytecodes.c"
  2227. assert(!(oparg & 1));
  2228. DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR);
  2229. DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR);
  2230. STAT_INC(LOAD_SUPER_ATTR, hit);
  2231. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
  2232. res = _PySuper_Lookup((PyTypeObject *)class, self, name, NULL);
  2233. #line 2362 "Python/generated_cases.c.h"
  2234. Py_DECREF(global_super);
  2235. Py_DECREF(class);
  2236. Py_DECREF(self);
  2237. #line 1710 "Python/bytecodes.c"
  2238. if (res == NULL) goto pop_3_error;
  2239. #line 2368 "Python/generated_cases.c.h"
  2240. STACK_SHRINK(2);
  2241. STACK_GROW(((oparg & 1) ? 1 : 0));
  2242. stack_pointer[-1] = res;
  2243. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2244. next_instr += 1;
  2245. DISPATCH();
  2246. }
  2247. TARGET(LOAD_SUPER_ATTR_METHOD) {
  2248. PyObject *self = stack_pointer[-1];
  2249. PyObject *class = stack_pointer[-2];
  2250. PyObject *global_super = stack_pointer[-3];
  2251. PyObject *res2;
  2252. PyObject *res;
  2253. #line 1714 "Python/bytecodes.c"
  2254. assert(oparg & 1);
  2255. DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR);
  2256. DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR);
  2257. STAT_INC(LOAD_SUPER_ATTR, hit);
  2258. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
  2259. PyTypeObject *cls = (PyTypeObject *)class;
  2260. int method_found = 0;
  2261. res2 = _PySuper_Lookup(cls, self, name,
  2262. Py_TYPE(self)->tp_getattro == PyObject_GenericGetAttr ? &method_found : NULL);
  2263. Py_DECREF(global_super);
  2264. Py_DECREF(class);
  2265. if (res2 == NULL) {
  2266. Py_DECREF(self);
  2267. if (true) goto pop_3_error;
  2268. }
  2269. if (method_found) {
  2270. res = self; // transfer ownership
  2271. } else {
  2272. Py_DECREF(self);
  2273. res = res2;
  2274. res2 = NULL;
  2275. }
  2276. #line 2406 "Python/generated_cases.c.h"
  2277. STACK_SHRINK(1);
  2278. stack_pointer[-1] = res;
  2279. stack_pointer[-2] = res2;
  2280. next_instr += 1;
  2281. DISPATCH();
  2282. }
  2283. TARGET(LOAD_ATTR) {
  2284. PREDICTED(LOAD_ATTR);
  2285. static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
  2286. PyObject *owner = stack_pointer[-1];
  2287. PyObject *res2 = NULL;
  2288. PyObject *res;
  2289. #line 1753 "Python/bytecodes.c"
  2290. #if ENABLE_SPECIALIZATION
  2291. _PyAttrCache *cache = (_PyAttrCache *)next_instr;
  2292. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  2293. PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
  2294. next_instr--;
  2295. _Py_Specialize_LoadAttr(owner, next_instr, name);
  2296. DISPATCH_SAME_OPARG();
  2297. }
  2298. STAT_INC(LOAD_ATTR, deferred);
  2299. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  2300. #endif /* ENABLE_SPECIALIZATION */
  2301. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 1);
  2302. if (oparg & 1) {
  2303. /* Designed to work in tandem with CALL, pushes two values. */
  2304. PyObject* meth = NULL;
  2305. if (_PyObject_GetMethod(owner, name, &meth)) {
  2306. /* We can bypass temporary bound method object.
  2307. meth is unbound method and obj is self.
  2308. meth | self | arg1 | ... | argN
  2309. */
  2310. assert(meth != NULL); // No errors on this branch
  2311. res2 = meth;
  2312. res = owner; // Transfer ownership
  2313. }
  2314. else {
  2315. /* meth is not an unbound method (but a regular attr, or
  2316. something was returned by a descriptor protocol). Set
  2317. the second element of the stack to NULL, to signal
  2318. CALL that it's not a method call.
  2319. NULL | meth | arg1 | ... | argN
  2320. */
  2321. #line 2454 "Python/generated_cases.c.h"
  2322. Py_DECREF(owner);
  2323. #line 1787 "Python/bytecodes.c"
  2324. if (meth == NULL) goto pop_1_error;
  2325. res2 = NULL;
  2326. res = meth;
  2327. }
  2328. }
  2329. else {
  2330. /* Classic, pushes one value. */
  2331. res = PyObject_GetAttr(owner, name);
  2332. #line 2465 "Python/generated_cases.c.h"
  2333. Py_DECREF(owner);
  2334. #line 1796 "Python/bytecodes.c"
  2335. if (res == NULL) goto pop_1_error;
  2336. }
  2337. #line 2470 "Python/generated_cases.c.h"
  2338. STACK_GROW(((oparg & 1) ? 1 : 0));
  2339. stack_pointer[-1] = res;
  2340. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2341. next_instr += 9;
  2342. DISPATCH();
  2343. }
  2344. TARGET(LOAD_ATTR_INSTANCE_VALUE) {
  2345. PyObject *owner = stack_pointer[-1];
  2346. PyObject *res2 = NULL;
  2347. PyObject *res;
  2348. uint32_t type_version = read_u32(&next_instr[1].cache);
  2349. uint16_t index = read_u16(&next_instr[3].cache);
  2350. #line 1801 "Python/bytecodes.c"
  2351. PyTypeObject *tp = Py_TYPE(owner);
  2352. assert(type_version != 0);
  2353. DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
  2354. assert(tp->tp_dictoffset < 0);
  2355. assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  2356. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
  2357. DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
  2358. res = _PyDictOrValues_GetValues(dorv)->values[index];
  2359. DEOPT_IF(res == NULL, LOAD_ATTR);
  2360. STAT_INC(LOAD_ATTR, hit);
  2361. Py_INCREF(res);
  2362. res2 = NULL;
  2363. #line 2497 "Python/generated_cases.c.h"
  2364. Py_DECREF(owner);
  2365. STACK_GROW(((oparg & 1) ? 1 : 0));
  2366. stack_pointer[-1] = res;
  2367. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2368. next_instr += 9;
  2369. DISPATCH();
  2370. }
  2371. TARGET(LOAD_ATTR_MODULE) {
  2372. PyObject *owner = stack_pointer[-1];
  2373. PyObject *res2 = NULL;
  2374. PyObject *res;
  2375. uint32_t type_version = read_u32(&next_instr[1].cache);
  2376. uint16_t index = read_u16(&next_instr[3].cache);
  2377. #line 1817 "Python/bytecodes.c"
  2378. DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR);
  2379. PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict;
  2380. assert(dict != NULL);
  2381. DEOPT_IF(dict->ma_keys->dk_version != type_version, LOAD_ATTR);
  2382. assert(dict->ma_keys->dk_kind == DICT_KEYS_UNICODE);
  2383. assert(index < dict->ma_keys->dk_nentries);
  2384. PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + index;
  2385. res = ep->me_value;
  2386. DEOPT_IF(res == NULL, LOAD_ATTR);
  2387. STAT_INC(LOAD_ATTR, hit);
  2388. Py_INCREF(res);
  2389. res2 = NULL;
  2390. #line 2525 "Python/generated_cases.c.h"
  2391. Py_DECREF(owner);
  2392. STACK_GROW(((oparg & 1) ? 1 : 0));
  2393. stack_pointer[-1] = res;
  2394. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2395. next_instr += 9;
  2396. DISPATCH();
  2397. }
  2398. TARGET(LOAD_ATTR_WITH_HINT) {
  2399. PyObject *owner = stack_pointer[-1];
  2400. PyObject *res2 = NULL;
  2401. PyObject *res;
  2402. uint32_t type_version = read_u32(&next_instr[1].cache);
  2403. uint16_t index = read_u16(&next_instr[3].cache);
  2404. #line 1833 "Python/bytecodes.c"
  2405. PyTypeObject *tp = Py_TYPE(owner);
  2406. assert(type_version != 0);
  2407. DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
  2408. assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  2409. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
  2410. DEOPT_IF(_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
  2411. PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
  2412. DEOPT_IF(dict == NULL, LOAD_ATTR);
  2413. assert(PyDict_CheckExact((PyObject *)dict));
  2414. PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
  2415. uint16_t hint = index;
  2416. DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, LOAD_ATTR);
  2417. if (DK_IS_UNICODE(dict->ma_keys)) {
  2418. PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + hint;
  2419. DEOPT_IF(ep->me_key != name, LOAD_ATTR);
  2420. res = ep->me_value;
  2421. }
  2422. else {
  2423. PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + hint;
  2424. DEOPT_IF(ep->me_key != name, LOAD_ATTR);
  2425. res = ep->me_value;
  2426. }
  2427. DEOPT_IF(res == NULL, LOAD_ATTR);
  2428. STAT_INC(LOAD_ATTR, hit);
  2429. Py_INCREF(res);
  2430. res2 = NULL;
  2431. #line 2567 "Python/generated_cases.c.h"
  2432. Py_DECREF(owner);
  2433. STACK_GROW(((oparg & 1) ? 1 : 0));
  2434. stack_pointer[-1] = res;
  2435. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2436. next_instr += 9;
  2437. DISPATCH();
  2438. }
  2439. TARGET(LOAD_ATTR_SLOT) {
  2440. PyObject *owner = stack_pointer[-1];
  2441. PyObject *res2 = NULL;
  2442. PyObject *res;
  2443. uint32_t type_version = read_u32(&next_instr[1].cache);
  2444. uint16_t index = read_u16(&next_instr[3].cache);
  2445. #line 1863 "Python/bytecodes.c"
  2446. PyTypeObject *tp = Py_TYPE(owner);
  2447. assert(type_version != 0);
  2448. DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
  2449. char *addr = (char *)owner + index;
  2450. res = *(PyObject **)addr;
  2451. DEOPT_IF(res == NULL, LOAD_ATTR);
  2452. STAT_INC(LOAD_ATTR, hit);
  2453. Py_INCREF(res);
  2454. res2 = NULL;
  2455. #line 2592 "Python/generated_cases.c.h"
  2456. Py_DECREF(owner);
  2457. STACK_GROW(((oparg & 1) ? 1 : 0));
  2458. stack_pointer[-1] = res;
  2459. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2460. next_instr += 9;
  2461. DISPATCH();
  2462. }
  2463. TARGET(LOAD_ATTR_CLASS) {
  2464. PyObject *cls = stack_pointer[-1];
  2465. PyObject *res2 = NULL;
  2466. PyObject *res;
  2467. uint32_t type_version = read_u32(&next_instr[1].cache);
  2468. PyObject *descr = read_obj(&next_instr[5].cache);
  2469. #line 1876 "Python/bytecodes.c"
  2470. DEOPT_IF(!PyType_Check(cls), LOAD_ATTR);
  2471. DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version,
  2472. LOAD_ATTR);
  2473. assert(type_version != 0);
  2474. STAT_INC(LOAD_ATTR, hit);
  2475. res2 = NULL;
  2476. res = descr;
  2477. assert(res != NULL);
  2478. Py_INCREF(res);
  2479. #line 2619 "Python/generated_cases.c.h"
  2480. Py_DECREF(cls);
  2481. STACK_GROW(((oparg & 1) ? 1 : 0));
  2482. stack_pointer[-1] = res;
  2483. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  2484. next_instr += 9;
  2485. DISPATCH();
  2486. }
  2487. TARGET(LOAD_ATTR_PROPERTY) {
  2488. PyObject *owner = stack_pointer[-1];
  2489. uint32_t type_version = read_u32(&next_instr[1].cache);
  2490. uint32_t func_version = read_u32(&next_instr[3].cache);
  2491. PyObject *fget = read_obj(&next_instr[5].cache);
  2492. #line 1891 "Python/bytecodes.c"
  2493. DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
  2494. PyTypeObject *cls = Py_TYPE(owner);
  2495. DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
  2496. assert(type_version != 0);
  2497. assert(Py_IS_TYPE(fget, &PyFunction_Type));
  2498. PyFunctionObject *f = (PyFunctionObject *)fget;
  2499. assert(func_version != 0);
  2500. DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
  2501. PyCodeObject *code = (PyCodeObject *)f->func_code;
  2502. assert(code->co_argcount == 1);
  2503. DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
  2504. STAT_INC(LOAD_ATTR, hit);
  2505. Py_INCREF(fget);
  2506. _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 1);
  2507. // Manipulate stack directly because we exit with DISPATCH_INLINED().
  2508. SET_TOP(NULL);
  2509. int shrink_stack = !(oparg & 1);
  2510. STACK_SHRINK(shrink_stack);
  2511. new_frame->localsplus[0] = owner;
  2512. JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR);
  2513. frame->return_offset = 0;
  2514. DISPATCH_INLINED(new_frame);
  2515. #line 2657 "Python/generated_cases.c.h"
  2516. }
  2517. TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) {
  2518. PyObject *owner = stack_pointer[-1];
  2519. uint32_t type_version = read_u32(&next_instr[1].cache);
  2520. uint32_t func_version = read_u32(&next_instr[3].cache);
  2521. PyObject *getattribute = read_obj(&next_instr[5].cache);
  2522. #line 1917 "Python/bytecodes.c"
  2523. DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
  2524. PyTypeObject *cls = Py_TYPE(owner);
  2525. DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
  2526. assert(type_version != 0);
  2527. assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
  2528. PyFunctionObject *f = (PyFunctionObject *)getattribute;
  2529. assert(func_version != 0);
  2530. DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
  2531. PyCodeObject *code = (PyCodeObject *)f->func_code;
  2532. assert(code->co_argcount == 2);
  2533. DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
  2534. STAT_INC(LOAD_ATTR, hit);
  2535. PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 1);
  2536. Py_INCREF(f);
  2537. _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 2);
  2538. // Manipulate stack directly because we exit with DISPATCH_INLINED().
  2539. SET_TOP(NULL);
  2540. int shrink_stack = !(oparg & 1);
  2541. STACK_SHRINK(shrink_stack);
  2542. new_frame->localsplus[0] = owner;
  2543. new_frame->localsplus[1] = Py_NewRef(name);
  2544. JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR);
  2545. frame->return_offset = 0;
  2546. DISPATCH_INLINED(new_frame);
  2547. #line 2691 "Python/generated_cases.c.h"
  2548. }
  2549. TARGET(STORE_ATTR_INSTANCE_VALUE) {
  2550. PyObject *owner = stack_pointer[-1];
  2551. PyObject *value = stack_pointer[-2];
  2552. uint32_t type_version = read_u32(&next_instr[1].cache);
  2553. uint16_t index = read_u16(&next_instr[3].cache);
  2554. #line 1945 "Python/bytecodes.c"
  2555. PyTypeObject *tp = Py_TYPE(owner);
  2556. assert(type_version != 0);
  2557. DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
  2558. assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  2559. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
  2560. DEOPT_IF(!_PyDictOrValues_IsValues(dorv), STORE_ATTR);
  2561. STAT_INC(STORE_ATTR, hit);
  2562. PyDictValues *values = _PyDictOrValues_GetValues(dorv);
  2563. PyObject *old_value = values->values[index];
  2564. values->values[index] = value;
  2565. if (old_value == NULL) {
  2566. _PyDictValues_AddToInsertionOrder(values, index);
  2567. }
  2568. else {
  2569. Py_DECREF(old_value);
  2570. }
  2571. Py_DECREF(owner);
  2572. #line 2717 "Python/generated_cases.c.h"
  2573. STACK_SHRINK(2);
  2574. next_instr += 4;
  2575. DISPATCH();
  2576. }
  2577. TARGET(STORE_ATTR_WITH_HINT) {
  2578. PyObject *owner = stack_pointer[-1];
  2579. PyObject *value = stack_pointer[-2];
  2580. uint32_t type_version = read_u32(&next_instr[1].cache);
  2581. uint16_t hint = read_u16(&next_instr[3].cache);
  2582. #line 1965 "Python/bytecodes.c"
  2583. PyTypeObject *tp = Py_TYPE(owner);
  2584. assert(type_version != 0);
  2585. DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
  2586. assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  2587. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
  2588. DEOPT_IF(_PyDictOrValues_IsValues(dorv), STORE_ATTR);
  2589. PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
  2590. DEOPT_IF(dict == NULL, STORE_ATTR);
  2591. assert(PyDict_CheckExact((PyObject *)dict));
  2592. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  2593. DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, STORE_ATTR);
  2594. PyObject *old_value;
  2595. uint64_t new_version;
  2596. if (DK_IS_UNICODE(dict->ma_keys)) {
  2597. PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + hint;
  2598. DEOPT_IF(ep->me_key != name, STORE_ATTR);
  2599. old_value = ep->me_value;
  2600. DEOPT_IF(old_value == NULL, STORE_ATTR);
  2601. new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value);
  2602. ep->me_value = value;
  2603. }
  2604. else {
  2605. PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + hint;
  2606. DEOPT_IF(ep->me_key != name, STORE_ATTR);
  2607. old_value = ep->me_value;
  2608. DEOPT_IF(old_value == NULL, STORE_ATTR);
  2609. new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value);
  2610. ep->me_value = value;
  2611. }
  2612. Py_DECREF(old_value);
  2613. STAT_INC(STORE_ATTR, hit);
  2614. /* Ensure dict is GC tracked if it needs to be */
  2615. if (!_PyObject_GC_IS_TRACKED(dict) && _PyObject_GC_MAY_BE_TRACKED(value)) {
  2616. _PyObject_GC_TRACK(dict);
  2617. }
  2618. /* PEP 509 */
  2619. dict->ma_version_tag = new_version;
  2620. Py_DECREF(owner);
  2621. #line 2767 "Python/generated_cases.c.h"
  2622. STACK_SHRINK(2);
  2623. next_instr += 4;
  2624. DISPATCH();
  2625. }
  2626. TARGET(STORE_ATTR_SLOT) {
  2627. PyObject *owner = stack_pointer[-1];
  2628. PyObject *value = stack_pointer[-2];
  2629. uint32_t type_version = read_u32(&next_instr[1].cache);
  2630. uint16_t index = read_u16(&next_instr[3].cache);
  2631. #line 2006 "Python/bytecodes.c"
  2632. PyTypeObject *tp = Py_TYPE(owner);
  2633. assert(type_version != 0);
  2634. DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
  2635. char *addr = (char *)owner + index;
  2636. STAT_INC(STORE_ATTR, hit);
  2637. PyObject *old_value = *(PyObject **)addr;
  2638. *(PyObject **)addr = value;
  2639. Py_XDECREF(old_value);
  2640. Py_DECREF(owner);
  2641. #line 2788 "Python/generated_cases.c.h"
  2642. STACK_SHRINK(2);
  2643. next_instr += 4;
  2644. DISPATCH();
  2645. }
  2646. TARGET(COMPARE_OP) {
  2647. PREDICTED(COMPARE_OP);
  2648. static_assert(INLINE_CACHE_ENTRIES_COMPARE_OP == 1, "incorrect cache size");
  2649. PyObject *right = stack_pointer[-1];
  2650. PyObject *left = stack_pointer[-2];
  2651. PyObject *res;
  2652. #line 2025 "Python/bytecodes.c"
  2653. #if ENABLE_SPECIALIZATION
  2654. _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
  2655. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  2656. next_instr--;
  2657. _Py_Specialize_CompareOp(left, right, next_instr, oparg);
  2658. DISPATCH_SAME_OPARG();
  2659. }
  2660. STAT_INC(COMPARE_OP, deferred);
  2661. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  2662. #endif /* ENABLE_SPECIALIZATION */
  2663. assert((oparg >> 4) <= Py_GE);
  2664. res = PyObject_RichCompare(left, right, oparg>>4);
  2665. #line 2813 "Python/generated_cases.c.h"
  2666. Py_DECREF(left);
  2667. Py_DECREF(right);
  2668. #line 2038 "Python/bytecodes.c"
  2669. if (res == NULL) goto pop_2_error;
  2670. #line 2818 "Python/generated_cases.c.h"
  2671. STACK_SHRINK(1);
  2672. stack_pointer[-1] = res;
  2673. next_instr += 1;
  2674. DISPATCH();
  2675. }
  2676. TARGET(COMPARE_OP_FLOAT) {
  2677. PyObject *right = stack_pointer[-1];
  2678. PyObject *left = stack_pointer[-2];
  2679. PyObject *res;
  2680. #line 2042 "Python/bytecodes.c"
  2681. DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP);
  2682. DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP);
  2683. STAT_INC(COMPARE_OP, hit);
  2684. double dleft = PyFloat_AS_DOUBLE(left);
  2685. double dright = PyFloat_AS_DOUBLE(right);
  2686. // 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
  2687. int sign_ish = COMPARISON_BIT(dleft, dright);
  2688. _Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
  2689. _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
  2690. res = (sign_ish & oparg) ? Py_True : Py_False;
  2691. #line 2840 "Python/generated_cases.c.h"
  2692. STACK_SHRINK(1);
  2693. stack_pointer[-1] = res;
  2694. next_instr += 1;
  2695. DISPATCH();
  2696. }
  2697. TARGET(COMPARE_OP_INT) {
  2698. PyObject *right = stack_pointer[-1];
  2699. PyObject *left = stack_pointer[-2];
  2700. PyObject *res;
  2701. #line 2056 "Python/bytecodes.c"
  2702. DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP);
  2703. DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP);
  2704. DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP);
  2705. DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)right), COMPARE_OP);
  2706. STAT_INC(COMPARE_OP, hit);
  2707. assert(_PyLong_DigitCount((PyLongObject *)left) <= 1 &&
  2708. _PyLong_DigitCount((PyLongObject *)right) <= 1);
  2709. Py_ssize_t ileft = _PyLong_CompactValue((PyLongObject *)left);
  2710. Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right);
  2711. // 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
  2712. int sign_ish = COMPARISON_BIT(ileft, iright);
  2713. _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
  2714. _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
  2715. res = (sign_ish & oparg) ? Py_True : Py_False;
  2716. #line 2866 "Python/generated_cases.c.h"
  2717. STACK_SHRINK(1);
  2718. stack_pointer[-1] = res;
  2719. next_instr += 1;
  2720. DISPATCH();
  2721. }
  2722. TARGET(COMPARE_OP_STR) {
  2723. PyObject *right = stack_pointer[-1];
  2724. PyObject *left = stack_pointer[-2];
  2725. PyObject *res;
  2726. #line 2074 "Python/bytecodes.c"
  2727. DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP);
  2728. DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP);
  2729. STAT_INC(COMPARE_OP, hit);
  2730. int eq = _PyUnicode_Equal(left, right);
  2731. assert((oparg >>4) == Py_EQ || (oparg >>4) == Py_NE);
  2732. _Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc);
  2733. _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
  2734. assert(eq == 0 || eq == 1);
  2735. assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
  2736. assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
  2737. res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False;
  2738. #line 2889 "Python/generated_cases.c.h"
  2739. STACK_SHRINK(1);
  2740. stack_pointer[-1] = res;
  2741. next_instr += 1;
  2742. DISPATCH();
  2743. }
  2744. TARGET(IS_OP) {
  2745. PyObject *right = stack_pointer[-1];
  2746. PyObject *left = stack_pointer[-2];
  2747. PyObject *b;
  2748. #line 2088 "Python/bytecodes.c"
  2749. int res = Py_Is(left, right) ^ oparg;
  2750. #line 2902 "Python/generated_cases.c.h"
  2751. Py_DECREF(left);
  2752. Py_DECREF(right);
  2753. #line 2090 "Python/bytecodes.c"
  2754. b = res ? Py_True : Py_False;
  2755. #line 2907 "Python/generated_cases.c.h"
  2756. STACK_SHRINK(1);
  2757. stack_pointer[-1] = b;
  2758. DISPATCH();
  2759. }
  2760. TARGET(CONTAINS_OP) {
  2761. PyObject *right = stack_pointer[-1];
  2762. PyObject *left = stack_pointer[-2];
  2763. PyObject *b;
  2764. #line 2094 "Python/bytecodes.c"
  2765. int res = PySequence_Contains(right, left);
  2766. #line 2919 "Python/generated_cases.c.h"
  2767. Py_DECREF(left);
  2768. Py_DECREF(right);
  2769. #line 2096 "Python/bytecodes.c"
  2770. if (res < 0) goto pop_2_error;
  2771. b = (res ^ oparg) ? Py_True : Py_False;
  2772. #line 2925 "Python/generated_cases.c.h"
  2773. STACK_SHRINK(1);
  2774. stack_pointer[-1] = b;
  2775. DISPATCH();
  2776. }
  2777. TARGET(CHECK_EG_MATCH) {
  2778. PyObject *match_type = stack_pointer[-1];
  2779. PyObject *exc_value = stack_pointer[-2];
  2780. PyObject *rest;
  2781. PyObject *match;
  2782. #line 2101 "Python/bytecodes.c"
  2783. if (check_except_star_type_valid(tstate, match_type) < 0) {
  2784. #line 2938 "Python/generated_cases.c.h"
  2785. Py_DECREF(exc_value);
  2786. Py_DECREF(match_type);
  2787. #line 2103 "Python/bytecodes.c"
  2788. if (true) goto pop_2_error;
  2789. }
  2790. match = NULL;
  2791. rest = NULL;
  2792. int res = exception_group_match(exc_value, match_type,
  2793. &match, &rest);
  2794. #line 2949 "Python/generated_cases.c.h"
  2795. Py_DECREF(exc_value);
  2796. Py_DECREF(match_type);
  2797. #line 2111 "Python/bytecodes.c"
  2798. if (res < 0) goto pop_2_error;
  2799. assert((match == NULL) == (rest == NULL));
  2800. if (match == NULL) goto pop_2_error;
  2801. if (!Py_IsNone(match)) {
  2802. PyErr_SetHandledException(match);
  2803. }
  2804. #line 2961 "Python/generated_cases.c.h"
  2805. stack_pointer[-1] = match;
  2806. stack_pointer[-2] = rest;
  2807. DISPATCH();
  2808. }
  2809. TARGET(CHECK_EXC_MATCH) {
  2810. PyObject *right = stack_pointer[-1];
  2811. PyObject *left = stack_pointer[-2];
  2812. PyObject *b;
  2813. #line 2122 "Python/bytecodes.c"
  2814. assert(PyExceptionInstance_Check(left));
  2815. if (check_except_type_valid(tstate, right) < 0) {
  2816. #line 2974 "Python/generated_cases.c.h"
  2817. Py_DECREF(right);
  2818. #line 2125 "Python/bytecodes.c"
  2819. if (true) goto pop_1_error;
  2820. }
  2821. int res = PyErr_GivenExceptionMatches(left, right);
  2822. #line 2981 "Python/generated_cases.c.h"
  2823. Py_DECREF(right);
  2824. #line 2130 "Python/bytecodes.c"
  2825. b = res ? Py_True : Py_False;
  2826. #line 2985 "Python/generated_cases.c.h"
  2827. stack_pointer[-1] = b;
  2828. DISPATCH();
  2829. }
  2830. TARGET(IMPORT_NAME) {
  2831. PyObject *fromlist = stack_pointer[-1];
  2832. PyObject *level = stack_pointer[-2];
  2833. PyObject *res;
  2834. #line 2134 "Python/bytecodes.c"
  2835. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  2836. res = import_name(tstate, frame, name, fromlist, level);
  2837. #line 2997 "Python/generated_cases.c.h"
  2838. Py_DECREF(level);
  2839. Py_DECREF(fromlist);
  2840. #line 2137 "Python/bytecodes.c"
  2841. if (res == NULL) goto pop_2_error;
  2842. #line 3002 "Python/generated_cases.c.h"
  2843. STACK_SHRINK(1);
  2844. stack_pointer[-1] = res;
  2845. DISPATCH();
  2846. }
  2847. TARGET(IMPORT_FROM) {
  2848. PyObject *from = stack_pointer[-1];
  2849. PyObject *res;
  2850. #line 2141 "Python/bytecodes.c"
  2851. PyObject *name = GETITEM(frame->f_code->co_names, oparg);
  2852. res = import_from(tstate, from, name);
  2853. if (res == NULL) goto error;
  2854. #line 3015 "Python/generated_cases.c.h"
  2855. STACK_GROW(1);
  2856. stack_pointer[-1] = res;
  2857. DISPATCH();
  2858. }
  2859. TARGET(JUMP_FORWARD) {
  2860. #line 2147 "Python/bytecodes.c"
  2861. JUMPBY(oparg);
  2862. #line 3024 "Python/generated_cases.c.h"
  2863. DISPATCH();
  2864. }
  2865. TARGET(JUMP_BACKWARD) {
  2866. PREDICTED(JUMP_BACKWARD);
  2867. #line 2151 "Python/bytecodes.c"
  2868. assert(oparg < INSTR_OFFSET());
  2869. JUMPBY(-oparg);
  2870. #line 3033 "Python/generated_cases.c.h"
  2871. CHECK_EVAL_BREAKER();
  2872. DISPATCH();
  2873. }
  2874. TARGET(POP_JUMP_IF_FALSE) {
  2875. PREDICTED(POP_JUMP_IF_FALSE);
  2876. PyObject *cond = stack_pointer[-1];
  2877. #line 2157 "Python/bytecodes.c"
  2878. if (Py_IsFalse(cond)) {
  2879. JUMPBY(oparg);
  2880. }
  2881. else if (!Py_IsTrue(cond)) {
  2882. int err = PyObject_IsTrue(cond);
  2883. #line 3047 "Python/generated_cases.c.h"
  2884. Py_DECREF(cond);
  2885. #line 2163 "Python/bytecodes.c"
  2886. if (err == 0) {
  2887. JUMPBY(oparg);
  2888. }
  2889. else {
  2890. if (err < 0) goto pop_1_error;
  2891. }
  2892. }
  2893. #line 3057 "Python/generated_cases.c.h"
  2894. STACK_SHRINK(1);
  2895. DISPATCH();
  2896. }
  2897. TARGET(POP_JUMP_IF_TRUE) {
  2898. PyObject *cond = stack_pointer[-1];
  2899. #line 2173 "Python/bytecodes.c"
  2900. if (Py_IsTrue(cond)) {
  2901. JUMPBY(oparg);
  2902. }
  2903. else if (!Py_IsFalse(cond)) {
  2904. int err = PyObject_IsTrue(cond);
  2905. #line 3070 "Python/generated_cases.c.h"
  2906. Py_DECREF(cond);
  2907. #line 2179 "Python/bytecodes.c"
  2908. if (err > 0) {
  2909. JUMPBY(oparg);
  2910. }
  2911. else {
  2912. if (err < 0) goto pop_1_error;
  2913. }
  2914. }
  2915. #line 3080 "Python/generated_cases.c.h"
  2916. STACK_SHRINK(1);
  2917. DISPATCH();
  2918. }
  2919. TARGET(POP_JUMP_IF_NOT_NONE) {
  2920. PyObject *value = stack_pointer[-1];
  2921. #line 2189 "Python/bytecodes.c"
  2922. if (!Py_IsNone(value)) {
  2923. #line 3089 "Python/generated_cases.c.h"
  2924. Py_DECREF(value);
  2925. #line 2191 "Python/bytecodes.c"
  2926. JUMPBY(oparg);
  2927. }
  2928. #line 3094 "Python/generated_cases.c.h"
  2929. STACK_SHRINK(1);
  2930. DISPATCH();
  2931. }
  2932. TARGET(POP_JUMP_IF_NONE) {
  2933. PyObject *value = stack_pointer[-1];
  2934. #line 2196 "Python/bytecodes.c"
  2935. if (Py_IsNone(value)) {
  2936. JUMPBY(oparg);
  2937. }
  2938. else {
  2939. #line 3106 "Python/generated_cases.c.h"
  2940. Py_DECREF(value);
  2941. #line 2201 "Python/bytecodes.c"
  2942. }
  2943. #line 3110 "Python/generated_cases.c.h"
  2944. STACK_SHRINK(1);
  2945. DISPATCH();
  2946. }
  2947. TARGET(JUMP_BACKWARD_NO_INTERRUPT) {
  2948. #line 2205 "Python/bytecodes.c"
  2949. /* This bytecode is used in the `yield from` or `await` loop.
  2950. * If there is an interrupt, we want it handled in the innermost
  2951. * generator or coroutine, so we deliberately do not check it here.
  2952. * (see bpo-30039).
  2953. */
  2954. JUMPBY(-oparg);
  2955. #line 3123 "Python/generated_cases.c.h"
  2956. DISPATCH();
  2957. }
  2958. TARGET(GET_LEN) {
  2959. PyObject *obj = stack_pointer[-1];
  2960. PyObject *len_o;
  2961. #line 2214 "Python/bytecodes.c"
  2962. // PUSH(len(TOS))
  2963. Py_ssize_t len_i = PyObject_Length(obj);
  2964. if (len_i < 0) goto error;
  2965. len_o = PyLong_FromSsize_t(len_i);
  2966. if (len_o == NULL) goto error;
  2967. #line 3136 "Python/generated_cases.c.h"
  2968. STACK_GROW(1);
  2969. stack_pointer[-1] = len_o;
  2970. DISPATCH();
  2971. }
  2972. TARGET(MATCH_CLASS) {
  2973. PyObject *names = stack_pointer[-1];
  2974. PyObject *type = stack_pointer[-2];
  2975. PyObject *subject = stack_pointer[-3];
  2976. PyObject *attrs;
  2977. #line 2222 "Python/bytecodes.c"
  2978. // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or
  2979. // None on failure.
  2980. assert(PyTuple_CheckExact(names));
  2981. attrs = match_class(tstate, subject, type, oparg, names);
  2982. #line 3152 "Python/generated_cases.c.h"
  2983. Py_DECREF(subject);
  2984. Py_DECREF(type);
  2985. Py_DECREF(names);
  2986. #line 2227 "Python/bytecodes.c"
  2987. if (attrs) {
  2988. assert(PyTuple_CheckExact(attrs)); // Success!
  2989. }
  2990. else {
  2991. if (_PyErr_Occurred(tstate)) goto pop_3_error;
  2992. attrs = Py_None; // Failure!
  2993. }
  2994. #line 3164 "Python/generated_cases.c.h"
  2995. STACK_SHRINK(2);
  2996. stack_pointer[-1] = attrs;
  2997. DISPATCH();
  2998. }
  2999. TARGET(MATCH_MAPPING) {
  3000. PyObject *subject = stack_pointer[-1];
  3001. PyObject *res;
  3002. #line 2237 "Python/bytecodes.c"
  3003. int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING;
  3004. res = match ? Py_True : Py_False;
  3005. #line 3176 "Python/generated_cases.c.h"
  3006. STACK_GROW(1);
  3007. stack_pointer[-1] = res;
  3008. PREDICT(POP_JUMP_IF_FALSE);
  3009. DISPATCH();
  3010. }
  3011. TARGET(MATCH_SEQUENCE) {
  3012. PyObject *subject = stack_pointer[-1];
  3013. PyObject *res;
  3014. #line 2243 "Python/bytecodes.c"
  3015. int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE;
  3016. res = match ? Py_True : Py_False;
  3017. #line 3189 "Python/generated_cases.c.h"
  3018. STACK_GROW(1);
  3019. stack_pointer[-1] = res;
  3020. PREDICT(POP_JUMP_IF_FALSE);
  3021. DISPATCH();
  3022. }
  3023. TARGET(MATCH_KEYS) {
  3024. PyObject *keys = stack_pointer[-1];
  3025. PyObject *subject = stack_pointer[-2];
  3026. PyObject *values_or_none;
  3027. #line 2249 "Python/bytecodes.c"
  3028. // On successful match, PUSH(values). Otherwise, PUSH(None).
  3029. values_or_none = match_keys(tstate, subject, keys);
  3030. if (values_or_none == NULL) goto error;
  3031. #line 3204 "Python/generated_cases.c.h"
  3032. STACK_GROW(1);
  3033. stack_pointer[-1] = values_or_none;
  3034. DISPATCH();
  3035. }
  3036. TARGET(GET_ITER) {
  3037. PyObject *iterable = stack_pointer[-1];
  3038. PyObject *iter;
  3039. #line 2255 "Python/bytecodes.c"
  3040. /* before: [obj]; after [getiter(obj)] */
  3041. iter = PyObject_GetIter(iterable);
  3042. #line 3216 "Python/generated_cases.c.h"
  3043. Py_DECREF(iterable);
  3044. #line 2258 "Python/bytecodes.c"
  3045. if (iter == NULL) goto pop_1_error;
  3046. #line 3220 "Python/generated_cases.c.h"
  3047. stack_pointer[-1] = iter;
  3048. DISPATCH();
  3049. }
  3050. TARGET(GET_YIELD_FROM_ITER) {
  3051. PyObject *iterable = stack_pointer[-1];
  3052. PyObject *iter;
  3053. #line 2262 "Python/bytecodes.c"
  3054. /* before: [obj]; after [getiter(obj)] */
  3055. if (PyCoro_CheckExact(iterable)) {
  3056. /* `iterable` is a coroutine */
  3057. if (!(frame->f_code->co_flags & (CO_COROUTINE | CO_ITERABLE_COROUTINE))) {
  3058. /* and it is used in a 'yield from' expression of a
  3059. regular generator. */
  3060. _PyErr_SetString(tstate, PyExc_TypeError,
  3061. "cannot 'yield from' a coroutine object "
  3062. "in a non-coroutine generator");
  3063. goto error;
  3064. }
  3065. iter = iterable;
  3066. }
  3067. else if (PyGen_CheckExact(iterable)) {
  3068. iter = iterable;
  3069. }
  3070. else {
  3071. /* `iterable` is not a generator. */
  3072. iter = PyObject_GetIter(iterable);
  3073. if (iter == NULL) {
  3074. goto error;
  3075. }
  3076. #line 3251 "Python/generated_cases.c.h"
  3077. Py_DECREF(iterable);
  3078. #line 2285 "Python/bytecodes.c"
  3079. }
  3080. #line 3255 "Python/generated_cases.c.h"
  3081. stack_pointer[-1] = iter;
  3082. PREDICT(LOAD_CONST);
  3083. DISPATCH();
  3084. }
  3085. TARGET(FOR_ITER) {
  3086. PREDICTED(FOR_ITER);
  3087. static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size");
  3088. PyObject *iter = stack_pointer[-1];
  3089. PyObject *next;
  3090. #line 2304 "Python/bytecodes.c"
  3091. #if ENABLE_SPECIALIZATION
  3092. _PyForIterCache *cache = (_PyForIterCache *)next_instr;
  3093. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  3094. next_instr--;
  3095. _Py_Specialize_ForIter(iter, next_instr, oparg);
  3096. DISPATCH_SAME_OPARG();
  3097. }
  3098. STAT_INC(FOR_ITER, deferred);
  3099. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  3100. #endif /* ENABLE_SPECIALIZATION */
  3101. /* before: [iter]; after: [iter, iter()] *or* [] (and jump over END_FOR.) */
  3102. next = (*Py_TYPE(iter)->tp_iternext)(iter);
  3103. if (next == NULL) {
  3104. if (_PyErr_Occurred(tstate)) {
  3105. if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
  3106. goto error;
  3107. }
  3108. monitor_raise(tstate, frame, next_instr-1);
  3109. _PyErr_Clear(tstate);
  3110. }
  3111. /* iterator ended normally */
  3112. assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
  3113. next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
  3114. Py_DECREF(iter);
  3115. STACK_SHRINK(1);
  3116. /* Jump forward oparg, then skip following END_FOR instruction */
  3117. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
  3118. DISPATCH();
  3119. }
  3120. // Common case: no jump, leave it to the code generator
  3121. #line 3297 "Python/generated_cases.c.h"
  3122. STACK_GROW(1);
  3123. stack_pointer[-1] = next;
  3124. next_instr += 1;
  3125. DISPATCH();
  3126. }
  3127. TARGET(INSTRUMENTED_FOR_ITER) {
  3128. #line 2337 "Python/bytecodes.c"
  3129. _Py_CODEUNIT *here = next_instr-1;
  3130. _Py_CODEUNIT *target;
  3131. PyObject *iter = TOP();
  3132. PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
  3133. if (next != NULL) {
  3134. PUSH(next);
  3135. target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER;
  3136. }
  3137. else {
  3138. if (_PyErr_Occurred(tstate)) {
  3139. if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
  3140. goto error;
  3141. }
  3142. monitor_raise(tstate, frame, here);
  3143. _PyErr_Clear(tstate);
  3144. }
  3145. /* iterator ended normally */
  3146. assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
  3147. next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
  3148. STACK_SHRINK(1);
  3149. Py_DECREF(iter);
  3150. /* Skip END_FOR */
  3151. target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1;
  3152. }
  3153. INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH);
  3154. #line 3331 "Python/generated_cases.c.h"
  3155. DISPATCH();
  3156. }
  3157. TARGET(FOR_ITER_LIST) {
  3158. PyObject *iter = stack_pointer[-1];
  3159. PyObject *next;
  3160. #line 2365 "Python/bytecodes.c"
  3161. DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER);
  3162. _PyListIterObject *it = (_PyListIterObject *)iter;
  3163. STAT_INC(FOR_ITER, hit);
  3164. PyListObject *seq = it->it_seq;
  3165. if (seq) {
  3166. if (it->it_index < PyList_GET_SIZE(seq)) {
  3167. next = Py_NewRef(PyList_GET_ITEM(seq, it->it_index++));
  3168. goto end_for_iter_list; // End of this instruction
  3169. }
  3170. it->it_seq = NULL;
  3171. Py_DECREF(seq);
  3172. }
  3173. Py_DECREF(iter);
  3174. STACK_SHRINK(1);
  3175. /* Jump forward oparg, then skip following END_FOR instruction */
  3176. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
  3177. DISPATCH();
  3178. end_for_iter_list:
  3179. // Common case: no jump, leave it to the code generator
  3180. #line 3358 "Python/generated_cases.c.h"
  3181. STACK_GROW(1);
  3182. stack_pointer[-1] = next;
  3183. next_instr += 1;
  3184. DISPATCH();
  3185. }
  3186. TARGET(FOR_ITER_TUPLE) {
  3187. PyObject *iter = stack_pointer[-1];
  3188. PyObject *next;
  3189. #line 2387 "Python/bytecodes.c"
  3190. _PyTupleIterObject *it = (_PyTupleIterObject *)iter;
  3191. DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER);
  3192. STAT_INC(FOR_ITER, hit);
  3193. PyTupleObject *seq = it->it_seq;
  3194. if (seq) {
  3195. if (it->it_index < PyTuple_GET_SIZE(seq)) {
  3196. next = Py_NewRef(PyTuple_GET_ITEM(seq, it->it_index++));
  3197. goto end_for_iter_tuple; // End of this instruction
  3198. }
  3199. it->it_seq = NULL;
  3200. Py_DECREF(seq);
  3201. }
  3202. Py_DECREF(iter);
  3203. STACK_SHRINK(1);
  3204. /* Jump forward oparg, then skip following END_FOR instruction */
  3205. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
  3206. DISPATCH();
  3207. end_for_iter_tuple:
  3208. // Common case: no jump, leave it to the code generator
  3209. #line 3388 "Python/generated_cases.c.h"
  3210. STACK_GROW(1);
  3211. stack_pointer[-1] = next;
  3212. next_instr += 1;
  3213. DISPATCH();
  3214. }
  3215. TARGET(FOR_ITER_RANGE) {
  3216. PyObject *iter = stack_pointer[-1];
  3217. PyObject *next;
  3218. #line 2409 "Python/bytecodes.c"
  3219. _PyRangeIterObject *r = (_PyRangeIterObject *)iter;
  3220. DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER);
  3221. STAT_INC(FOR_ITER, hit);
  3222. if (r->len <= 0) {
  3223. STACK_SHRINK(1);
  3224. Py_DECREF(r);
  3225. // Jump over END_FOR instruction.
  3226. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
  3227. DISPATCH();
  3228. }
  3229. long value = r->start;
  3230. r->start = value + r->step;
  3231. r->len--;
  3232. next = PyLong_FromLong(value);
  3233. if (next == NULL) {
  3234. goto error;
  3235. }
  3236. #line 3416 "Python/generated_cases.c.h"
  3237. STACK_GROW(1);
  3238. stack_pointer[-1] = next;
  3239. next_instr += 1;
  3240. DISPATCH();
  3241. }
  3242. TARGET(FOR_ITER_GEN) {
  3243. PyObject *iter = stack_pointer[-1];
  3244. #line 2429 "Python/bytecodes.c"
  3245. DEOPT_IF(tstate->interp->eval_frame, FOR_ITER);
  3246. PyGenObject *gen = (PyGenObject *)iter;
  3247. DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER);
  3248. DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER);
  3249. STAT_INC(FOR_ITER, hit);
  3250. _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
  3251. frame->return_offset = oparg;
  3252. _PyFrame_StackPush(gen_frame, Py_None);
  3253. gen->gi_frame_state = FRAME_EXECUTING;
  3254. gen->gi_exc_state.previous_item = tstate->exc_info;
  3255. tstate->exc_info = &gen->gi_exc_state;
  3256. JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER);
  3257. assert(next_instr[oparg].op.code == END_FOR ||
  3258. next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
  3259. DISPATCH_INLINED(gen_frame);
  3260. #line 3441 "Python/generated_cases.c.h"
  3261. }
  3262. TARGET(BEFORE_ASYNC_WITH) {
  3263. PyObject *mgr = stack_pointer[-1];
  3264. PyObject *exit;
  3265. PyObject *res;
  3266. #line 2447 "Python/bytecodes.c"
  3267. PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__));
  3268. if (enter == NULL) {
  3269. if (!_PyErr_Occurred(tstate)) {
  3270. _PyErr_Format(tstate, PyExc_TypeError,
  3271. "'%.200s' object does not support the "
  3272. "asynchronous context manager protocol",
  3273. Py_TYPE(mgr)->tp_name);
  3274. }
  3275. goto error;
  3276. }
  3277. exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__aexit__));
  3278. if (exit == NULL) {
  3279. if (!_PyErr_Occurred(tstate)) {
  3280. _PyErr_Format(tstate, PyExc_TypeError,
  3281. "'%.200s' object does not support the "
  3282. "asynchronous context manager protocol "
  3283. "(missed __aexit__ method)",
  3284. Py_TYPE(mgr)->tp_name);
  3285. }
  3286. Py_DECREF(enter);
  3287. goto error;
  3288. }
  3289. #line 3471 "Python/generated_cases.c.h"
  3290. Py_DECREF(mgr);
  3291. #line 2470 "Python/bytecodes.c"
  3292. res = _PyObject_CallNoArgs(enter);
  3293. Py_DECREF(enter);
  3294. if (res == NULL) {
  3295. Py_DECREF(exit);
  3296. if (true) goto pop_1_error;
  3297. }
  3298. #line 3480 "Python/generated_cases.c.h"
  3299. STACK_GROW(1);
  3300. stack_pointer[-1] = res;
  3301. stack_pointer[-2] = exit;
  3302. PREDICT(GET_AWAITABLE);
  3303. DISPATCH();
  3304. }
  3305. TARGET(BEFORE_WITH) {
  3306. PyObject *mgr = stack_pointer[-1];
  3307. PyObject *exit;
  3308. PyObject *res;
  3309. #line 2480 "Python/bytecodes.c"
  3310. /* pop the context manager, push its __exit__ and the
  3311. * value returned from calling its __enter__
  3312. */
  3313. PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__enter__));
  3314. if (enter == NULL) {
  3315. if (!_PyErr_Occurred(tstate)) {
  3316. _PyErr_Format(tstate, PyExc_TypeError,
  3317. "'%.200s' object does not support the "
  3318. "context manager protocol",
  3319. Py_TYPE(mgr)->tp_name);
  3320. }
  3321. goto error;
  3322. }
  3323. exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
  3324. if (exit == NULL) {
  3325. if (!_PyErr_Occurred(tstate)) {
  3326. _PyErr_Format(tstate, PyExc_TypeError,
  3327. "'%.200s' object does not support the "
  3328. "context manager protocol "
  3329. "(missed __exit__ method)",
  3330. Py_TYPE(mgr)->tp_name);
  3331. }
  3332. Py_DECREF(enter);
  3333. goto error;
  3334. }
  3335. #line 3518 "Python/generated_cases.c.h"
  3336. Py_DECREF(mgr);
  3337. #line 2506 "Python/bytecodes.c"
  3338. res = _PyObject_CallNoArgs(enter);
  3339. Py_DECREF(enter);
  3340. if (res == NULL) {
  3341. Py_DECREF(exit);
  3342. if (true) goto pop_1_error;
  3343. }
  3344. #line 3527 "Python/generated_cases.c.h"
  3345. STACK_GROW(1);
  3346. stack_pointer[-1] = res;
  3347. stack_pointer[-2] = exit;
  3348. DISPATCH();
  3349. }
  3350. TARGET(WITH_EXCEPT_START) {
  3351. PyObject *val = stack_pointer[-1];
  3352. PyObject *lasti = stack_pointer[-3];
  3353. PyObject *exit_func = stack_pointer[-4];
  3354. PyObject *res;
  3355. #line 2515 "Python/bytecodes.c"
  3356. /* At the top of the stack are 4 values:
  3357. - val: TOP = exc_info()
  3358. - unused: SECOND = previous exception
  3359. - lasti: THIRD = lasti of exception in exc_info()
  3360. - exit_func: FOURTH = the context.__exit__ bound method
  3361. We call FOURTH(type(TOP), TOP, GetTraceback(TOP)).
  3362. Then we push the __exit__ return value.
  3363. */
  3364. PyObject *exc, *tb;
  3365. assert(val && PyExceptionInstance_Check(val));
  3366. exc = PyExceptionInstance_Class(val);
  3367. tb = PyException_GetTraceback(val);
  3368. if (tb == NULL) {
  3369. tb = Py_None;
  3370. }
  3371. else {
  3372. Py_DECREF(tb);
  3373. }
  3374. assert(PyLong_Check(lasti));
  3375. (void)lasti; // Shut up compiler warning if asserts are off
  3376. PyObject *stack[4] = {NULL, exc, val, tb};
  3377. res = PyObject_Vectorcall(exit_func, stack + 1,
  3378. 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  3379. if (res == NULL) goto error;
  3380. #line 3565 "Python/generated_cases.c.h"
  3381. STACK_GROW(1);
  3382. stack_pointer[-1] = res;
  3383. DISPATCH();
  3384. }
  3385. TARGET(PUSH_EXC_INFO) {
  3386. PyObject *new_exc = stack_pointer[-1];
  3387. PyObject *prev_exc;
  3388. #line 2543 "Python/bytecodes.c"
  3389. _PyErr_StackItem *exc_info = tstate->exc_info;
  3390. if (exc_info->exc_value != NULL) {
  3391. prev_exc = exc_info->exc_value;
  3392. }
  3393. else {
  3394. prev_exc = Py_None;
  3395. }
  3396. assert(PyExceptionInstance_Check(new_exc));
  3397. exc_info->exc_value = Py_NewRef(new_exc);
  3398. #line 3584 "Python/generated_cases.c.h"
  3399. STACK_GROW(1);
  3400. stack_pointer[-1] = new_exc;
  3401. stack_pointer[-2] = prev_exc;
  3402. DISPATCH();
  3403. }
  3404. TARGET(LOAD_ATTR_METHOD_WITH_VALUES) {
  3405. PyObject *self = stack_pointer[-1];
  3406. PyObject *res2 = NULL;
  3407. PyObject *res;
  3408. uint32_t type_version = read_u32(&next_instr[1].cache);
  3409. uint32_t keys_version = read_u32(&next_instr[3].cache);
  3410. PyObject *descr = read_obj(&next_instr[5].cache);
  3411. #line 2555 "Python/bytecodes.c"
  3412. /* Cached method object */
  3413. PyTypeObject *self_cls = Py_TYPE(self);
  3414. assert(type_version != 0);
  3415. DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
  3416. assert(self_cls->tp_flags & Py_TPFLAGS_MANAGED_DICT);
  3417. PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(self);
  3418. DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
  3419. PyHeapTypeObject *self_heap_type = (PyHeapTypeObject *)self_cls;
  3420. DEOPT_IF(self_heap_type->ht_cached_keys->dk_version !=
  3421. keys_version, LOAD_ATTR);
  3422. STAT_INC(LOAD_ATTR, hit);
  3423. assert(descr != NULL);
  3424. res2 = Py_NewRef(descr);
  3425. assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR));
  3426. res = self;
  3427. assert(oparg & 1);
  3428. #line 3615 "Python/generated_cases.c.h"
  3429. STACK_GROW(((oparg & 1) ? 1 : 0));
  3430. stack_pointer[-1] = res;
  3431. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  3432. next_instr += 9;
  3433. DISPATCH();
  3434. }
  3435. TARGET(LOAD_ATTR_METHOD_NO_DICT) {
  3436. PyObject *self = stack_pointer[-1];
  3437. PyObject *res2 = NULL;
  3438. PyObject *res;
  3439. uint32_t type_version = read_u32(&next_instr[1].cache);
  3440. PyObject *descr = read_obj(&next_instr[5].cache);
  3441. #line 2574 "Python/bytecodes.c"
  3442. PyTypeObject *self_cls = Py_TYPE(self);
  3443. DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
  3444. assert(self_cls->tp_dictoffset == 0);
  3445. STAT_INC(LOAD_ATTR, hit);
  3446. assert(descr != NULL);
  3447. assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR));
  3448. res2 = Py_NewRef(descr);
  3449. res = self;
  3450. assert(oparg & 1);
  3451. #line 3639 "Python/generated_cases.c.h"
  3452. STACK_GROW(((oparg & 1) ? 1 : 0));
  3453. stack_pointer[-1] = res;
  3454. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  3455. next_instr += 9;
  3456. DISPATCH();
  3457. }
  3458. TARGET(LOAD_ATTR_METHOD_LAZY_DICT) {
  3459. PyObject *self = stack_pointer[-1];
  3460. PyObject *res2 = NULL;
  3461. PyObject *res;
  3462. uint32_t type_version = read_u32(&next_instr[1].cache);
  3463. PyObject *descr = read_obj(&next_instr[5].cache);
  3464. #line 2586 "Python/bytecodes.c"
  3465. PyTypeObject *self_cls = Py_TYPE(self);
  3466. DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
  3467. Py_ssize_t dictoffset = self_cls->tp_dictoffset;
  3468. assert(dictoffset > 0);
  3469. PyObject *dict = *(PyObject **)((char *)self + dictoffset);
  3470. /* This object has a __dict__, just not yet created */
  3471. DEOPT_IF(dict != NULL, LOAD_ATTR);
  3472. STAT_INC(LOAD_ATTR, hit);
  3473. assert(descr != NULL);
  3474. assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR));
  3475. res2 = Py_NewRef(descr);
  3476. res = self;
  3477. assert(oparg & 1);
  3478. #line 3667 "Python/generated_cases.c.h"
  3479. STACK_GROW(((oparg & 1) ? 1 : 0));
  3480. stack_pointer[-1] = res;
  3481. if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
  3482. next_instr += 9;
  3483. DISPATCH();
  3484. }
  3485. TARGET(KW_NAMES) {
  3486. #line 2602 "Python/bytecodes.c"
  3487. assert(kwnames == NULL);
  3488. assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts));
  3489. kwnames = GETITEM(frame->f_code->co_consts, oparg);
  3490. #line 3680 "Python/generated_cases.c.h"
  3491. DISPATCH();
  3492. }
  3493. TARGET(INSTRUMENTED_CALL) {
  3494. #line 2608 "Python/bytecodes.c"
  3495. int is_meth = PEEK(oparg+2) != NULL;
  3496. int total_args = oparg + is_meth;
  3497. PyObject *function = PEEK(total_args + 1);
  3498. PyObject *arg = total_args == 0 ?
  3499. &_PyInstrumentation_MISSING : PEEK(total_args);
  3500. int err = _Py_call_instrumentation_2args(
  3501. tstate, PY_MONITORING_EVENT_CALL,
  3502. frame, next_instr-1, function, arg);
  3503. if (err) goto error;
  3504. _PyCallCache *cache = (_PyCallCache *)next_instr;
  3505. INCREMENT_ADAPTIVE_COUNTER(cache->counter);
  3506. GO_TO_INSTRUCTION(CALL);
  3507. #line 3698 "Python/generated_cases.c.h"
  3508. }
  3509. TARGET(CALL) {
  3510. PREDICTED(CALL);
  3511. static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
  3512. PyObject **args = (stack_pointer - oparg);
  3513. PyObject *callable = stack_pointer[-(1 + oparg)];
  3514. PyObject *method = stack_pointer[-(2 + oparg)];
  3515. PyObject *res;
  3516. #line 2653 "Python/bytecodes.c"
  3517. int is_meth = method != NULL;
  3518. int total_args = oparg;
  3519. if (is_meth) {
  3520. callable = method;
  3521. args--;
  3522. total_args++;
  3523. }
  3524. #if ENABLE_SPECIALIZATION
  3525. _PyCallCache *cache = (_PyCallCache *)next_instr;
  3526. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  3527. next_instr--;
  3528. _Py_Specialize_Call(callable, next_instr, total_args, kwnames);
  3529. DISPATCH_SAME_OPARG();
  3530. }
  3531. STAT_INC(CALL, deferred);
  3532. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  3533. #endif /* ENABLE_SPECIALIZATION */
  3534. if (!is_meth && Py_TYPE(callable) == &PyMethod_Type) {
  3535. is_meth = 1; // For consistenct; it's dead, though
  3536. args--;
  3537. total_args++;
  3538. PyObject *self = ((PyMethodObject *)callable)->im_self;
  3539. args[0] = Py_NewRef(self);
  3540. method = ((PyMethodObject *)callable)->im_func;
  3541. args[-1] = Py_NewRef(method);
  3542. Py_DECREF(callable);
  3543. callable = method;
  3544. }
  3545. int positional_args = total_args - KWNAMES_LEN();
  3546. // Check if the call can be inlined or not
  3547. if (Py_TYPE(callable) == &PyFunction_Type &&
  3548. tstate->interp->eval_frame == NULL &&
  3549. ((PyFunctionObject *)callable)->vectorcall == _PyFunction_Vectorcall)
  3550. {
  3551. int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(callable))->co_flags;
  3552. PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(callable));
  3553. _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit(
  3554. tstate, (PyFunctionObject *)callable, locals,
  3555. args, positional_args, kwnames
  3556. );
  3557. kwnames = NULL;
  3558. // Manipulate stack directly since we leave using DISPATCH_INLINED().
  3559. STACK_SHRINK(oparg + 2);
  3560. // The frame has stolen all the arguments from the stack,
  3561. // so there is no need to clean them up.
  3562. if (new_frame == NULL) {
  3563. goto error;
  3564. }
  3565. JUMPBY(INLINE_CACHE_ENTRIES_CALL);
  3566. frame->return_offset = 0;
  3567. DISPATCH_INLINED(new_frame);
  3568. }
  3569. /* Callable is not a normal Python function */
  3570. res = PyObject_Vectorcall(
  3571. callable, args,
  3572. positional_args | PY_VECTORCALL_ARGUMENTS_OFFSET,
  3573. kwnames);
  3574. if (opcode == INSTRUMENTED_CALL) {
  3575. PyObject *arg = total_args == 0 ?
  3576. &_PyInstrumentation_MISSING : PEEK(total_args);
  3577. if (res == NULL) {
  3578. _Py_call_instrumentation_exc2(
  3579. tstate, PY_MONITORING_EVENT_C_RAISE,
  3580. frame, next_instr-1, callable, arg);
  3581. }
  3582. else {
  3583. int err = _Py_call_instrumentation_2args(
  3584. tstate, PY_MONITORING_EVENT_C_RETURN,
  3585. frame, next_instr-1, callable, arg);
  3586. if (err < 0) {
  3587. Py_CLEAR(res);
  3588. }
  3589. }
  3590. }
  3591. kwnames = NULL;
  3592. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3593. Py_DECREF(callable);
  3594. for (int i = 0; i < total_args; i++) {
  3595. Py_DECREF(args[i]);
  3596. }
  3597. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3598. #line 3790 "Python/generated_cases.c.h"
  3599. STACK_SHRINK(oparg);
  3600. STACK_SHRINK(1);
  3601. stack_pointer[-1] = res;
  3602. next_instr += 3;
  3603. CHECK_EVAL_BREAKER();
  3604. DISPATCH();
  3605. }
  3606. TARGET(CALL_BOUND_METHOD_EXACT_ARGS) {
  3607. PyObject *callable = stack_pointer[-(1 + oparg)];
  3608. PyObject *method = stack_pointer[-(2 + oparg)];
  3609. #line 2741 "Python/bytecodes.c"
  3610. DEOPT_IF(method != NULL, CALL);
  3611. DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL);
  3612. STAT_INC(CALL, hit);
  3613. PyObject *self = ((PyMethodObject *)callable)->im_self;
  3614. PEEK(oparg + 1) = Py_NewRef(self); // callable
  3615. PyObject *meth = ((PyMethodObject *)callable)->im_func;
  3616. PEEK(oparg + 2) = Py_NewRef(meth); // method
  3617. Py_DECREF(callable);
  3618. GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS);
  3619. #line 3812 "Python/generated_cases.c.h"
  3620. }
  3621. TARGET(CALL_PY_EXACT_ARGS) {
  3622. PREDICTED(CALL_PY_EXACT_ARGS);
  3623. PyObject **args = (stack_pointer - oparg);
  3624. PyObject *callable = stack_pointer[-(1 + oparg)];
  3625. PyObject *method = stack_pointer[-(2 + oparg)];
  3626. uint32_t func_version = read_u32(&next_instr[1].cache);
  3627. #line 2753 "Python/bytecodes.c"
  3628. assert(kwnames == NULL);
  3629. DEOPT_IF(tstate->interp->eval_frame, CALL);
  3630. int is_meth = method != NULL;
  3631. int argcount = oparg;
  3632. if (is_meth) {
  3633. callable = method;
  3634. args--;
  3635. argcount++;
  3636. }
  3637. DEOPT_IF(!PyFunction_Check(callable), CALL);
  3638. PyFunctionObject *func = (PyFunctionObject *)callable;
  3639. DEOPT_IF(func->func_version != func_version, CALL);
  3640. PyCodeObject *code = (PyCodeObject *)func->func_code;
  3641. DEOPT_IF(code->co_argcount != argcount, CALL);
  3642. DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
  3643. STAT_INC(CALL, hit);
  3644. _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, func, argcount);
  3645. for (int i = 0; i < argcount; i++) {
  3646. new_frame->localsplus[i] = args[i];
  3647. }
  3648. // Manipulate stack directly since we leave using DISPATCH_INLINED().
  3649. STACK_SHRINK(oparg + 2);
  3650. JUMPBY(INLINE_CACHE_ENTRIES_CALL);
  3651. frame->return_offset = 0;
  3652. DISPATCH_INLINED(new_frame);
  3653. #line 3847 "Python/generated_cases.c.h"
  3654. }
  3655. TARGET(CALL_PY_WITH_DEFAULTS) {
  3656. PyObject **args = (stack_pointer - oparg);
  3657. PyObject *callable = stack_pointer[-(1 + oparg)];
  3658. PyObject *method = stack_pointer[-(2 + oparg)];
  3659. uint32_t func_version = read_u32(&next_instr[1].cache);
  3660. #line 2781 "Python/bytecodes.c"
  3661. assert(kwnames == NULL);
  3662. DEOPT_IF(tstate->interp->eval_frame, CALL);
  3663. int is_meth = method != NULL;
  3664. int argcount = oparg;
  3665. if (is_meth) {
  3666. callable = method;
  3667. args--;
  3668. argcount++;
  3669. }
  3670. DEOPT_IF(!PyFunction_Check(callable), CALL);
  3671. PyFunctionObject *func = (PyFunctionObject *)callable;
  3672. DEOPT_IF(func->func_version != func_version, CALL);
  3673. PyCodeObject *code = (PyCodeObject *)func->func_code;
  3674. assert(func->func_defaults);
  3675. assert(PyTuple_CheckExact(func->func_defaults));
  3676. int defcount = (int)PyTuple_GET_SIZE(func->func_defaults);
  3677. assert(defcount <= code->co_argcount);
  3678. int min_args = code->co_argcount - defcount;
  3679. DEOPT_IF(argcount > code->co_argcount, CALL);
  3680. DEOPT_IF(argcount < min_args, CALL);
  3681. DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
  3682. STAT_INC(CALL, hit);
  3683. _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, func, code->co_argcount);
  3684. for (int i = 0; i < argcount; i++) {
  3685. new_frame->localsplus[i] = args[i];
  3686. }
  3687. for (int i = argcount; i < code->co_argcount; i++) {
  3688. PyObject *def = PyTuple_GET_ITEM(func->func_defaults, i - min_args);
  3689. new_frame->localsplus[i] = Py_NewRef(def);
  3690. }
  3691. // Manipulate stack and cache directly since we leave using DISPATCH_INLINED().
  3692. STACK_SHRINK(oparg + 2);
  3693. JUMPBY(INLINE_CACHE_ENTRIES_CALL);
  3694. frame->return_offset = 0;
  3695. DISPATCH_INLINED(new_frame);
  3696. #line 3891 "Python/generated_cases.c.h"
  3697. }
  3698. TARGET(CALL_NO_KW_TYPE_1) {
  3699. PyObject **args = (stack_pointer - oparg);
  3700. PyObject *callable = stack_pointer[-(1 + oparg)];
  3701. PyObject *null = stack_pointer[-(2 + oparg)];
  3702. PyObject *res;
  3703. #line 2819 "Python/bytecodes.c"
  3704. assert(kwnames == NULL);
  3705. assert(oparg == 1);
  3706. DEOPT_IF(null != NULL, CALL);
  3707. PyObject *obj = args[0];
  3708. DEOPT_IF(callable != (PyObject *)&PyType_Type, CALL);
  3709. STAT_INC(CALL, hit);
  3710. res = Py_NewRef(Py_TYPE(obj));
  3711. Py_DECREF(obj);
  3712. Py_DECREF(&PyType_Type); // I.e., callable
  3713. #line 3909 "Python/generated_cases.c.h"
  3714. STACK_SHRINK(oparg);
  3715. STACK_SHRINK(1);
  3716. stack_pointer[-1] = res;
  3717. next_instr += 3;
  3718. DISPATCH();
  3719. }
  3720. TARGET(CALL_NO_KW_STR_1) {
  3721. PyObject **args = (stack_pointer - oparg);
  3722. PyObject *callable = stack_pointer[-(1 + oparg)];
  3723. PyObject *null = stack_pointer[-(2 + oparg)];
  3724. PyObject *res;
  3725. #line 2831 "Python/bytecodes.c"
  3726. assert(kwnames == NULL);
  3727. assert(oparg == 1);
  3728. DEOPT_IF(null != NULL, CALL);
  3729. DEOPT_IF(callable != (PyObject *)&PyUnicode_Type, CALL);
  3730. STAT_INC(CALL, hit);
  3731. PyObject *arg = args[0];
  3732. res = PyObject_Str(arg);
  3733. Py_DECREF(arg);
  3734. Py_DECREF(&PyUnicode_Type); // I.e., callable
  3735. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3736. #line 3933 "Python/generated_cases.c.h"
  3737. STACK_SHRINK(oparg);
  3738. STACK_SHRINK(1);
  3739. stack_pointer[-1] = res;
  3740. next_instr += 3;
  3741. CHECK_EVAL_BREAKER();
  3742. DISPATCH();
  3743. }
  3744. TARGET(CALL_NO_KW_TUPLE_1) {
  3745. PyObject **args = (stack_pointer - oparg);
  3746. PyObject *callable = stack_pointer[-(1 + oparg)];
  3747. PyObject *null = stack_pointer[-(2 + oparg)];
  3748. PyObject *res;
  3749. #line 2845 "Python/bytecodes.c"
  3750. assert(kwnames == NULL);
  3751. assert(oparg == 1);
  3752. DEOPT_IF(null != NULL, CALL);
  3753. DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL);
  3754. STAT_INC(CALL, hit);
  3755. PyObject *arg = args[0];
  3756. res = PySequence_Tuple(arg);
  3757. Py_DECREF(arg);
  3758. Py_DECREF(&PyTuple_Type); // I.e., tuple
  3759. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3760. #line 3958 "Python/generated_cases.c.h"
  3761. STACK_SHRINK(oparg);
  3762. STACK_SHRINK(1);
  3763. stack_pointer[-1] = res;
  3764. next_instr += 3;
  3765. CHECK_EVAL_BREAKER();
  3766. DISPATCH();
  3767. }
  3768. TARGET(CALL_BUILTIN_CLASS) {
  3769. PyObject **args = (stack_pointer - oparg);
  3770. PyObject *callable = stack_pointer[-(1 + oparg)];
  3771. PyObject *method = stack_pointer[-(2 + oparg)];
  3772. PyObject *res;
  3773. #line 2859 "Python/bytecodes.c"
  3774. int is_meth = method != NULL;
  3775. int total_args = oparg;
  3776. if (is_meth) {
  3777. callable = method;
  3778. args--;
  3779. total_args++;
  3780. }
  3781. int kwnames_len = KWNAMES_LEN();
  3782. DEOPT_IF(!PyType_Check(callable), CALL);
  3783. PyTypeObject *tp = (PyTypeObject *)callable;
  3784. DEOPT_IF(tp->tp_vectorcall == NULL, CALL);
  3785. STAT_INC(CALL, hit);
  3786. res = tp->tp_vectorcall((PyObject *)tp, args,
  3787. total_args - kwnames_len, kwnames);
  3788. kwnames = NULL;
  3789. /* Free the arguments. */
  3790. for (int i = 0; i < total_args; i++) {
  3791. Py_DECREF(args[i]);
  3792. }
  3793. Py_DECREF(tp);
  3794. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3795. #line 3994 "Python/generated_cases.c.h"
  3796. STACK_SHRINK(oparg);
  3797. STACK_SHRINK(1);
  3798. stack_pointer[-1] = res;
  3799. next_instr += 3;
  3800. CHECK_EVAL_BREAKER();
  3801. DISPATCH();
  3802. }
  3803. TARGET(CALL_NO_KW_BUILTIN_O) {
  3804. PyObject **args = (stack_pointer - oparg);
  3805. PyObject *callable = stack_pointer[-(1 + oparg)];
  3806. PyObject *method = stack_pointer[-(2 + oparg)];
  3807. PyObject *res;
  3808. #line 2884 "Python/bytecodes.c"
  3809. /* Builtin METH_O functions */
  3810. assert(kwnames == NULL);
  3811. int is_meth = method != NULL;
  3812. int total_args = oparg;
  3813. if (is_meth) {
  3814. callable = method;
  3815. args--;
  3816. total_args++;
  3817. }
  3818. DEOPT_IF(total_args != 1, CALL);
  3819. DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
  3820. DEOPT_IF(PyCFunction_GET_FLAGS(callable) != METH_O, CALL);
  3821. STAT_INC(CALL, hit);
  3822. PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
  3823. // This is slower but CPython promises to check all non-vectorcall
  3824. // function calls.
  3825. if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
  3826. goto error;
  3827. }
  3828. PyObject *arg = args[0];
  3829. res = _PyCFunction_TrampolineCall(cfunc, PyCFunction_GET_SELF(callable), arg);
  3830. _Py_LeaveRecursiveCallTstate(tstate);
  3831. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3832. Py_DECREF(arg);
  3833. Py_DECREF(callable);
  3834. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3835. #line 4036 "Python/generated_cases.c.h"
  3836. STACK_SHRINK(oparg);
  3837. STACK_SHRINK(1);
  3838. stack_pointer[-1] = res;
  3839. next_instr += 3;
  3840. CHECK_EVAL_BREAKER();
  3841. DISPATCH();
  3842. }
  3843. TARGET(CALL_NO_KW_BUILTIN_FAST) {
  3844. PyObject **args = (stack_pointer - oparg);
  3845. PyObject *callable = stack_pointer[-(1 + oparg)];
  3846. PyObject *method = stack_pointer[-(2 + oparg)];
  3847. PyObject *res;
  3848. #line 2915 "Python/bytecodes.c"
  3849. /* Builtin METH_FASTCALL functions, without keywords */
  3850. assert(kwnames == NULL);
  3851. int is_meth = method != NULL;
  3852. int total_args = oparg;
  3853. if (is_meth) {
  3854. callable = method;
  3855. args--;
  3856. total_args++;
  3857. }
  3858. DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
  3859. DEOPT_IF(PyCFunction_GET_FLAGS(callable) != METH_FASTCALL, CALL);
  3860. STAT_INC(CALL, hit);
  3861. PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
  3862. /* res = func(self, args, nargs) */
  3863. res = ((_PyCFunctionFast)(void(*)(void))cfunc)(
  3864. PyCFunction_GET_SELF(callable),
  3865. args,
  3866. total_args);
  3867. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3868. /* Free the arguments. */
  3869. for (int i = 0; i < total_args; i++) {
  3870. Py_DECREF(args[i]);
  3871. }
  3872. Py_DECREF(callable);
  3873. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3874. /* Not deopting because this doesn't mean our optimization was
  3875. wrong. `res` can be NULL for valid reasons. Eg. getattr(x,
  3876. 'invalid'). In those cases an exception is set, so we must
  3877. handle it.
  3878. */
  3879. #line 4082 "Python/generated_cases.c.h"
  3880. STACK_SHRINK(oparg);
  3881. STACK_SHRINK(1);
  3882. stack_pointer[-1] = res;
  3883. next_instr += 3;
  3884. CHECK_EVAL_BREAKER();
  3885. DISPATCH();
  3886. }
  3887. TARGET(CALL_BUILTIN_FAST_WITH_KEYWORDS) {
  3888. PyObject **args = (stack_pointer - oparg);
  3889. PyObject *callable = stack_pointer[-(1 + oparg)];
  3890. PyObject *method = stack_pointer[-(2 + oparg)];
  3891. PyObject *res;
  3892. #line 2950 "Python/bytecodes.c"
  3893. /* Builtin METH_FASTCALL | METH_KEYWORDS functions */
  3894. int is_meth = method != NULL;
  3895. int total_args = oparg;
  3896. if (is_meth) {
  3897. callable = method;
  3898. args--;
  3899. total_args++;
  3900. }
  3901. DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
  3902. DEOPT_IF(PyCFunction_GET_FLAGS(callable) !=
  3903. (METH_FASTCALL | METH_KEYWORDS), CALL);
  3904. STAT_INC(CALL, hit);
  3905. /* res = func(self, args, nargs, kwnames) */
  3906. _PyCFunctionFastWithKeywords cfunc =
  3907. (_PyCFunctionFastWithKeywords)(void(*)(void))
  3908. PyCFunction_GET_FUNCTION(callable);
  3909. res = cfunc(
  3910. PyCFunction_GET_SELF(callable),
  3911. args,
  3912. total_args - KWNAMES_LEN(),
  3913. kwnames
  3914. );
  3915. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3916. kwnames = NULL;
  3917. /* Free the arguments. */
  3918. for (int i = 0; i < total_args; i++) {
  3919. Py_DECREF(args[i]);
  3920. }
  3921. Py_DECREF(callable);
  3922. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3923. #line 4128 "Python/generated_cases.c.h"
  3924. STACK_SHRINK(oparg);
  3925. STACK_SHRINK(1);
  3926. stack_pointer[-1] = res;
  3927. next_instr += 3;
  3928. CHECK_EVAL_BREAKER();
  3929. DISPATCH();
  3930. }
  3931. TARGET(CALL_NO_KW_LEN) {
  3932. PyObject **args = (stack_pointer - oparg);
  3933. PyObject *callable = stack_pointer[-(1 + oparg)];
  3934. PyObject *method = stack_pointer[-(2 + oparg)];
  3935. PyObject *res;
  3936. #line 2985 "Python/bytecodes.c"
  3937. assert(kwnames == NULL);
  3938. /* len(o) */
  3939. int is_meth = method != NULL;
  3940. int total_args = oparg;
  3941. if (is_meth) {
  3942. callable = method;
  3943. args--;
  3944. total_args++;
  3945. }
  3946. DEOPT_IF(total_args != 1, CALL);
  3947. PyInterpreterState *interp = _PyInterpreterState_GET();
  3948. DEOPT_IF(callable != interp->callable_cache.len, CALL);
  3949. STAT_INC(CALL, hit);
  3950. PyObject *arg = args[0];
  3951. Py_ssize_t len_i = PyObject_Length(arg);
  3952. if (len_i < 0) {
  3953. goto error;
  3954. }
  3955. res = PyLong_FromSsize_t(len_i);
  3956. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3957. Py_DECREF(callable);
  3958. Py_DECREF(arg);
  3959. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3960. #line 4167 "Python/generated_cases.c.h"
  3961. STACK_SHRINK(oparg);
  3962. STACK_SHRINK(1);
  3963. stack_pointer[-1] = res;
  3964. next_instr += 3;
  3965. DISPATCH();
  3966. }
  3967. TARGET(CALL_NO_KW_ISINSTANCE) {
  3968. PyObject **args = (stack_pointer - oparg);
  3969. PyObject *callable = stack_pointer[-(1 + oparg)];
  3970. PyObject *method = stack_pointer[-(2 + oparg)];
  3971. PyObject *res;
  3972. #line 3012 "Python/bytecodes.c"
  3973. assert(kwnames == NULL);
  3974. /* isinstance(o, o2) */
  3975. int is_meth = method != NULL;
  3976. int total_args = oparg;
  3977. if (is_meth) {
  3978. callable = method;
  3979. args--;
  3980. total_args++;
  3981. }
  3982. DEOPT_IF(total_args != 2, CALL);
  3983. PyInterpreterState *interp = _PyInterpreterState_GET();
  3984. DEOPT_IF(callable != interp->callable_cache.isinstance, CALL);
  3985. STAT_INC(CALL, hit);
  3986. PyObject *cls = args[1];
  3987. PyObject *inst = args[0];
  3988. int retval = PyObject_IsInstance(inst, cls);
  3989. if (retval < 0) {
  3990. goto error;
  3991. }
  3992. res = PyBool_FromLong(retval);
  3993. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  3994. Py_DECREF(inst);
  3995. Py_DECREF(cls);
  3996. Py_DECREF(callable);
  3997. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  3998. #line 4207 "Python/generated_cases.c.h"
  3999. STACK_SHRINK(oparg);
  4000. STACK_SHRINK(1);
  4001. stack_pointer[-1] = res;
  4002. next_instr += 3;
  4003. DISPATCH();
  4004. }
  4005. TARGET(CALL_NO_KW_LIST_APPEND) {
  4006. PyObject **args = (stack_pointer - oparg);
  4007. PyObject *self = stack_pointer[-(1 + oparg)];
  4008. PyObject *method = stack_pointer[-(2 + oparg)];
  4009. #line 3042 "Python/bytecodes.c"
  4010. assert(kwnames == NULL);
  4011. assert(oparg == 1);
  4012. PyInterpreterState *interp = _PyInterpreterState_GET();
  4013. DEOPT_IF(method != interp->callable_cache.list_append, CALL);
  4014. assert(self != NULL);
  4015. DEOPT_IF(!PyList_Check(self), CALL);
  4016. STAT_INC(CALL, hit);
  4017. if (_PyList_AppendTakeRef((PyListObject *)self, args[0]) < 0) {
  4018. goto pop_1_error; // Since arg is DECREF'ed already
  4019. }
  4020. Py_DECREF(self);
  4021. Py_DECREF(method);
  4022. STACK_SHRINK(3);
  4023. // CALL + POP_TOP
  4024. JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1);
  4025. assert(next_instr[-1].op.code == POP_TOP);
  4026. DISPATCH();
  4027. #line 4237 "Python/generated_cases.c.h"
  4028. }
  4029. TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) {
  4030. PyObject **args = (stack_pointer - oparg);
  4031. PyObject *method = stack_pointer[-(2 + oparg)];
  4032. PyObject *res;
  4033. #line 3062 "Python/bytecodes.c"
  4034. assert(kwnames == NULL);
  4035. int is_meth = method != NULL;
  4036. int total_args = oparg;
  4037. if (is_meth) {
  4038. args--;
  4039. total_args++;
  4040. }
  4041. PyMethodDescrObject *callable =
  4042. (PyMethodDescrObject *)PEEK(total_args + 1);
  4043. DEOPT_IF(total_args != 2, CALL);
  4044. DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
  4045. PyMethodDef *meth = callable->d_method;
  4046. DEOPT_IF(meth->ml_flags != METH_O, CALL);
  4047. PyObject *arg = args[1];
  4048. PyObject *self = args[0];
  4049. DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
  4050. STAT_INC(CALL, hit);
  4051. PyCFunction cfunc = meth->ml_meth;
  4052. // This is slower but CPython promises to check all non-vectorcall
  4053. // function calls.
  4054. if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
  4055. goto error;
  4056. }
  4057. res = _PyCFunction_TrampolineCall(cfunc, self, arg);
  4058. _Py_LeaveRecursiveCallTstate(tstate);
  4059. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  4060. Py_DECREF(self);
  4061. Py_DECREF(arg);
  4062. Py_DECREF(callable);
  4063. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  4064. #line 4275 "Python/generated_cases.c.h"
  4065. STACK_SHRINK(oparg);
  4066. STACK_SHRINK(1);
  4067. stack_pointer[-1] = res;
  4068. next_instr += 3;
  4069. CHECK_EVAL_BREAKER();
  4070. DISPATCH();
  4071. }
  4072. TARGET(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS) {
  4073. PyObject **args = (stack_pointer - oparg);
  4074. PyObject *method = stack_pointer[-(2 + oparg)];
  4075. PyObject *res;
  4076. #line 3096 "Python/bytecodes.c"
  4077. int is_meth = method != NULL;
  4078. int total_args = oparg;
  4079. if (is_meth) {
  4080. args--;
  4081. total_args++;
  4082. }
  4083. PyMethodDescrObject *callable =
  4084. (PyMethodDescrObject *)PEEK(total_args + 1);
  4085. DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
  4086. PyMethodDef *meth = callable->d_method;
  4087. DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL);
  4088. PyTypeObject *d_type = callable->d_common.d_type;
  4089. PyObject *self = args[0];
  4090. DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL);
  4091. STAT_INC(CALL, hit);
  4092. int nargs = total_args - 1;
  4093. _PyCFunctionFastWithKeywords cfunc =
  4094. (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth;
  4095. res = cfunc(self, args + 1, nargs - KWNAMES_LEN(), kwnames);
  4096. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  4097. kwnames = NULL;
  4098. /* Free the arguments. */
  4099. for (int i = 0; i < total_args; i++) {
  4100. Py_DECREF(args[i]);
  4101. }
  4102. Py_DECREF(callable);
  4103. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  4104. #line 4317 "Python/generated_cases.c.h"
  4105. STACK_SHRINK(oparg);
  4106. STACK_SHRINK(1);
  4107. stack_pointer[-1] = res;
  4108. next_instr += 3;
  4109. CHECK_EVAL_BREAKER();
  4110. DISPATCH();
  4111. }
  4112. TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS) {
  4113. PyObject **args = (stack_pointer - oparg);
  4114. PyObject *method = stack_pointer[-(2 + oparg)];
  4115. PyObject *res;
  4116. #line 3128 "Python/bytecodes.c"
  4117. assert(kwnames == NULL);
  4118. assert(oparg == 0 || oparg == 1);
  4119. int is_meth = method != NULL;
  4120. int total_args = oparg;
  4121. if (is_meth) {
  4122. args--;
  4123. total_args++;
  4124. }
  4125. DEOPT_IF(total_args != 1, CALL);
  4126. PyMethodDescrObject *callable = (PyMethodDescrObject *)SECOND();
  4127. DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
  4128. PyMethodDef *meth = callable->d_method;
  4129. PyObject *self = args[0];
  4130. DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
  4131. DEOPT_IF(meth->ml_flags != METH_NOARGS, CALL);
  4132. STAT_INC(CALL, hit);
  4133. PyCFunction cfunc = meth->ml_meth;
  4134. // This is slower but CPython promises to check all non-vectorcall
  4135. // function calls.
  4136. if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
  4137. goto error;
  4138. }
  4139. res = _PyCFunction_TrampolineCall(cfunc, self, NULL);
  4140. _Py_LeaveRecursiveCallTstate(tstate);
  4141. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  4142. Py_DECREF(self);
  4143. Py_DECREF(callable);
  4144. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  4145. #line 4359 "Python/generated_cases.c.h"
  4146. STACK_SHRINK(oparg);
  4147. STACK_SHRINK(1);
  4148. stack_pointer[-1] = res;
  4149. next_instr += 3;
  4150. CHECK_EVAL_BREAKER();
  4151. DISPATCH();
  4152. }
  4153. TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_FAST) {
  4154. PyObject **args = (stack_pointer - oparg);
  4155. PyObject *method = stack_pointer[-(2 + oparg)];
  4156. PyObject *res;
  4157. #line 3160 "Python/bytecodes.c"
  4158. assert(kwnames == NULL);
  4159. int is_meth = method != NULL;
  4160. int total_args = oparg;
  4161. if (is_meth) {
  4162. args--;
  4163. total_args++;
  4164. }
  4165. PyMethodDescrObject *callable =
  4166. (PyMethodDescrObject *)PEEK(total_args + 1);
  4167. /* Builtin METH_FASTCALL methods, without keywords */
  4168. DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
  4169. PyMethodDef *meth = callable->d_method;
  4170. DEOPT_IF(meth->ml_flags != METH_FASTCALL, CALL);
  4171. PyObject *self = args[0];
  4172. DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
  4173. STAT_INC(CALL, hit);
  4174. _PyCFunctionFast cfunc =
  4175. (_PyCFunctionFast)(void(*)(void))meth->ml_meth;
  4176. int nargs = total_args - 1;
  4177. res = cfunc(self, args + 1, nargs);
  4178. assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
  4179. /* Clear the stack of the arguments. */
  4180. for (int i = 0; i < total_args; i++) {
  4181. Py_DECREF(args[i]);
  4182. }
  4183. Py_DECREF(callable);
  4184. if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
  4185. #line 4400 "Python/generated_cases.c.h"
  4186. STACK_SHRINK(oparg);
  4187. STACK_SHRINK(1);
  4188. stack_pointer[-1] = res;
  4189. next_instr += 3;
  4190. CHECK_EVAL_BREAKER();
  4191. DISPATCH();
  4192. }
  4193. TARGET(INSTRUMENTED_CALL_FUNCTION_EX) {
  4194. #line 3191 "Python/bytecodes.c"
  4195. GO_TO_INSTRUCTION(CALL_FUNCTION_EX);
  4196. #line 4412 "Python/generated_cases.c.h"
  4197. }
  4198. TARGET(CALL_FUNCTION_EX) {
  4199. PREDICTED(CALL_FUNCTION_EX);
  4200. PyObject *kwargs = (oparg & 1) ? stack_pointer[-(((oparg & 1) ? 1 : 0))] : NULL;
  4201. PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))];
  4202. PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))];
  4203. PyObject *result;
  4204. #line 3195 "Python/bytecodes.c"
  4205. // DICT_MERGE is called before this opcode if there are kwargs.
  4206. // It converts all dict subtypes in kwargs into regular dicts.
  4207. assert(kwargs == NULL || PyDict_CheckExact(kwargs));
  4208. if (!PyTuple_CheckExact(callargs)) {
  4209. if (check_args_iterable(tstate, func, callargs) < 0) {
  4210. goto error;
  4211. }
  4212. PyObject *tuple = PySequence_Tuple(callargs);
  4213. if (tuple == NULL) {
  4214. goto error;
  4215. }
  4216. Py_SETREF(callargs, tuple);
  4217. }
  4218. assert(PyTuple_CheckExact(callargs));
  4219. EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
  4220. if (opcode == INSTRUMENTED_CALL_FUNCTION_EX) {
  4221. PyObject *arg = PyTuple_GET_SIZE(callargs) > 0 ?
  4222. PyTuple_GET_ITEM(callargs, 0) : &_PyInstrumentation_MISSING;
  4223. int err = _Py_call_instrumentation_2args(
  4224. tstate, PY_MONITORING_EVENT_CALL,
  4225. frame, next_instr-1, func, arg);
  4226. if (err) goto error;
  4227. result = PyObject_Call(func, callargs, kwargs);
  4228. if (!PyFunction_Check(func) && !PyMethod_Check(func)) {
  4229. if (result == NULL) {
  4230. _Py_call_instrumentation_exc2(
  4231. tstate, PY_MONITORING_EVENT_C_RAISE,
  4232. frame, next_instr-1, func, arg);
  4233. }
  4234. else {
  4235. int err = _Py_call_instrumentation_2args(
  4236. tstate, PY_MONITORING_EVENT_C_RETURN,
  4237. frame, next_instr-1, func, arg);
  4238. if (err < 0) {
  4239. Py_CLEAR(result);
  4240. }
  4241. }
  4242. }
  4243. }
  4244. else {
  4245. if (Py_TYPE(func) == &PyFunction_Type &&
  4246. tstate->interp->eval_frame == NULL &&
  4247. ((PyFunctionObject *)func)->vectorcall == _PyFunction_Vectorcall) {
  4248. assert(PyTuple_CheckExact(callargs));
  4249. Py_ssize_t nargs = PyTuple_GET_SIZE(callargs);
  4250. int code_flags = ((PyCodeObject *)PyFunction_GET_CODE(func))->co_flags;
  4251. PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(func));
  4252. _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit_Ex(tstate,
  4253. (PyFunctionObject *)func, locals,
  4254. nargs, callargs, kwargs);
  4255. // Need to manually shrink the stack since we exit with DISPATCH_INLINED.
  4256. STACK_SHRINK(oparg + 3);
  4257. if (new_frame == NULL) {
  4258. goto error;
  4259. }
  4260. frame->return_offset = 0;
  4261. DISPATCH_INLINED(new_frame);
  4262. }
  4263. result = PyObject_Call(func, callargs, kwargs);
  4264. }
  4265. #line 4483 "Python/generated_cases.c.h"
  4266. Py_DECREF(func);
  4267. Py_DECREF(callargs);
  4268. Py_XDECREF(kwargs);
  4269. #line 3257 "Python/bytecodes.c"
  4270. assert(PEEK(3 + (oparg & 1)) == NULL);
  4271. if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; }
  4272. #line 4490 "Python/generated_cases.c.h"
  4273. STACK_SHRINK(((oparg & 1) ? 1 : 0));
  4274. STACK_SHRINK(2);
  4275. stack_pointer[-1] = result;
  4276. CHECK_EVAL_BREAKER();
  4277. DISPATCH();
  4278. }
  4279. TARGET(MAKE_FUNCTION) {
  4280. PyObject *codeobj = stack_pointer[-1];
  4281. PyObject *closure = (oparg & 0x08) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0))] : NULL;
  4282. PyObject *annotations = (oparg & 0x04) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0))] : NULL;
  4283. PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL;
  4284. PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL;
  4285. PyObject *func;
  4286. #line 3267 "Python/bytecodes.c"
  4287. PyFunctionObject *func_obj = (PyFunctionObject *)
  4288. PyFunction_New(codeobj, GLOBALS());
  4289. Py_DECREF(codeobj);
  4290. if (func_obj == NULL) {
  4291. goto error;
  4292. }
  4293. if (oparg & 0x08) {
  4294. assert(PyTuple_CheckExact(closure));
  4295. func_obj->func_closure = closure;
  4296. }
  4297. if (oparg & 0x04) {
  4298. assert(PyTuple_CheckExact(annotations));
  4299. func_obj->func_annotations = annotations;
  4300. }
  4301. if (oparg & 0x02) {
  4302. assert(PyDict_CheckExact(kwdefaults));
  4303. func_obj->func_kwdefaults = kwdefaults;
  4304. }
  4305. if (oparg & 0x01) {
  4306. assert(PyTuple_CheckExact(defaults));
  4307. func_obj->func_defaults = defaults;
  4308. }
  4309. func_obj->func_version = ((PyCodeObject *)codeobj)->co_version;
  4310. func = (PyObject *)func_obj;
  4311. #line 4534 "Python/generated_cases.c.h"
  4312. STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0));
  4313. stack_pointer[-1] = func;
  4314. DISPATCH();
  4315. }
  4316. TARGET(RETURN_GENERATOR) {
  4317. #line 3298 "Python/bytecodes.c"
  4318. assert(PyFunction_Check(frame->f_funcobj));
  4319. PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj;
  4320. PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func);
  4321. if (gen == NULL) {
  4322. goto error;
  4323. }
  4324. assert(EMPTY());
  4325. _PyFrame_SetStackPointer(frame, stack_pointer);
  4326. _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
  4327. _PyFrame_Copy(frame, gen_frame);
  4328. assert(frame->frame_obj == NULL);
  4329. gen->gi_frame_state = FRAME_CREATED;
  4330. gen_frame->owner = FRAME_OWNED_BY_GENERATOR;
  4331. _Py_LeaveRecursiveCallPy(tstate);
  4332. assert(frame != &entry_frame);
  4333. _PyInterpreterFrame *prev = frame->previous;
  4334. _PyThreadState_PopFrame(tstate, frame);
  4335. frame = cframe.current_frame = prev;
  4336. _PyFrame_StackPush(frame, (PyObject *)gen);
  4337. goto resume_frame;
  4338. #line 4562 "Python/generated_cases.c.h"
  4339. }
  4340. TARGET(BUILD_SLICE) {
  4341. PyObject *step = (oparg == 3) ? stack_pointer[-(((oparg == 3) ? 1 : 0))] : NULL;
  4342. PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))];
  4343. PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))];
  4344. PyObject *slice;
  4345. #line 3321 "Python/bytecodes.c"
  4346. slice = PySlice_New(start, stop, step);
  4347. #line 4572 "Python/generated_cases.c.h"
  4348. Py_DECREF(start);
  4349. Py_DECREF(stop);
  4350. Py_XDECREF(step);
  4351. #line 3323 "Python/bytecodes.c"
  4352. if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; }
  4353. #line 4578 "Python/generated_cases.c.h"
  4354. STACK_SHRINK(((oparg == 3) ? 1 : 0));
  4355. STACK_SHRINK(1);
  4356. stack_pointer[-1] = slice;
  4357. DISPATCH();
  4358. }
  4359. TARGET(FORMAT_VALUE) {
  4360. PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL;
  4361. PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))];
  4362. PyObject *result;
  4363. #line 3327 "Python/bytecodes.c"
  4364. /* Handles f-string value formatting. */
  4365. PyObject *(*conv_fn)(PyObject *);
  4366. int which_conversion = oparg & FVC_MASK;
  4367. /* See if any conversion is specified. */
  4368. switch (which_conversion) {
  4369. case FVC_NONE: conv_fn = NULL; break;
  4370. case FVC_STR: conv_fn = PyObject_Str; break;
  4371. case FVC_REPR: conv_fn = PyObject_Repr; break;
  4372. case FVC_ASCII: conv_fn = PyObject_ASCII; break;
  4373. default:
  4374. _PyErr_Format(tstate, PyExc_SystemError,
  4375. "unexpected conversion flag %d",
  4376. which_conversion);
  4377. goto error;
  4378. }
  4379. /* If there's a conversion function, call it and replace
  4380. value with that result. Otherwise, just use value,
  4381. without conversion. */
  4382. if (conv_fn != NULL) {
  4383. result = conv_fn(value);
  4384. Py_DECREF(value);
  4385. if (result == NULL) {
  4386. Py_XDECREF(fmt_spec);
  4387. if (true) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; }
  4388. }
  4389. value = result;
  4390. }
  4391. result = PyObject_Format(value, fmt_spec);
  4392. Py_DECREF(value);
  4393. Py_XDECREF(fmt_spec);
  4394. if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; }
  4395. #line 4624 "Python/generated_cases.c.h"
  4396. STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0));
  4397. stack_pointer[-1] = result;
  4398. DISPATCH();
  4399. }
  4400. TARGET(COPY) {
  4401. PyObject *bottom = stack_pointer[-(1 + (oparg-1))];
  4402. PyObject *top;
  4403. #line 3364 "Python/bytecodes.c"
  4404. assert(oparg > 0);
  4405. top = Py_NewRef(bottom);
  4406. #line 4636 "Python/generated_cases.c.h"
  4407. STACK_GROW(1);
  4408. stack_pointer[-1] = top;
  4409. DISPATCH();
  4410. }
  4411. TARGET(BINARY_OP) {
  4412. PREDICTED(BINARY_OP);
  4413. static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 1, "incorrect cache size");
  4414. PyObject *rhs = stack_pointer[-1];
  4415. PyObject *lhs = stack_pointer[-2];
  4416. PyObject *res;
  4417. #line 3369 "Python/bytecodes.c"
  4418. #if ENABLE_SPECIALIZATION
  4419. _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
  4420. if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
  4421. next_instr--;
  4422. _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, &GETLOCAL(0));
  4423. DISPATCH_SAME_OPARG();
  4424. }
  4425. STAT_INC(BINARY_OP, deferred);
  4426. DECREMENT_ADAPTIVE_COUNTER(cache->counter);
  4427. #endif /* ENABLE_SPECIALIZATION */
  4428. assert(0 <= oparg);
  4429. assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops));
  4430. assert(binary_ops[oparg]);
  4431. res = binary_ops[oparg](lhs, rhs);
  4432. #line 4663 "Python/generated_cases.c.h"
  4433. Py_DECREF(lhs);
  4434. Py_DECREF(rhs);
  4435. #line 3384 "Python/bytecodes.c"
  4436. if (res == NULL) goto pop_2_error;
  4437. #line 4668 "Python/generated_cases.c.h"
  4438. STACK_SHRINK(1);
  4439. stack_pointer[-1] = res;
  4440. next_instr += 1;
  4441. DISPATCH();
  4442. }
  4443. TARGET(SWAP) {
  4444. PyObject *top = stack_pointer[-1];
  4445. PyObject *bottom = stack_pointer[-(2 + (oparg-2))];
  4446. #line 3389 "Python/bytecodes.c"
  4447. assert(oparg >= 2);
  4448. #line 4680 "Python/generated_cases.c.h"
  4449. stack_pointer[-1] = bottom;
  4450. stack_pointer[-(2 + (oparg-2))] = top;
  4451. DISPATCH();
  4452. }
  4453. TARGET(INSTRUMENTED_INSTRUCTION) {
  4454. #line 3393 "Python/bytecodes.c"
  4455. int next_opcode = _Py_call_instrumentation_instruction(
  4456. tstate, frame, next_instr-1);
  4457. if (next_opcode < 0) goto error;
  4458. next_instr--;
  4459. if (_PyOpcode_Caches[next_opcode]) {
  4460. _PyBinaryOpCache *cache = (_PyBinaryOpCache *)(next_instr+1);
  4461. INCREMENT_ADAPTIVE_COUNTER(cache->counter);
  4462. }
  4463. assert(next_opcode > 0 && next_opcode < 256);
  4464. opcode = next_opcode;
  4465. DISPATCH_GOTO();
  4466. #line 4699 "Python/generated_cases.c.h"
  4467. }
  4468. TARGET(INSTRUMENTED_JUMP_FORWARD) {
  4469. #line 3407 "Python/bytecodes.c"
  4470. INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP);
  4471. #line 4705 "Python/generated_cases.c.h"
  4472. DISPATCH();
  4473. }
  4474. TARGET(INSTRUMENTED_JUMP_BACKWARD) {
  4475. #line 3411 "Python/bytecodes.c"
  4476. INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP);
  4477. #line 4712 "Python/generated_cases.c.h"
  4478. CHECK_EVAL_BREAKER();
  4479. DISPATCH();
  4480. }
  4481. TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) {
  4482. #line 3416 "Python/bytecodes.c"
  4483. PyObject *cond = POP();
  4484. int err = PyObject_IsTrue(cond);
  4485. Py_DECREF(cond);
  4486. if (err < 0) goto error;
  4487. _Py_CODEUNIT *here = next_instr-1;
  4488. assert(err == 0 || err == 1);
  4489. int offset = err*oparg;
  4490. INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
  4491. #line 4727 "Python/generated_cases.c.h"
  4492. DISPATCH();
  4493. }
  4494. TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) {
  4495. #line 3427 "Python/bytecodes.c"
  4496. PyObject *cond = POP();
  4497. int err = PyObject_IsTrue(cond);
  4498. Py_DECREF(cond);
  4499. if (err < 0) goto error;
  4500. _Py_CODEUNIT *here = next_instr-1;
  4501. assert(err == 0 || err == 1);
  4502. int offset = (1-err)*oparg;
  4503. INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
  4504. #line 4741 "Python/generated_cases.c.h"
  4505. DISPATCH();
  4506. }
  4507. TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) {
  4508. #line 3438 "Python/bytecodes.c"
  4509. PyObject *value = POP();
  4510. _Py_CODEUNIT *here = next_instr-1;
  4511. int offset;
  4512. if (Py_IsNone(value)) {
  4513. offset = oparg;
  4514. }
  4515. else {
  4516. Py_DECREF(value);
  4517. offset = 0;
  4518. }
  4519. INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
  4520. #line 4758 "Python/generated_cases.c.h"
  4521. DISPATCH();
  4522. }
  4523. TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) {
  4524. #line 3452 "Python/bytecodes.c"
  4525. PyObject *value = POP();
  4526. _Py_CODEUNIT *here = next_instr-1;
  4527. int offset;
  4528. if (Py_IsNone(value)) {
  4529. offset = 0;
  4530. }
  4531. else {
  4532. Py_DECREF(value);
  4533. offset = oparg;
  4534. }
  4535. INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
  4536. #line 4775 "Python/generated_cases.c.h"
  4537. DISPATCH();
  4538. }
  4539. TARGET(EXTENDED_ARG) {
  4540. #line 3466 "Python/bytecodes.c"
  4541. assert(oparg);
  4542. opcode = next_instr->op.code;
  4543. oparg = oparg << 8 | next_instr->op.arg;
  4544. PRE_DISPATCH_GOTO();
  4545. DISPATCH_GOTO();
  4546. #line 4786 "Python/generated_cases.c.h"
  4547. }
  4548. TARGET(CACHE) {
  4549. #line 3474 "Python/bytecodes.c"
  4550. assert(0 && "Executing a cache.");
  4551. Py_UNREACHABLE();
  4552. #line 4793 "Python/generated_cases.c.h"
  4553. }
  4554. TARGET(RESERVED) {
  4555. #line 3479 "Python/bytecodes.c"
  4556. assert(0 && "Executing RESERVED instruction.");
  4557. Py_UNREACHABLE();
  4558. #line 4800 "Python/generated_cases.c.h"
  4559. }