opcode_metadata.h 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. // This file is generated by Tools/cases_generator/generate_cases.py
  2. // from:
  3. // Python/bytecodes.c
  4. // Do not edit!
  5. #ifndef NEED_OPCODE_METADATA
  6. extern int _PyOpcode_num_popped(int opcode, int oparg, bool jump);
  7. #else
  8. int
  9. _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
  10. switch(opcode) {
  11. case NOP:
  12. return 0;
  13. case RESUME:
  14. return 0;
  15. case INSTRUMENTED_RESUME:
  16. return 0;
  17. case LOAD_CLOSURE:
  18. return 0;
  19. case LOAD_FAST_CHECK:
  20. return 0;
  21. case LOAD_FAST:
  22. return 0;
  23. case LOAD_FAST_AND_CLEAR:
  24. return 0;
  25. case LOAD_CONST:
  26. return 0;
  27. case STORE_FAST:
  28. return 1;
  29. case LOAD_FAST__LOAD_FAST:
  30. return 0+0;
  31. case LOAD_FAST__LOAD_CONST:
  32. return 0+0;
  33. case STORE_FAST__LOAD_FAST:
  34. return 1+0;
  35. case STORE_FAST__STORE_FAST:
  36. return 1+1;
  37. case LOAD_CONST__LOAD_FAST:
  38. return 0+0;
  39. case POP_TOP:
  40. return 1;
  41. case PUSH_NULL:
  42. return 0;
  43. case END_FOR:
  44. return 1+1;
  45. case INSTRUMENTED_END_FOR:
  46. return 2;
  47. case END_SEND:
  48. return 2;
  49. case INSTRUMENTED_END_SEND:
  50. return 2;
  51. case UNARY_NEGATIVE:
  52. return 1;
  53. case UNARY_NOT:
  54. return 1;
  55. case UNARY_INVERT:
  56. return 1;
  57. case BINARY_OP_MULTIPLY_INT:
  58. return 2;
  59. case BINARY_OP_MULTIPLY_FLOAT:
  60. return 2;
  61. case BINARY_OP_SUBTRACT_INT:
  62. return 2;
  63. case BINARY_OP_SUBTRACT_FLOAT:
  64. return 2;
  65. case BINARY_OP_ADD_UNICODE:
  66. return 2;
  67. case BINARY_OP_INPLACE_ADD_UNICODE:
  68. return 2;
  69. case BINARY_OP_ADD_FLOAT:
  70. return 2;
  71. case BINARY_OP_ADD_INT:
  72. return 2;
  73. case BINARY_SUBSCR:
  74. return 2;
  75. case BINARY_SLICE:
  76. return 3;
  77. case STORE_SLICE:
  78. return 4;
  79. case BINARY_SUBSCR_LIST_INT:
  80. return 2;
  81. case BINARY_SUBSCR_TUPLE_INT:
  82. return 2;
  83. case BINARY_SUBSCR_DICT:
  84. return 2;
  85. case BINARY_SUBSCR_GETITEM:
  86. return 2;
  87. case LIST_APPEND:
  88. return (oparg-1) + 2;
  89. case SET_ADD:
  90. return (oparg-1) + 2;
  91. case STORE_SUBSCR:
  92. return 3;
  93. case STORE_SUBSCR_LIST_INT:
  94. return 3;
  95. case STORE_SUBSCR_DICT:
  96. return 3;
  97. case DELETE_SUBSCR:
  98. return 2;
  99. case CALL_INTRINSIC_1:
  100. return 1;
  101. case CALL_INTRINSIC_2:
  102. return 2;
  103. case RAISE_VARARGS:
  104. return oparg;
  105. case INTERPRETER_EXIT:
  106. return 1;
  107. case RETURN_VALUE:
  108. return 1;
  109. case INSTRUMENTED_RETURN_VALUE:
  110. return 1;
  111. case RETURN_CONST:
  112. return 0;
  113. case INSTRUMENTED_RETURN_CONST:
  114. return 0;
  115. case GET_AITER:
  116. return 1;
  117. case GET_ANEXT:
  118. return 1;
  119. case GET_AWAITABLE:
  120. return 1;
  121. case SEND:
  122. return 2;
  123. case SEND_GEN:
  124. return 2;
  125. case INSTRUMENTED_YIELD_VALUE:
  126. return 1;
  127. case YIELD_VALUE:
  128. return 1;
  129. case POP_EXCEPT:
  130. return 1;
  131. case RERAISE:
  132. return oparg + 1;
  133. case END_ASYNC_FOR:
  134. return 2;
  135. case CLEANUP_THROW:
  136. return 3;
  137. case LOAD_ASSERTION_ERROR:
  138. return 0;
  139. case LOAD_BUILD_CLASS:
  140. return 0;
  141. case STORE_NAME:
  142. return 1;
  143. case DELETE_NAME:
  144. return 0;
  145. case UNPACK_SEQUENCE:
  146. return 1;
  147. case UNPACK_SEQUENCE_TWO_TUPLE:
  148. return 1;
  149. case UNPACK_SEQUENCE_TUPLE:
  150. return 1;
  151. case UNPACK_SEQUENCE_LIST:
  152. return 1;
  153. case UNPACK_EX:
  154. return 1;
  155. case STORE_ATTR:
  156. return 2;
  157. case DELETE_ATTR:
  158. return 1;
  159. case STORE_GLOBAL:
  160. return 1;
  161. case DELETE_GLOBAL:
  162. return 0;
  163. case LOAD_LOCALS:
  164. return 0;
  165. case LOAD_FROM_DICT_OR_GLOBALS:
  166. return 1;
  167. case LOAD_NAME:
  168. return 0;
  169. case LOAD_GLOBAL:
  170. return 0;
  171. case LOAD_GLOBAL_MODULE:
  172. return 0;
  173. case LOAD_GLOBAL_BUILTIN:
  174. return 0;
  175. case DELETE_FAST:
  176. return 0;
  177. case MAKE_CELL:
  178. return 0;
  179. case DELETE_DEREF:
  180. return 0;
  181. case LOAD_FROM_DICT_OR_DEREF:
  182. return 1;
  183. case LOAD_DEREF:
  184. return 0;
  185. case STORE_DEREF:
  186. return 1;
  187. case COPY_FREE_VARS:
  188. return 0;
  189. case BUILD_STRING:
  190. return oparg;
  191. case BUILD_TUPLE:
  192. return oparg;
  193. case BUILD_LIST:
  194. return oparg;
  195. case LIST_EXTEND:
  196. return (oparg-1) + 2;
  197. case SET_UPDATE:
  198. return (oparg-1) + 2;
  199. case BUILD_SET:
  200. return oparg;
  201. case BUILD_MAP:
  202. return oparg*2;
  203. case SETUP_ANNOTATIONS:
  204. return 0;
  205. case BUILD_CONST_KEY_MAP:
  206. return oparg + 1;
  207. case DICT_UPDATE:
  208. return 1;
  209. case DICT_MERGE:
  210. return 1;
  211. case MAP_ADD:
  212. return 2;
  213. case INSTRUMENTED_LOAD_SUPER_ATTR:
  214. return 3;
  215. case LOAD_SUPER_ATTR:
  216. return 3;
  217. case LOAD_SUPER_ATTR_ATTR:
  218. return 3;
  219. case LOAD_SUPER_ATTR_METHOD:
  220. return 3;
  221. case LOAD_ATTR:
  222. return 1;
  223. case LOAD_ATTR_INSTANCE_VALUE:
  224. return 1;
  225. case LOAD_ATTR_MODULE:
  226. return 1;
  227. case LOAD_ATTR_WITH_HINT:
  228. return 1;
  229. case LOAD_ATTR_SLOT:
  230. return 1;
  231. case LOAD_ATTR_CLASS:
  232. return 1;
  233. case LOAD_ATTR_PROPERTY:
  234. return 1;
  235. case LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN:
  236. return 1;
  237. case STORE_ATTR_INSTANCE_VALUE:
  238. return 2;
  239. case STORE_ATTR_WITH_HINT:
  240. return 2;
  241. case STORE_ATTR_SLOT:
  242. return 2;
  243. case COMPARE_OP:
  244. return 2;
  245. case COMPARE_OP_FLOAT:
  246. return 2;
  247. case COMPARE_OP_INT:
  248. return 2;
  249. case COMPARE_OP_STR:
  250. return 2;
  251. case IS_OP:
  252. return 2;
  253. case CONTAINS_OP:
  254. return 2;
  255. case CHECK_EG_MATCH:
  256. return 2;
  257. case CHECK_EXC_MATCH:
  258. return 2;
  259. case IMPORT_NAME:
  260. return 2;
  261. case IMPORT_FROM:
  262. return 1;
  263. case JUMP_FORWARD:
  264. return 0;
  265. case JUMP_BACKWARD:
  266. return 0;
  267. case POP_JUMP_IF_FALSE:
  268. return 1;
  269. case POP_JUMP_IF_TRUE:
  270. return 1;
  271. case POP_JUMP_IF_NOT_NONE:
  272. return 1;
  273. case POP_JUMP_IF_NONE:
  274. return 1;
  275. case JUMP_BACKWARD_NO_INTERRUPT:
  276. return 0;
  277. case GET_LEN:
  278. return 1;
  279. case MATCH_CLASS:
  280. return 3;
  281. case MATCH_MAPPING:
  282. return 1;
  283. case MATCH_SEQUENCE:
  284. return 1;
  285. case MATCH_KEYS:
  286. return 2;
  287. case GET_ITER:
  288. return 1;
  289. case GET_YIELD_FROM_ITER:
  290. return 1;
  291. case FOR_ITER:
  292. return 1;
  293. case INSTRUMENTED_FOR_ITER:
  294. return 0;
  295. case FOR_ITER_LIST:
  296. return 1;
  297. case FOR_ITER_TUPLE:
  298. return 1;
  299. case FOR_ITER_RANGE:
  300. return 1;
  301. case FOR_ITER_GEN:
  302. return 1;
  303. case BEFORE_ASYNC_WITH:
  304. return 1;
  305. case BEFORE_WITH:
  306. return 1;
  307. case WITH_EXCEPT_START:
  308. return 4;
  309. case PUSH_EXC_INFO:
  310. return 1;
  311. case LOAD_ATTR_METHOD_WITH_VALUES:
  312. return 1;
  313. case LOAD_ATTR_METHOD_NO_DICT:
  314. return 1;
  315. case LOAD_ATTR_METHOD_LAZY_DICT:
  316. return 1;
  317. case KW_NAMES:
  318. return 0;
  319. case INSTRUMENTED_CALL:
  320. return 0;
  321. case CALL:
  322. return oparg + 2;
  323. case CALL_BOUND_METHOD_EXACT_ARGS:
  324. return oparg + 2;
  325. case CALL_PY_EXACT_ARGS:
  326. return oparg + 2;
  327. case CALL_PY_WITH_DEFAULTS:
  328. return oparg + 2;
  329. case CALL_NO_KW_TYPE_1:
  330. return oparg + 2;
  331. case CALL_NO_KW_STR_1:
  332. return oparg + 2;
  333. case CALL_NO_KW_TUPLE_1:
  334. return oparg + 2;
  335. case CALL_BUILTIN_CLASS:
  336. return oparg + 2;
  337. case CALL_NO_KW_BUILTIN_O:
  338. return oparg + 2;
  339. case CALL_NO_KW_BUILTIN_FAST:
  340. return oparg + 2;
  341. case CALL_BUILTIN_FAST_WITH_KEYWORDS:
  342. return oparg + 2;
  343. case CALL_NO_KW_LEN:
  344. return oparg + 2;
  345. case CALL_NO_KW_ISINSTANCE:
  346. return oparg + 2;
  347. case CALL_NO_KW_LIST_APPEND:
  348. return oparg + 2;
  349. case CALL_NO_KW_METHOD_DESCRIPTOR_O:
  350. return oparg + 2;
  351. case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS:
  352. return oparg + 2;
  353. case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS:
  354. return oparg + 2;
  355. case CALL_NO_KW_METHOD_DESCRIPTOR_FAST:
  356. return oparg + 2;
  357. case INSTRUMENTED_CALL_FUNCTION_EX:
  358. return 0;
  359. case CALL_FUNCTION_EX:
  360. return ((oparg & 1) ? 1 : 0) + 3;
  361. case MAKE_FUNCTION:
  362. return ((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + 1;
  363. case RETURN_GENERATOR:
  364. return 0;
  365. case BUILD_SLICE:
  366. return ((oparg == 3) ? 1 : 0) + 2;
  367. case FORMAT_VALUE:
  368. return (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0) + 1;
  369. case COPY:
  370. return (oparg-1) + 1;
  371. case BINARY_OP:
  372. return 2;
  373. case SWAP:
  374. return (oparg-2) + 2;
  375. case INSTRUMENTED_INSTRUCTION:
  376. return 0;
  377. case INSTRUMENTED_JUMP_FORWARD:
  378. return 0;
  379. case INSTRUMENTED_JUMP_BACKWARD:
  380. return 0;
  381. case INSTRUMENTED_POP_JUMP_IF_TRUE:
  382. return 0;
  383. case INSTRUMENTED_POP_JUMP_IF_FALSE:
  384. return 0;
  385. case INSTRUMENTED_POP_JUMP_IF_NONE:
  386. return 0;
  387. case INSTRUMENTED_POP_JUMP_IF_NOT_NONE:
  388. return 0;
  389. case EXTENDED_ARG:
  390. return 0;
  391. case CACHE:
  392. return 0;
  393. case RESERVED:
  394. return 0;
  395. default:
  396. return -1;
  397. }
  398. }
  399. #endif
  400. #ifndef NEED_OPCODE_METADATA
  401. extern int _PyOpcode_num_pushed(int opcode, int oparg, bool jump);
  402. #else
  403. int
  404. _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
  405. switch(opcode) {
  406. case NOP:
  407. return 0;
  408. case RESUME:
  409. return 0;
  410. case INSTRUMENTED_RESUME:
  411. return 0;
  412. case LOAD_CLOSURE:
  413. return 1;
  414. case LOAD_FAST_CHECK:
  415. return 1;
  416. case LOAD_FAST:
  417. return 1;
  418. case LOAD_FAST_AND_CLEAR:
  419. return 1;
  420. case LOAD_CONST:
  421. return 1;
  422. case STORE_FAST:
  423. return 0;
  424. case LOAD_FAST__LOAD_FAST:
  425. return 1+1;
  426. case LOAD_FAST__LOAD_CONST:
  427. return 1+1;
  428. case STORE_FAST__LOAD_FAST:
  429. return 0+1;
  430. case STORE_FAST__STORE_FAST:
  431. return 0+0;
  432. case LOAD_CONST__LOAD_FAST:
  433. return 1+1;
  434. case POP_TOP:
  435. return 0;
  436. case PUSH_NULL:
  437. return 1;
  438. case END_FOR:
  439. return 0+0;
  440. case INSTRUMENTED_END_FOR:
  441. return 0;
  442. case END_SEND:
  443. return 1;
  444. case INSTRUMENTED_END_SEND:
  445. return 1;
  446. case UNARY_NEGATIVE:
  447. return 1;
  448. case UNARY_NOT:
  449. return 1;
  450. case UNARY_INVERT:
  451. return 1;
  452. case BINARY_OP_MULTIPLY_INT:
  453. return 1;
  454. case BINARY_OP_MULTIPLY_FLOAT:
  455. return 1;
  456. case BINARY_OP_SUBTRACT_INT:
  457. return 1;
  458. case BINARY_OP_SUBTRACT_FLOAT:
  459. return 1;
  460. case BINARY_OP_ADD_UNICODE:
  461. return 1;
  462. case BINARY_OP_INPLACE_ADD_UNICODE:
  463. return 0;
  464. case BINARY_OP_ADD_FLOAT:
  465. return 1;
  466. case BINARY_OP_ADD_INT:
  467. return 1;
  468. case BINARY_SUBSCR:
  469. return 1;
  470. case BINARY_SLICE:
  471. return 1;
  472. case STORE_SLICE:
  473. return 0;
  474. case BINARY_SUBSCR_LIST_INT:
  475. return 1;
  476. case BINARY_SUBSCR_TUPLE_INT:
  477. return 1;
  478. case BINARY_SUBSCR_DICT:
  479. return 1;
  480. case BINARY_SUBSCR_GETITEM:
  481. return 1;
  482. case LIST_APPEND:
  483. return (oparg-1) + 1;
  484. case SET_ADD:
  485. return (oparg-1) + 1;
  486. case STORE_SUBSCR:
  487. return 0;
  488. case STORE_SUBSCR_LIST_INT:
  489. return 0;
  490. case STORE_SUBSCR_DICT:
  491. return 0;
  492. case DELETE_SUBSCR:
  493. return 0;
  494. case CALL_INTRINSIC_1:
  495. return 1;
  496. case CALL_INTRINSIC_2:
  497. return 1;
  498. case RAISE_VARARGS:
  499. return 0;
  500. case INTERPRETER_EXIT:
  501. return 0;
  502. case RETURN_VALUE:
  503. return 0;
  504. case INSTRUMENTED_RETURN_VALUE:
  505. return 0;
  506. case RETURN_CONST:
  507. return 0;
  508. case INSTRUMENTED_RETURN_CONST:
  509. return 0;
  510. case GET_AITER:
  511. return 1;
  512. case GET_ANEXT:
  513. return 2;
  514. case GET_AWAITABLE:
  515. return 1;
  516. case SEND:
  517. return 2;
  518. case SEND_GEN:
  519. return 2;
  520. case INSTRUMENTED_YIELD_VALUE:
  521. return 1;
  522. case YIELD_VALUE:
  523. return 1;
  524. case POP_EXCEPT:
  525. return 0;
  526. case RERAISE:
  527. return oparg;
  528. case END_ASYNC_FOR:
  529. return 0;
  530. case CLEANUP_THROW:
  531. return 2;
  532. case LOAD_ASSERTION_ERROR:
  533. return 1;
  534. case LOAD_BUILD_CLASS:
  535. return 1;
  536. case STORE_NAME:
  537. return 0;
  538. case DELETE_NAME:
  539. return 0;
  540. case UNPACK_SEQUENCE:
  541. return oparg;
  542. case UNPACK_SEQUENCE_TWO_TUPLE:
  543. return oparg;
  544. case UNPACK_SEQUENCE_TUPLE:
  545. return oparg;
  546. case UNPACK_SEQUENCE_LIST:
  547. return oparg;
  548. case UNPACK_EX:
  549. return (oparg & 0xFF) + (oparg >> 8) + 1;
  550. case STORE_ATTR:
  551. return 0;
  552. case DELETE_ATTR:
  553. return 0;
  554. case STORE_GLOBAL:
  555. return 0;
  556. case DELETE_GLOBAL:
  557. return 0;
  558. case LOAD_LOCALS:
  559. return 1;
  560. case LOAD_FROM_DICT_OR_GLOBALS:
  561. return 1;
  562. case LOAD_NAME:
  563. return 1;
  564. case LOAD_GLOBAL:
  565. return ((oparg & 1) ? 1 : 0) + 1;
  566. case LOAD_GLOBAL_MODULE:
  567. return ((oparg & 1) ? 1 : 0) + 1;
  568. case LOAD_GLOBAL_BUILTIN:
  569. return ((oparg & 1) ? 1 : 0) + 1;
  570. case DELETE_FAST:
  571. return 0;
  572. case MAKE_CELL:
  573. return 0;
  574. case DELETE_DEREF:
  575. return 0;
  576. case LOAD_FROM_DICT_OR_DEREF:
  577. return 1;
  578. case LOAD_DEREF:
  579. return 1;
  580. case STORE_DEREF:
  581. return 0;
  582. case COPY_FREE_VARS:
  583. return 0;
  584. case BUILD_STRING:
  585. return 1;
  586. case BUILD_TUPLE:
  587. return 1;
  588. case BUILD_LIST:
  589. return 1;
  590. case LIST_EXTEND:
  591. return (oparg-1) + 1;
  592. case SET_UPDATE:
  593. return (oparg-1) + 1;
  594. case BUILD_SET:
  595. return 1;
  596. case BUILD_MAP:
  597. return 1;
  598. case SETUP_ANNOTATIONS:
  599. return 0;
  600. case BUILD_CONST_KEY_MAP:
  601. return 1;
  602. case DICT_UPDATE:
  603. return 0;
  604. case DICT_MERGE:
  605. return 0;
  606. case MAP_ADD:
  607. return 0;
  608. case INSTRUMENTED_LOAD_SUPER_ATTR:
  609. return ((oparg & 1) ? 1 : 0) + 1;
  610. case LOAD_SUPER_ATTR:
  611. return ((oparg & 1) ? 1 : 0) + 1;
  612. case LOAD_SUPER_ATTR_ATTR:
  613. return ((oparg & 1) ? 1 : 0) + 1;
  614. case LOAD_SUPER_ATTR_METHOD:
  615. return 2;
  616. case LOAD_ATTR:
  617. return ((oparg & 1) ? 1 : 0) + 1;
  618. case LOAD_ATTR_INSTANCE_VALUE:
  619. return ((oparg & 1) ? 1 : 0) + 1;
  620. case LOAD_ATTR_MODULE:
  621. return ((oparg & 1) ? 1 : 0) + 1;
  622. case LOAD_ATTR_WITH_HINT:
  623. return ((oparg & 1) ? 1 : 0) + 1;
  624. case LOAD_ATTR_SLOT:
  625. return ((oparg & 1) ? 1 : 0) + 1;
  626. case LOAD_ATTR_CLASS:
  627. return ((oparg & 1) ? 1 : 0) + 1;
  628. case LOAD_ATTR_PROPERTY:
  629. return ((oparg & 1) ? 1 : 0) + 1;
  630. case LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN:
  631. return ((oparg & 1) ? 1 : 0) + 1;
  632. case STORE_ATTR_INSTANCE_VALUE:
  633. return 0;
  634. case STORE_ATTR_WITH_HINT:
  635. return 0;
  636. case STORE_ATTR_SLOT:
  637. return 0;
  638. case COMPARE_OP:
  639. return 1;
  640. case COMPARE_OP_FLOAT:
  641. return 1;
  642. case COMPARE_OP_INT:
  643. return 1;
  644. case COMPARE_OP_STR:
  645. return 1;
  646. case IS_OP:
  647. return 1;
  648. case CONTAINS_OP:
  649. return 1;
  650. case CHECK_EG_MATCH:
  651. return 2;
  652. case CHECK_EXC_MATCH:
  653. return 2;
  654. case IMPORT_NAME:
  655. return 1;
  656. case IMPORT_FROM:
  657. return 2;
  658. case JUMP_FORWARD:
  659. return 0;
  660. case JUMP_BACKWARD:
  661. return 0;
  662. case POP_JUMP_IF_FALSE:
  663. return 0;
  664. case POP_JUMP_IF_TRUE:
  665. return 0;
  666. case POP_JUMP_IF_NOT_NONE:
  667. return 0;
  668. case POP_JUMP_IF_NONE:
  669. return 0;
  670. case JUMP_BACKWARD_NO_INTERRUPT:
  671. return 0;
  672. case GET_LEN:
  673. return 2;
  674. case MATCH_CLASS:
  675. return 1;
  676. case MATCH_MAPPING:
  677. return 2;
  678. case MATCH_SEQUENCE:
  679. return 2;
  680. case MATCH_KEYS:
  681. return 3;
  682. case GET_ITER:
  683. return 1;
  684. case GET_YIELD_FROM_ITER:
  685. return 1;
  686. case FOR_ITER:
  687. return 2;
  688. case INSTRUMENTED_FOR_ITER:
  689. return 0;
  690. case FOR_ITER_LIST:
  691. return 2;
  692. case FOR_ITER_TUPLE:
  693. return 2;
  694. case FOR_ITER_RANGE:
  695. return 2;
  696. case FOR_ITER_GEN:
  697. return 2;
  698. case BEFORE_ASYNC_WITH:
  699. return 2;
  700. case BEFORE_WITH:
  701. return 2;
  702. case WITH_EXCEPT_START:
  703. return 5;
  704. case PUSH_EXC_INFO:
  705. return 2;
  706. case LOAD_ATTR_METHOD_WITH_VALUES:
  707. return ((oparg & 1) ? 1 : 0) + 1;
  708. case LOAD_ATTR_METHOD_NO_DICT:
  709. return ((oparg & 1) ? 1 : 0) + 1;
  710. case LOAD_ATTR_METHOD_LAZY_DICT:
  711. return ((oparg & 1) ? 1 : 0) + 1;
  712. case KW_NAMES:
  713. return 0;
  714. case INSTRUMENTED_CALL:
  715. return 0;
  716. case CALL:
  717. return 1;
  718. case CALL_BOUND_METHOD_EXACT_ARGS:
  719. return 1;
  720. case CALL_PY_EXACT_ARGS:
  721. return 1;
  722. case CALL_PY_WITH_DEFAULTS:
  723. return 1;
  724. case CALL_NO_KW_TYPE_1:
  725. return 1;
  726. case CALL_NO_KW_STR_1:
  727. return 1;
  728. case CALL_NO_KW_TUPLE_1:
  729. return 1;
  730. case CALL_BUILTIN_CLASS:
  731. return 1;
  732. case CALL_NO_KW_BUILTIN_O:
  733. return 1;
  734. case CALL_NO_KW_BUILTIN_FAST:
  735. return 1;
  736. case CALL_BUILTIN_FAST_WITH_KEYWORDS:
  737. return 1;
  738. case CALL_NO_KW_LEN:
  739. return 1;
  740. case CALL_NO_KW_ISINSTANCE:
  741. return 1;
  742. case CALL_NO_KW_LIST_APPEND:
  743. return 1;
  744. case CALL_NO_KW_METHOD_DESCRIPTOR_O:
  745. return 1;
  746. case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS:
  747. return 1;
  748. case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS:
  749. return 1;
  750. case CALL_NO_KW_METHOD_DESCRIPTOR_FAST:
  751. return 1;
  752. case INSTRUMENTED_CALL_FUNCTION_EX:
  753. return 0;
  754. case CALL_FUNCTION_EX:
  755. return 1;
  756. case MAKE_FUNCTION:
  757. return 1;
  758. case RETURN_GENERATOR:
  759. return 0;
  760. case BUILD_SLICE:
  761. return 1;
  762. case FORMAT_VALUE:
  763. return 1;
  764. case COPY:
  765. return (oparg-1) + 2;
  766. case BINARY_OP:
  767. return 1;
  768. case SWAP:
  769. return (oparg-2) + 2;
  770. case INSTRUMENTED_INSTRUCTION:
  771. return 0;
  772. case INSTRUMENTED_JUMP_FORWARD:
  773. return 0;
  774. case INSTRUMENTED_JUMP_BACKWARD:
  775. return 0;
  776. case INSTRUMENTED_POP_JUMP_IF_TRUE:
  777. return 0;
  778. case INSTRUMENTED_POP_JUMP_IF_FALSE:
  779. return 0;
  780. case INSTRUMENTED_POP_JUMP_IF_NONE:
  781. return 0;
  782. case INSTRUMENTED_POP_JUMP_IF_NOT_NONE:
  783. return 0;
  784. case EXTENDED_ARG:
  785. return 0;
  786. case CACHE:
  787. return 0;
  788. case RESERVED:
  789. return 0;
  790. default:
  791. return -1;
  792. }
  793. }
  794. #endif
  795. enum InstructionFormat { INSTR_FMT_IB, INSTR_FMT_IBC, INSTR_FMT_IBC00, INSTR_FMT_IBC000, INSTR_FMT_IBC00000000, INSTR_FMT_IBIB, INSTR_FMT_IX, INSTR_FMT_IXC, INSTR_FMT_IXC000 };
  796. struct opcode_metadata {
  797. bool valid_entry;
  798. enum InstructionFormat instr_format;
  799. };
  800. #ifndef NEED_OPCODE_METADATA
  801. extern const struct opcode_metadata _PyOpcode_opcode_metadata[256];
  802. #else
  803. const struct opcode_metadata _PyOpcode_opcode_metadata[256] = {
  804. [NOP] = { true, INSTR_FMT_IX },
  805. [RESUME] = { true, INSTR_FMT_IB },
  806. [INSTRUMENTED_RESUME] = { true, INSTR_FMT_IB },
  807. [LOAD_CLOSURE] = { true, INSTR_FMT_IB },
  808. [LOAD_FAST_CHECK] = { true, INSTR_FMT_IB },
  809. [LOAD_FAST] = { true, INSTR_FMT_IB },
  810. [LOAD_FAST_AND_CLEAR] = { true, INSTR_FMT_IB },
  811. [LOAD_CONST] = { true, INSTR_FMT_IB },
  812. [STORE_FAST] = { true, INSTR_FMT_IB },
  813. [LOAD_FAST__LOAD_FAST] = { true, INSTR_FMT_IBIB },
  814. [LOAD_FAST__LOAD_CONST] = { true, INSTR_FMT_IBIB },
  815. [STORE_FAST__LOAD_FAST] = { true, INSTR_FMT_IBIB },
  816. [STORE_FAST__STORE_FAST] = { true, INSTR_FMT_IBIB },
  817. [LOAD_CONST__LOAD_FAST] = { true, INSTR_FMT_IBIB },
  818. [POP_TOP] = { true, INSTR_FMT_IX },
  819. [PUSH_NULL] = { true, INSTR_FMT_IX },
  820. [END_FOR] = { true, INSTR_FMT_IB },
  821. [INSTRUMENTED_END_FOR] = { true, INSTR_FMT_IX },
  822. [END_SEND] = { true, INSTR_FMT_IX },
  823. [INSTRUMENTED_END_SEND] = { true, INSTR_FMT_IX },
  824. [UNARY_NEGATIVE] = { true, INSTR_FMT_IX },
  825. [UNARY_NOT] = { true, INSTR_FMT_IX },
  826. [UNARY_INVERT] = { true, INSTR_FMT_IX },
  827. [BINARY_OP_MULTIPLY_INT] = { true, INSTR_FMT_IXC },
  828. [BINARY_OP_MULTIPLY_FLOAT] = { true, INSTR_FMT_IXC },
  829. [BINARY_OP_SUBTRACT_INT] = { true, INSTR_FMT_IXC },
  830. [BINARY_OP_SUBTRACT_FLOAT] = { true, INSTR_FMT_IXC },
  831. [BINARY_OP_ADD_UNICODE] = { true, INSTR_FMT_IXC },
  832. [BINARY_OP_INPLACE_ADD_UNICODE] = { true, INSTR_FMT_IX },
  833. [BINARY_OP_ADD_FLOAT] = { true, INSTR_FMT_IXC },
  834. [BINARY_OP_ADD_INT] = { true, INSTR_FMT_IXC },
  835. [BINARY_SUBSCR] = { true, INSTR_FMT_IXC },
  836. [BINARY_SLICE] = { true, INSTR_FMT_IX },
  837. [STORE_SLICE] = { true, INSTR_FMT_IX },
  838. [BINARY_SUBSCR_LIST_INT] = { true, INSTR_FMT_IXC },
  839. [BINARY_SUBSCR_TUPLE_INT] = { true, INSTR_FMT_IXC },
  840. [BINARY_SUBSCR_DICT] = { true, INSTR_FMT_IXC },
  841. [BINARY_SUBSCR_GETITEM] = { true, INSTR_FMT_IXC },
  842. [LIST_APPEND] = { true, INSTR_FMT_IB },
  843. [SET_ADD] = { true, INSTR_FMT_IB },
  844. [STORE_SUBSCR] = { true, INSTR_FMT_IXC },
  845. [STORE_SUBSCR_LIST_INT] = { true, INSTR_FMT_IXC },
  846. [STORE_SUBSCR_DICT] = { true, INSTR_FMT_IXC },
  847. [DELETE_SUBSCR] = { true, INSTR_FMT_IX },
  848. [CALL_INTRINSIC_1] = { true, INSTR_FMT_IB },
  849. [CALL_INTRINSIC_2] = { true, INSTR_FMT_IB },
  850. [RAISE_VARARGS] = { true, INSTR_FMT_IB },
  851. [INTERPRETER_EXIT] = { true, INSTR_FMT_IX },
  852. [RETURN_VALUE] = { true, INSTR_FMT_IX },
  853. [INSTRUMENTED_RETURN_VALUE] = { true, INSTR_FMT_IX },
  854. [RETURN_CONST] = { true, INSTR_FMT_IB },
  855. [INSTRUMENTED_RETURN_CONST] = { true, INSTR_FMT_IB },
  856. [GET_AITER] = { true, INSTR_FMT_IX },
  857. [GET_ANEXT] = { true, INSTR_FMT_IX },
  858. [GET_AWAITABLE] = { true, INSTR_FMT_IB },
  859. [SEND] = { true, INSTR_FMT_IBC },
  860. [SEND_GEN] = { true, INSTR_FMT_IBC },
  861. [INSTRUMENTED_YIELD_VALUE] = { true, INSTR_FMT_IX },
  862. [YIELD_VALUE] = { true, INSTR_FMT_IX },
  863. [POP_EXCEPT] = { true, INSTR_FMT_IX },
  864. [RERAISE] = { true, INSTR_FMT_IB },
  865. [END_ASYNC_FOR] = { true, INSTR_FMT_IX },
  866. [CLEANUP_THROW] = { true, INSTR_FMT_IX },
  867. [LOAD_ASSERTION_ERROR] = { true, INSTR_FMT_IX },
  868. [LOAD_BUILD_CLASS] = { true, INSTR_FMT_IX },
  869. [STORE_NAME] = { true, INSTR_FMT_IB },
  870. [DELETE_NAME] = { true, INSTR_FMT_IB },
  871. [UNPACK_SEQUENCE] = { true, INSTR_FMT_IBC },
  872. [UNPACK_SEQUENCE_TWO_TUPLE] = { true, INSTR_FMT_IBC },
  873. [UNPACK_SEQUENCE_TUPLE] = { true, INSTR_FMT_IBC },
  874. [UNPACK_SEQUENCE_LIST] = { true, INSTR_FMT_IBC },
  875. [UNPACK_EX] = { true, INSTR_FMT_IB },
  876. [STORE_ATTR] = { true, INSTR_FMT_IBC000 },
  877. [DELETE_ATTR] = { true, INSTR_FMT_IB },
  878. [STORE_GLOBAL] = { true, INSTR_FMT_IB },
  879. [DELETE_GLOBAL] = { true, INSTR_FMT_IB },
  880. [LOAD_LOCALS] = { true, INSTR_FMT_IX },
  881. [LOAD_FROM_DICT_OR_GLOBALS] = { true, INSTR_FMT_IB },
  882. [LOAD_NAME] = { true, INSTR_FMT_IB },
  883. [LOAD_GLOBAL] = { true, INSTR_FMT_IBC000 },
  884. [LOAD_GLOBAL_MODULE] = { true, INSTR_FMT_IBC000 },
  885. [LOAD_GLOBAL_BUILTIN] = { true, INSTR_FMT_IBC000 },
  886. [DELETE_FAST] = { true, INSTR_FMT_IB },
  887. [MAKE_CELL] = { true, INSTR_FMT_IB },
  888. [DELETE_DEREF] = { true, INSTR_FMT_IB },
  889. [LOAD_FROM_DICT_OR_DEREF] = { true, INSTR_FMT_IB },
  890. [LOAD_DEREF] = { true, INSTR_FMT_IB },
  891. [STORE_DEREF] = { true, INSTR_FMT_IB },
  892. [COPY_FREE_VARS] = { true, INSTR_FMT_IB },
  893. [BUILD_STRING] = { true, INSTR_FMT_IB },
  894. [BUILD_TUPLE] = { true, INSTR_FMT_IB },
  895. [BUILD_LIST] = { true, INSTR_FMT_IB },
  896. [LIST_EXTEND] = { true, INSTR_FMT_IB },
  897. [SET_UPDATE] = { true, INSTR_FMT_IB },
  898. [BUILD_SET] = { true, INSTR_FMT_IB },
  899. [BUILD_MAP] = { true, INSTR_FMT_IB },
  900. [SETUP_ANNOTATIONS] = { true, INSTR_FMT_IX },
  901. [BUILD_CONST_KEY_MAP] = { true, INSTR_FMT_IB },
  902. [DICT_UPDATE] = { true, INSTR_FMT_IB },
  903. [DICT_MERGE] = { true, INSTR_FMT_IB },
  904. [MAP_ADD] = { true, INSTR_FMT_IB },
  905. [INSTRUMENTED_LOAD_SUPER_ATTR] = { true, INSTR_FMT_IBC00000000 },
  906. [LOAD_SUPER_ATTR] = { true, INSTR_FMT_IBC },
  907. [LOAD_SUPER_ATTR_ATTR] = { true, INSTR_FMT_IBC },
  908. [LOAD_SUPER_ATTR_METHOD] = { true, INSTR_FMT_IBC },
  909. [LOAD_ATTR] = { true, INSTR_FMT_IBC00000000 },
  910. [LOAD_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IBC00000000 },
  911. [LOAD_ATTR_MODULE] = { true, INSTR_FMT_IBC00000000 },
  912. [LOAD_ATTR_WITH_HINT] = { true, INSTR_FMT_IBC00000000 },
  913. [LOAD_ATTR_SLOT] = { true, INSTR_FMT_IBC00000000 },
  914. [LOAD_ATTR_CLASS] = { true, INSTR_FMT_IBC00000000 },
  915. [LOAD_ATTR_PROPERTY] = { true, INSTR_FMT_IBC00000000 },
  916. [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { true, INSTR_FMT_IBC00000000 },
  917. [STORE_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IXC000 },
  918. [STORE_ATTR_WITH_HINT] = { true, INSTR_FMT_IBC000 },
  919. [STORE_ATTR_SLOT] = { true, INSTR_FMT_IXC000 },
  920. [COMPARE_OP] = { true, INSTR_FMT_IBC },
  921. [COMPARE_OP_FLOAT] = { true, INSTR_FMT_IBC },
  922. [COMPARE_OP_INT] = { true, INSTR_FMT_IBC },
  923. [COMPARE_OP_STR] = { true, INSTR_FMT_IBC },
  924. [IS_OP] = { true, INSTR_FMT_IB },
  925. [CONTAINS_OP] = { true, INSTR_FMT_IB },
  926. [CHECK_EG_MATCH] = { true, INSTR_FMT_IX },
  927. [CHECK_EXC_MATCH] = { true, INSTR_FMT_IX },
  928. [IMPORT_NAME] = { true, INSTR_FMT_IB },
  929. [IMPORT_FROM] = { true, INSTR_FMT_IB },
  930. [JUMP_FORWARD] = { true, INSTR_FMT_IB },
  931. [JUMP_BACKWARD] = { true, INSTR_FMT_IB },
  932. [POP_JUMP_IF_FALSE] = { true, INSTR_FMT_IB },
  933. [POP_JUMP_IF_TRUE] = { true, INSTR_FMT_IB },
  934. [POP_JUMP_IF_NOT_NONE] = { true, INSTR_FMT_IB },
  935. [POP_JUMP_IF_NONE] = { true, INSTR_FMT_IB },
  936. [JUMP_BACKWARD_NO_INTERRUPT] = { true, INSTR_FMT_IB },
  937. [GET_LEN] = { true, INSTR_FMT_IX },
  938. [MATCH_CLASS] = { true, INSTR_FMT_IB },
  939. [MATCH_MAPPING] = { true, INSTR_FMT_IX },
  940. [MATCH_SEQUENCE] = { true, INSTR_FMT_IX },
  941. [MATCH_KEYS] = { true, INSTR_FMT_IX },
  942. [GET_ITER] = { true, INSTR_FMT_IX },
  943. [GET_YIELD_FROM_ITER] = { true, INSTR_FMT_IX },
  944. [FOR_ITER] = { true, INSTR_FMT_IBC },
  945. [INSTRUMENTED_FOR_ITER] = { true, INSTR_FMT_IB },
  946. [FOR_ITER_LIST] = { true, INSTR_FMT_IBC },
  947. [FOR_ITER_TUPLE] = { true, INSTR_FMT_IBC },
  948. [FOR_ITER_RANGE] = { true, INSTR_FMT_IBC },
  949. [FOR_ITER_GEN] = { true, INSTR_FMT_IBC },
  950. [BEFORE_ASYNC_WITH] = { true, INSTR_FMT_IX },
  951. [BEFORE_WITH] = { true, INSTR_FMT_IX },
  952. [WITH_EXCEPT_START] = { true, INSTR_FMT_IX },
  953. [PUSH_EXC_INFO] = { true, INSTR_FMT_IX },
  954. [LOAD_ATTR_METHOD_WITH_VALUES] = { true, INSTR_FMT_IBC00000000 },
  955. [LOAD_ATTR_METHOD_NO_DICT] = { true, INSTR_FMT_IBC00000000 },
  956. [LOAD_ATTR_METHOD_LAZY_DICT] = { true, INSTR_FMT_IBC00000000 },
  957. [KW_NAMES] = { true, INSTR_FMT_IB },
  958. [INSTRUMENTED_CALL] = { true, INSTR_FMT_IB },
  959. [CALL] = { true, INSTR_FMT_IBC00 },
  960. [CALL_BOUND_METHOD_EXACT_ARGS] = { true, INSTR_FMT_IBC00 },
  961. [CALL_PY_EXACT_ARGS] = { true, INSTR_FMT_IBC00 },
  962. [CALL_PY_WITH_DEFAULTS] = { true, INSTR_FMT_IBC00 },
  963. [CALL_NO_KW_TYPE_1] = { true, INSTR_FMT_IBC00 },
  964. [CALL_NO_KW_STR_1] = { true, INSTR_FMT_IBC00 },
  965. [CALL_NO_KW_TUPLE_1] = { true, INSTR_FMT_IBC00 },
  966. [CALL_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00 },
  967. [CALL_NO_KW_BUILTIN_O] = { true, INSTR_FMT_IBC00 },
  968. [CALL_NO_KW_BUILTIN_FAST] = { true, INSTR_FMT_IBC00 },
  969. [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00 },
  970. [CALL_NO_KW_LEN] = { true, INSTR_FMT_IBC00 },
  971. [CALL_NO_KW_ISINSTANCE] = { true, INSTR_FMT_IBC00 },
  972. [CALL_NO_KW_LIST_APPEND] = { true, INSTR_FMT_IBC00 },
  973. [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { true, INSTR_FMT_IBC00 },
  974. [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00 },
  975. [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC00 },
  976. [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC00 },
  977. [INSTRUMENTED_CALL_FUNCTION_EX] = { true, INSTR_FMT_IX },
  978. [CALL_FUNCTION_EX] = { true, INSTR_FMT_IB },
  979. [MAKE_FUNCTION] = { true, INSTR_FMT_IB },
  980. [RETURN_GENERATOR] = { true, INSTR_FMT_IX },
  981. [BUILD_SLICE] = { true, INSTR_FMT_IB },
  982. [FORMAT_VALUE] = { true, INSTR_FMT_IB },
  983. [COPY] = { true, INSTR_FMT_IB },
  984. [BINARY_OP] = { true, INSTR_FMT_IBC },
  985. [SWAP] = { true, INSTR_FMT_IB },
  986. [INSTRUMENTED_INSTRUCTION] = { true, INSTR_FMT_IX },
  987. [INSTRUMENTED_JUMP_FORWARD] = { true, INSTR_FMT_IB },
  988. [INSTRUMENTED_JUMP_BACKWARD] = { true, INSTR_FMT_IB },
  989. [INSTRUMENTED_POP_JUMP_IF_TRUE] = { true, INSTR_FMT_IB },
  990. [INSTRUMENTED_POP_JUMP_IF_FALSE] = { true, INSTR_FMT_IB },
  991. [INSTRUMENTED_POP_JUMP_IF_NONE] = { true, INSTR_FMT_IB },
  992. [INSTRUMENTED_POP_JUMP_IF_NOT_NONE] = { true, INSTR_FMT_IB },
  993. [EXTENDED_ARG] = { true, INSTR_FMT_IB },
  994. [CACHE] = { true, INSTR_FMT_IX },
  995. [RESERVED] = { true, INSTR_FMT_IX },
  996. };
  997. #endif