1/** -*-c-*- 2 This file contains instruction information for yarv instruction sequence. 3 4 ---- 5 This file is auto generated by insns2vm.rb 6 DO NOT TOUCH! 7 8 If you want to fix something, you must edit 'template/insns_info.inc.tmpl' 9 or insns2vm.rb 10 */ 11 12#define TS_OFFSET 'O' 13#define TS_NUM 'N' 14#define TS_LINDEX 'L' 15#define TS_VALUE 'V' 16#define TS_ID 'I' 17#define TS_GENTRY 'G' 18#define TS_IC 'K' 19#define TS_CALLINFO 'C' 20#define TS_CDHASH 'H' 21#define TS_ISEQ 'S' 22#define TS_VARIABLE '.' 23#define TS_FUNCPTR 'F' 24 25static const char *const insn_name_info[] = { 26 "nop", 27 "getlocal", 28 "setlocal", 29 "getspecial", 30 "setspecial", 31 "getinstancevariable", 32 "setinstancevariable", 33 "getclassvariable", 34 "setclassvariable", 35 "getconstant", 36 "setconstant", 37 "getglobal", 38 "setglobal", 39 "putnil", 40 "putself", 41 "putobject", 42 "putspecialobject", 43 "putiseq", 44 "putstring", 45 "concatstrings", 46 "tostring", 47 "toregexp", 48 "newarray", 49 "duparray", 50 "expandarray", 51 "concatarray", 52 "splatarray", 53 "newhash", 54 "newrange", 55 "pop", 56 "dup", 57 "dupn", 58 "swap", 59 "reput", 60 "topn", 61 "setn", 62 "adjuststack", 63 "defined", 64 "checkmatch", 65 "trace", 66 "defineclass", 67 "send", 68 "opt_send_simple", 69 "invokesuper", 70 "invokeblock", 71 "leave", 72 "throw", 73 "jump", 74 "branchif", 75 "branchunless", 76 "getinlinecache", 77 "onceinlinecache", 78 "setinlinecache", 79 "opt_case_dispatch", 80 "opt_plus", 81 "opt_minus", 82 "opt_mult", 83 "opt_div", 84 "opt_mod", 85 "opt_eq", 86 "opt_neq", 87 "opt_lt", 88 "opt_le", 89 "opt_gt", 90 "opt_ge", 91 "opt_ltlt", 92 "opt_aref", 93 "opt_aset", 94 "opt_length", 95 "opt_size", 96 "opt_empty_p", 97 "opt_succ", 98 "opt_not", 99 "opt_regexpmatch1", 100 "opt_regexpmatch2", 101 "opt_call_c_function", 102 "bitblt", 103 "answer", 104 "getlocal_OP__WC__0", 105 "getlocal_OP__WC__1", 106 "setlocal_OP__WC__0", 107 "setlocal_OP__WC__1", 108 "putobject_OP_INT2FIX_O_0_C_", 109 "putobject_OP_INT2FIX_O_1_C_", 110 111}; 112 113static const char *const insn_operand_info[] = { 114 "", 115 "LN", 116 "LN", 117 "NN", 118 "N", 119 "IK", 120 "IK", 121 "I", 122 "I", 123 "I", 124 "I", 125 "G", 126 "G", 127 "", 128 "", 129 "V", 130 "N", 131 "S", 132 "V", 133 "N", 134 "", 135 "NN", 136 "N", 137 "V", 138 "NN", 139 "", 140 "V", 141 "N", 142 "N", 143 "", 144 "", 145 "N", 146 "", 147 "", 148 "N", 149 "N", 150 "N", 151 "NVV", 152 "N", 153 "N", 154 "ISN", 155 "C", 156 "C", 157 "C", 158 "C", 159 "", 160 "N", 161 "O", 162 "O", 163 "O", 164 "OK", 165 "OK", 166 "K", 167 "HO", 168 "C", 169 "C", 170 "C", 171 "C", 172 "C", 173 "C", 174 "CC", 175 "C", 176 "C", 177 "C", 178 "C", 179 "C", 180 "C", 181 "C", 182 "C", 183 "C", 184 "C", 185 "C", 186 "C", 187 "V", 188 "", 189 "F", 190 "", 191 "", 192 "L", 193 "L", 194 "L", 195 "L", 196 "", 197 "", 198 199}; 200 201static const int insn_len_info[] = { 202 1, 203 3, 204 3, 205 3, 206 2, 207 3, 208 3, 209 2, 210 2, 211 2, 212 2, 213 2, 214 2, 215 1, 216 1, 217 2, 218 2, 219 2, 220 2, 221 2, 222 1, 223 3, 224 2, 225 2, 226 3, 227 1, 228 2, 229 2, 230 2, 231 1, 232 1, 233 2, 234 1, 235 1, 236 2, 237 2, 238 2, 239 4, 240 2, 241 2, 242 4, 243 2, 244 2, 245 2, 246 2, 247 1, 248 2, 249 2, 250 2, 251 2, 252 3, 253 3, 254 2, 255 3, 256 2, 257 2, 258 2, 259 2, 260 2, 261 2, 262 3, 263 2, 264 2, 265 2, 266 2, 267 2, 268 2, 269 2, 270 2, 271 2, 272 2, 273 2, 274 2, 275 2, 276 1, 277 2, 278 1, 279 1, 280 2, 281 2, 282 2, 283 2, 284 1, 285 1, 286 287}; 288 289#ifdef USE_INSN_RET_NUM 290static const int insn_stack_push_num_info[] = { 291 0, 292 1, 293 0, 294 1, 295 0, 296 1, 297 0, 298 1, 299 0, 300 1, 301 0, 302 1, 303 0, 304 1, 305 1, 306 1, 307 1, 308 1, 309 1, 310 1, 311 1, 312 1, 313 1, 314 1, 315 1, 316 1, 317 1, 318 1, 319 1, 320 0, 321 2, 322 1, 323 2, 324 1, 325 1, 326 1, 327 1, 328 1, 329 1, 330 0, 331 1, 332 1, 333 1, 334 1, 335 1, 336 1, 337 1, 338 0, 339 0, 340 0, 341 1, 342 1, 343 1, 344 0, 345 1, 346 1, 347 1, 348 1, 349 1, 350 1, 351 1, 352 1, 353 1, 354 1, 355 1, 356 1, 357 1, 358 1, 359 1, 360 1, 361 1, 362 1, 363 1, 364 1, 365 1, 366 0, 367 1, 368 1, 369 1, 370 1, 371 0, 372 0, 373 1, 374 1, 375 376}; 377#endif 378 379#ifdef USE_INSN_STACK_INCREASE 380static int 381insn_stack_increase(int depth, int insn, VALUE *opes) 382{ 383 switch(insn){ 384 case BIN(nop):{ 385 return depth + 0; 386 } 387 case BIN(getlocal):{ 388 return depth + 1; 389 } 390 case BIN(setlocal):{ 391 return depth + -1; 392 } 393 case BIN(getspecial):{ 394 return depth + 1; 395 } 396 case BIN(setspecial):{ 397 return depth + -1; 398 } 399 case BIN(getinstancevariable):{ 400 return depth + 1; 401 } 402 case BIN(setinstancevariable):{ 403 return depth + -1; 404 } 405 case BIN(getclassvariable):{ 406 return depth + 1; 407 } 408 case BIN(setclassvariable):{ 409 return depth + -1; 410 } 411 case BIN(getconstant):{ 412 return depth + 0; 413 } 414 case BIN(setconstant):{ 415 return depth + -2; 416 } 417 case BIN(getglobal):{ 418 return depth + 1; 419 } 420 case BIN(setglobal):{ 421 return depth + -1; 422 } 423 case BIN(putnil):{ 424 return depth + 1; 425 } 426 case BIN(putself):{ 427 return depth + 1; 428 } 429 case BIN(putobject):{ 430 return depth + 1; 431 } 432 case BIN(putspecialobject):{ 433 return depth + 1; 434 } 435 case BIN(putiseq):{ 436 return depth + 1; 437 } 438 case BIN(putstring):{ 439 return depth + 1; 440 } 441 case BIN(concatstrings):{ 442 int inc = 0; 443 int num = FIX2INT(opes[0]); 444 inc += 1 - num;; 445 return depth + inc; 446 } 447 case BIN(tostring):{ 448 return depth + 0; 449 } 450 case BIN(toregexp):{ 451 int inc = 0; 452 int cnt = FIX2INT(opes[1]); 453 inc += 1 - cnt;; 454 return depth + inc; 455 } 456 case BIN(newarray):{ 457 int inc = 0; 458 int num = FIX2INT(opes[0]); 459 inc += 1 - num;; 460 return depth + inc; 461 } 462 case BIN(duparray):{ 463 return depth + 1; 464 } 465 case BIN(expandarray):{ 466 int inc = 0; 467 int num = FIX2INT(opes[0]); 468 int flag = FIX2INT(opes[1]); 469 inc += num - 1 + (flag & 1 ? 1 : 0);; 470 return depth + inc; 471 } 472 case BIN(concatarray):{ 473 return depth + -1; 474 } 475 case BIN(splatarray):{ 476 return depth + 0; 477 } 478 case BIN(newhash):{ 479 int inc = 0; 480 int num = FIX2INT(opes[0]); 481 inc += 1 - num;; 482 return depth + inc; 483 } 484 case BIN(newrange):{ 485 return depth + -1; 486 } 487 case BIN(pop):{ 488 return depth + -1; 489 } 490 case BIN(dup):{ 491 return depth + 1; 492 } 493 case BIN(dupn):{ 494 int inc = 0; 495 int n = FIX2INT(opes[0]); 496 inc += n;; 497 return depth + inc; 498 } 499 case BIN(swap):{ 500 return depth + 0; 501 } 502 case BIN(reput):{ 503 int inc = 0; 504 inc += 0;; 505 return depth + inc; 506 } 507 case BIN(topn):{ 508 int inc = 0; 509 inc += 1;; 510 return depth + inc; 511 } 512 case BIN(setn):{ 513 int inc = 0; 514 inc += 0; 515 return depth + inc; 516 } 517 case BIN(adjuststack):{ 518 int inc = 0; 519 int n = FIX2INT(opes[0]); 520 inc -= n; 521 return depth + inc; 522 } 523 case BIN(defined):{ 524 return depth + 0; 525 } 526 case BIN(checkmatch):{ 527 return depth + -1; 528 } 529 case BIN(trace):{ 530 return depth + 0; 531 } 532 case BIN(defineclass):{ 533 return depth + -1; 534 } 535 case BIN(send):{ 536 int inc = 0; 537 CALL_INFO ci = (CALL_INFO)(opes[0]); 538 inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));; 539 return depth + inc; 540 } 541 case BIN(opt_send_simple):{ 542 int inc = 0; 543 CALL_INFO ci = (CALL_INFO)(opes[0]); 544 inc += -ci->orig_argc;; 545 return depth + inc; 546 } 547 case BIN(invokesuper):{ 548 int inc = 0; 549 CALL_INFO ci = (CALL_INFO)(opes[0]); 550 inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));; 551 return depth + inc; 552 } 553 case BIN(invokeblock):{ 554 int inc = 0; 555 CALL_INFO ci = (CALL_INFO)(opes[0]); 556 inc += 1 - ci->orig_argc;; 557 return depth + inc; 558 } 559 case BIN(leave):{ 560 return depth + 0; 561 } 562 case BIN(throw):{ 563 return depth + 0; 564 } 565 case BIN(jump):{ 566 return depth + 0; 567 } 568 case BIN(branchif):{ 569 return depth + -1; 570 } 571 case BIN(branchunless):{ 572 return depth + -1; 573 } 574 case BIN(getinlinecache):{ 575 return depth + 1; 576 } 577 case BIN(onceinlinecache):{ 578 return depth + 1; 579 } 580 case BIN(setinlinecache):{ 581 return depth + 0; 582 } 583 case BIN(opt_case_dispatch):{ 584 int inc = 0; 585 inc += -1;; 586 return depth + inc; 587 } 588 case BIN(opt_plus):{ 589 return depth + -1; 590 } 591 case BIN(opt_minus):{ 592 return depth + -1; 593 } 594 case BIN(opt_mult):{ 595 return depth + -1; 596 } 597 case BIN(opt_div):{ 598 return depth + -1; 599 } 600 case BIN(opt_mod):{ 601 return depth + -1; 602 } 603 case BIN(opt_eq):{ 604 return depth + -1; 605 } 606 case BIN(opt_neq):{ 607 return depth + -1; 608 } 609 case BIN(opt_lt):{ 610 return depth + -1; 611 } 612 case BIN(opt_le):{ 613 return depth + -1; 614 } 615 case BIN(opt_gt):{ 616 return depth + -1; 617 } 618 case BIN(opt_ge):{ 619 return depth + -1; 620 } 621 case BIN(opt_ltlt):{ 622 return depth + -1; 623 } 624 case BIN(opt_aref):{ 625 return depth + -1; 626 } 627 case BIN(opt_aset):{ 628 return depth + -2; 629 } 630 case BIN(opt_length):{ 631 return depth + 0; 632 } 633 case BIN(opt_size):{ 634 return depth + 0; 635 } 636 case BIN(opt_empty_p):{ 637 return depth + 0; 638 } 639 case BIN(opt_succ):{ 640 return depth + 0; 641 } 642 case BIN(opt_not):{ 643 return depth + 0; 644 } 645 case BIN(opt_regexpmatch1):{ 646 return depth + 0; 647 } 648 case BIN(opt_regexpmatch2):{ 649 return depth + -1; 650 } 651 case BIN(opt_call_c_function):{ 652 return depth + 0; 653 } 654 case BIN(bitblt):{ 655 return depth + 1; 656 } 657 case BIN(answer):{ 658 return depth + 1; 659 } 660 case BIN(getlocal_OP__WC__0):{ 661 return depth + 1; 662 } 663 case BIN(getlocal_OP__WC__1):{ 664 return depth + 1; 665 } 666 case BIN(setlocal_OP__WC__0):{ 667 return depth + -1; 668 } 669 case BIN(setlocal_OP__WC__1):{ 670 return depth + -1; 671 } 672 case BIN(putobject_OP_INT2FIX_O_0_C_):{ 673 return depth + 1; 674 } 675 case BIN(putobject_OP_INT2FIX_O_1_C_):{ 676 return depth + 1; 677 } 678 679 default: 680 rb_bug("insn_sp_increase: unreachable"); 681 } 682 return 0; 683} 684#endif 685 686/* some utilities */ 687 688static int 689insn_len(VALUE insn) 690{ 691 return insn_len_info[(int)insn]; 692} 693 694static const char * 695insn_name(VALUE insn) 696{ 697 return insn_name_info[(int)insn]; 698} 699 700static const char * 701insn_op_types(VALUE insn) 702{ 703 return insn_operand_info[(int)insn]; 704} 705 706static int 707insn_op_type(VALUE insn, long pos) 708{ 709 int len = insn_len(insn) - 1; 710 if(pos < len){ 711 return insn_operand_info[(int)insn][pos]; 712 } 713 else{ 714 return 0; 715 } 716} 717 718#ifdef USE_INSN_RET_NUM 719static int 720insn_ret_num(VALUE insn) 721{ 722 return insn_stack_push_num_info[(int)insn]; 723} 724#endif 725