exec.c
1 /* 2 * Bean Java VM 3 * Copyright (C) 2005-2020 Christian Lins <christian@lins.me> 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #include <assert.h> 19 #include <stdbool.h> 20 #include <stdint.h> 21 #include <stdlib.h> 22 23 #include <debug.h> 24 #include <stackframe.h> 25 #include <thread.h> 26 #include <bytecode.h> 27 28 uint8_t Get1ByteOperand(Stackframe* frame) 29 { 30 return *(++frame->instPtr); 31 } 32 33 uint16_t Get2ByteOperand(Stackframe* frame) 34 { 35 uint16_t operand = 0x0000; 36 37 operand = Get1ByteOperand(frame); 38 operand = operand << 8; 39 operand = operand | Get1ByteOperand(frame); 40 41 return operand; 42 } 43 44 uint32_t Get4ByteOperand(Stackframe * frame) 45 { 46 uint32_t operand = 0x00000000; 47 48 operand = Get2ByteOperand(frame); 49 operand = operand << 16; 50 operand = operand | Get2ByteOperand(frame); 51 52 return operand; 53 } 54 55 int exec_thread(Thread *thread) 56 { 57 Stackframe* frame = current_frame(thread); 58 59 #ifdef DEBUG 60 assert(frame != NULL); 61 printf("Opcode 0x%x (%p)\tClass %p\n", 62 *(frame->instPtr), (void *) frame->instPtr, 63 (void *) thread->RunningClass); 64 #endif 65 66 // Instruction pointer is incremented by one AFTER execution, 67 // except for the INVOKE and RETURN statements where this is handled in 68 // the appropriate do-functions. 69 bool incrementPtr = true; 70 71 uint8_t opcode = *(frame->instPtr); 72 switch (opcode) { 73 case IL_NOP:{ /* No operation */ 74 // Simply do nothing but incrementing IP 75 break; 76 } 77 case IL_ACONST_NULL: /* Pushes a NULL-reference onto the stack */ 78 { 79 do_ACONST_NULL(thread); 80 break; 81 } 82 case IL_ICONST_M1: /* Pushes int -1 onto the stack */ 83 { 84 do_ICONSTi(thread, -1); 85 break; 86 } 87 case IL_ICONST_0: /* Pushes int 0 onto the stack */ 88 { 89 do_ICONSTi(thread, 0); 90 break; 91 } 92 case IL_ICONST_1: /* Pushes int 1 onto the stack */ 93 { 94 do_ICONSTi(thread, 1); 95 break; 96 } 97 case IL_ICONST_2: /* Pushes int 2 onto the stack */ 98 { 99 do_ICONSTi(thread, 2); 100 break; 101 } 102 case IL_ICONST_3: /* Pushes int 3 onto the stack */ 103 { 104 do_ICONSTi(thread, 3); 105 break; 106 } 107 case IL_ICONST_4: /* Pushes int 4 onto the stack */ 108 { 109 do_ICONSTi(thread, 4); 110 break; 111 } 112 case IL_ICONST_5: /* Pushes int 5 onto the stack */ 113 { 114 do_ICONSTi(thread, 5); 115 break; 116 } 117 case IL_LCONST_0: /* Pushes long 0 onto the stack */ 118 { 119 do_LCONSTi(thread, 0); 120 break; 121 } 122 case IL_LCONST_1: /* Pushes long 1 onto the stack */ 123 { 124 do_LCONSTi(thread, 1); 125 break; 126 } 127 case IL_FCONST_0: /* Pushes 0.0f onto the stack */ 128 { 129 do_FCONSTi(thread, 0.0f); 130 break; 131 } 132 case IL_FCONST_1: /* Pushes 1.0f onto the stack */ 133 { 134 do_FCONSTi(thread, 1.0f); 135 break; 136 } 137 case IL_FCONST_2: /* Pushes 2.0f onto the stack */ 138 { 139 do_FCONSTi(thread, 2.0f); 140 break; 141 } 142 case IL_DCONST_0: /* Pushes 0.0 onto the stack */ 143 { 144 do_DCONSTi(thread, 0.0); 145 break; 146 } 147 case IL_DCONST_1: /* Pushes 1.0 onto the stack */ 148 { 149 do_DCONSTi(thread, 1.0); 150 break; 151 } 152 case IL_BIPUSH: /* Expands a byte and pushes it as int onto the stack */ 153 { 154 do_BIPUSH(thread); 155 break; 156 } 157 case IL_SIPUSH: /* Expands a short and pushes it as int onto the stack */ 158 { 159 do_SIPUSH(thread); 160 break; 161 } 162 case IL_LDC: /* Pushes a 32-bit constant-pool entry */ 163 { 164 do_LDC(thread); 165 break; 166 } 167 case IL_LDC_W: /* Pushes a 32-bit constant-pool entry (indexed by two bytes) */ 168 { 169 do_LDC_W(thread); 170 break; 171 } 172 case IL_LDC2_W: /* Pushes a 64-bit constant-pool entry */ 173 { 174 do_LDC2_W(thread); 175 break; 176 } 177 case IL_ILOAD: /* Pushes int from local variable index onto the stack */ 178 { 179 do_ILOAD(thread); 180 break; 181 } 182 case IL_LLOAD: /* Pushes long from local variable index onto the stack */ 183 { 184 do_LLOAD(thread); 185 break; 186 } 187 case IL_FLOAD: /* Pushes float from local variable index onto the stack */ 188 { 189 do_FLOAD(thread); 190 break; 191 } 192 case IL_DLOAD: /* Pushes float from local variable index onto the stack */ 193 { 194 do_DLOAD(thread); 195 break; 196 } 197 case IL_ALOAD: /* Pushes object reference from local vars onto the stack */ 198 { 199 do_ALOAD(thread); 200 break; 201 } 202 case IL_ILOAD_0: /* Pushes int from local vars [0] onto the stack */ 203 { 204 do_ILOADi(thread, 0); 205 break; 206 } 207 case IL_ILOAD_1: /* Pushes int from local vars [1] onto the stack */ 208 { 209 do_ILOADi(thread, 1); 210 break; 211 } 212 case IL_ILOAD_2: /* Pushes int from local vars [2] onto the stack */ 213 { 214 do_ILOADi(thread, 2); 215 break; 216 } 217 case IL_ILOAD_3: /* Pushes int from local vars [3] onto the stack */ 218 { 219 do_ILOADi(thread, 3); 220 break; 221 } 222 case IL_LLOAD_0: /* Pushes long from local vars [0] onto the stack */ 223 { 224 do_LLOADi(thread, 0); 225 break; 226 } 227 case IL_LLOAD_1: /* Pushes long from local vars [1] onto the stack */ 228 { 229 do_LLOADi(thread, 1); 230 break; 231 } 232 case IL_LLOAD_2: /* Pushes long from local vars [2] onto the stack */ 233 { 234 do_LLOADi(thread, 2); 235 break; 236 } 237 case IL_LLOAD_3: /* Pushes long from local vars [3] onto the stack */ 238 { 239 do_LLOADi(thread, 3); 240 break; 241 } 242 case IL_FLOAD_0: /* Pushes float from local vars [0] onto the stack */ 243 { 244 do_FLOADi(thread, 0); 245 break; 246 } 247 case IL_FLOAD_1: /* Pushes float from local vars [1] onto the stack */ 248 { 249 do_FLOADi(thread, 1); 250 break; 251 } 252 case IL_FLOAD_2: /* Pushes float from local vars [2] onto the stack */ 253 { 254 do_FLOADi(thread, 2); 255 break; 256 } 257 case IL_FLOAD_3: /* Pushes float from local vars [3] onto the stack */ 258 { 259 do_FLOADi(thread, 3); 260 break; 261 } 262 case IL_DLOAD_0: /* Pushes double from local vars [0] onto the stack */ 263 { 264 do_DLOADi(thread, 0); 265 break; 266 } 267 case IL_DLOAD_1: /* Pushes double from local vars [1] onto the stack */ 268 { 269 do_DLOADi(thread, 1); 270 break; 271 } 272 case IL_DLOAD_2: /* Pushes double from local vars [2] onto the stack */ 273 { 274 do_DLOADi(thread, 2); 275 break; 276 } 277 case IL_DLOAD_3: /* Pushes double from local vars [3] onto the stack */ 278 { 279 do_DLOADi(thread, 3); 280 break; 281 } 282 case IL_ALOAD_0: /* Pushes object reference from local vars [0] onto the stack */ 283 { 284 do_ALOADi(thread, 0); 285 break; 286 } 287 case IL_ALOAD_1: 288 { 289 do_ALOADi(thread, 1); 290 break; 291 } 292 case IL_ALOAD_2: 293 { 294 do_ALOADi(thread, 2); 295 break; 296 } 297 case IL_ALOAD_3: 298 { 299 do_ALOADi(thread, 3); 300 break; 301 } 302 case IL_IALOAD: 303 { 304 do_IALOAD(thread); 305 break; 306 } 307 case IL_LALOAD: 308 { 309 do_LALOAD(thread); 310 break; 311 } 312 case IL_FALOAD: 313 { 314 do_FALOAD(thread); 315 break; 316 } 317 case IL_DALOAD: 318 { 319 do_DALOAD(thread); 320 break; 321 } 322 case IL_AALOAD: 323 { 324 do_AALOAD(thread); 325 break; 326 } 327 case IL_BALOAD: 328 { 329 do_BALOAD(thread); 330 break; 331 } 332 case IL_CALOAD: 333 { 334 do_CALOAD(thread); 335 break; 336 } 337 case IL_SALOAD: 338 { 339 do_SALOAD(thread); 340 break; 341 } 342 case IL_ISTORE: 343 { 344 do_ISTORE(thread); 345 break; 346 } 347 case IL_LSTORE: 348 { 349 do_LSTORE(thread); 350 break; 351 } 352 case IL_FSTORE: 353 { 354 do_FSTORE(thread); 355 break; 356 } 357 case IL_DSTORE: 358 { 359 do_DSTORE(thread); 360 break; 361 } 362 case IL_ASTORE: 363 { 364 do_ASTORE(thread); 365 break; 366 } 367 case IL_ISTORE_0: 368 { 369 do_ISTOREi(thread, 0); 370 break; 371 } 372 case IL_ISTORE_1: 373 { 374 do_ISTOREi(thread, 1); 375 break; 376 } 377 case IL_ISTORE_2: 378 { 379 do_ISTOREi(thread, 2); 380 break; 381 } 382 case IL_ISTORE_3: 383 { 384 do_ISTOREi(thread, 3); 385 break; 386 } 387 case IL_LSTORE_0: 388 { 389 do_LSTOREi(thread, 0); 390 break; 391 } 392 case IL_LSTORE_1: 393 { 394 do_LSTOREi(thread, 1); 395 break; 396 } 397 case IL_LSTORE_2: 398 { 399 do_LSTOREi(thread, 2); 400 break; 401 } 402 case IL_LSTORE_3: 403 { 404 do_LSTOREi(thread, 3); 405 break; 406 } 407 case IL_FSTORE_0: 408 { 409 do_FSTOREi(thread, 0); 410 break; 411 } 412 case IL_FSTORE_1: 413 { 414 do_FSTOREi(thread, 1); 415 break; 416 } 417 case IL_FSTORE_2: 418 { 419 do_FSTOREi(thread, 2); 420 break; 421 } 422 case IL_FSTORE_3: 423 { 424 do_FSTOREi(thread, 3); 425 break; 426 } 427 case IL_DSTORE_0: 428 { 429 do_DSTOREi(thread, 0); 430 break; 431 } 432 case IL_DSTORE_1: 433 { 434 do_DSTOREi(thread, 1); 435 break; 436 } 437 case IL_DSTORE_2: 438 { 439 do_DSTOREi(thread, 2); 440 break; 441 } 442 case IL_DSTORE_3: 443 { 444 do_DSTOREi(thread, 3); 445 break; 446 } 447 case IL_ASTORE_0: 448 { 449 do_ASTOREi(thread, 0); 450 break; 451 } 452 case IL_ASTORE_1: 453 { 454 do_ASTOREi(thread, 1); 455 break; 456 } 457 case IL_ASTORE_2: 458 { 459 do_ASTOREi(thread, 2); 460 break; 461 } 462 case IL_ASTORE_3: 463 { 464 do_ASTOREi(thread, 3); 465 break; 466 } 467 case IL_IASTORE: 468 { 469 do_IASTORE(thread); 470 break; 471 } 472 case IL_LASTORE: 473 { 474 do_LASTORE(thread); 475 break; 476 } 477 case IL_FASTORE: 478 { 479 do_FASTORE(thread); 480 break; 481 } 482 case IL_DASTORE: 483 { 484 do_DASTORE(thread); 485 break; 486 } 487 case IL_AASTORE: 488 { 489 do_AASTORE(thread); 490 break; 491 } 492 case IL_BASTORE: 493 { 494 do_BASTORE(thread); 495 break; 496 } 497 case IL_CASTORE: 498 { 499 do_CASTORE(thread); 500 break; 501 } 502 case IL_SASTORE: 503 { 504 do_SASTORE(thread); 505 break; 506 } 507 case IL_POP: 508 { 509 do_POP(thread); 510 break; 511 } 512 case IL_POP2: 513 { 514 do_POP2(thread); 515 break; 516 } 517 case IL_DUP: 518 { 519 do_DUP(thread); 520 break; 521 } 522 case IL_DUP_X1: 523 { 524 do_DUP_X1(thread); 525 break; 526 } 527 case IL_DUP_X2: 528 { 529 do_DUP_X2(thread); 530 break; 531 } 532 case IL_DUP2: 533 { 534 do_DUP2(thread); 535 break; 536 } 537 case IL_DUP2_X1: 538 { 539 do_DUP2_X1(thread); 540 break; 541 } 542 case IL_DUP2_X2: 543 { 544 do_DUP2_X2(thread); 545 break; 546 } 547 case IL_SWAP: 548 { 549 do_SWAP(thread); 550 break; 551 } 552 case IL_IADD: 553 { 554 do_IADD(thread); 555 break; 556 } 557 case IL_LADD: 558 { 559 do_LADD(thread); 560 break; 561 } 562 case IL_FADD: 563 { 564 do_FADD(thread); 565 break; 566 } 567 case IL_DADD: 568 { 569 do_DADD(thread); 570 break; 571 } 572 case IL_ISUB: 573 { 574 do_ISUB(thread); 575 break; 576 } 577 case IL_LSUB: 578 { 579 do_LSUB(thread); 580 break; 581 } 582 case IL_FSUB: 583 { 584 do_FSUB(thread); 585 break; 586 } 587 case IL_DSUB: 588 { 589 do_DSUB(thread); 590 break; 591 } 592 case IL_IMUL: 593 { 594 do_IMUL(thread); 595 break; 596 } 597 case IL_LMUL: 598 { 599 do_LMUL(thread); 600 break; 601 } 602 case IL_FMUL: 603 { 604 do_FMUL(thread); 605 break; 606 } 607 case IL_DMUL: 608 { 609 do_DMUL(thread); 610 break; 611 } 612 case IL_IDIV: 613 { 614 do_IDIV(thread); 615 break; 616 } 617 case IL_LDIV: 618 { 619 do_LDIV(thread); 620 break; 621 } 622 case IL_FDIV: 623 { 624 do_FDIV(thread); 625 break; 626 } 627 case IL_DDIV: 628 { 629 do_DDIV(thread); 630 break; 631 } 632 case IL_IREM: 633 { 634 do_IREM(thread); 635 break; 636 } 637 case IL_LREM: 638 { 639 do_LREM(thread); 640 break; 641 } 642 case IL_FREM: 643 { 644 do_FREM(thread); 645 break; 646 } 647 case IL_DREM: 648 { 649 do_DREM(thread); 650 break; 651 } 652 case IL_INEG: 653 { 654 do_INEG(thread); 655 break; 656 } 657 case IL_LNEG: 658 { 659 do_LNEG(thread); 660 break; 661 } 662 case IL_FNEG: 663 { 664 do_FNEG(thread); 665 break; 666 } 667 case IL_DNEG: 668 { 669 do_DNEG(thread); 670 break; 671 } 672 case IL_ISHL: 673 { 674 do_ISHL(thread); 675 break; 676 } 677 case IL_LSHL: 678 { 679 do_LSHL(thread); 680 break; 681 } 682 case IL_ISHR: 683 { 684 do_ISHR(thread); 685 break; 686 } 687 case IL_LSHR: 688 { 689 do_LSHR(thread); 690 break; 691 } 692 case IL_IUSHR: 693 { 694 do_IUSHR(thread); 695 break; 696 } 697 case IL_LUSHR: 698 { 699 do_LUSHR(thread); 700 break; 701 } 702 case IL_IAND: 703 { 704 do_IAND(thread); 705 break; 706 } 707 case IL_LAND: 708 { 709 do_LAND(thread); 710 break; 711 } 712 case IL_IOR: 713 { 714 do_IOR(thread); 715 break; 716 } 717 case IL_LOR: 718 { 719 do_LOR(thread); 720 break; 721 } 722 case IL_IXOR: 723 { 724 do_IXOR(thread); 725 break; 726 } 727 case IL_LXOR: 728 { 729 do_LXOR(thread); 730 break; 731 } 732 case IL_IINC: 733 { 734 do_IINC(thread); 735 break; 736 } 737 case IL_I2L: 738 { 739 do_I2L(thread); 740 break; 741 } 742 case IL_I2F: 743 { 744 do_I2F(thread); 745 break; 746 } 747 case IL_I2D: 748 { 749 do_I2D(thread); 750 break; 751 } 752 case IL_L2I: 753 { 754 do_L2I(thread); 755 break; 756 } 757 case IL_L2F: 758 { 759 do_L2F(thread); 760 break; 761 } 762 case IL_L2D: 763 { 764 do_L2D(thread); 765 break; 766 } 767 case IL_F2I: 768 { 769 do_F2I(thread); 770 break; 771 } 772 case IL_F2L: 773 { 774 do_F2L(thread); 775 break; 776 } 777 case IL_F2D: 778 { 779 do_F2D(thread); 780 break; 781 } 782 case IL_D2I: 783 { 784 do_D2I(thread); 785 break; 786 } 787 case IL_D2L: 788 { 789 do_D2L(thread); 790 break; 791 } 792 case IL_D2F: 793 { 794 do_D2F(thread); 795 break; 796 } 797 case IL_I2B: 798 { 799 do_I2B(thread); 800 break; 801 } 802 case IL_I2C: 803 { 804 do_I2C(thread); 805 break; 806 } 807 case IL_I2S: 808 { 809 do_I2S(thread); 810 break; 811 } 812 case IL_LCMP: 813 { 814 do_LCMP(thread); 815 break; 816 } 817 case IL_FCMPL: 818 { 819 do_FCMPL(thread); 820 break; 821 } 822 case IL_FCMPG: 823 { 824 do_FCMPG(thread); 825 break; 826 } 827 case IL_DCMPL: 828 { 829 do_DCMPL(thread); 830 break; 831 } 832 case IL_DCMPG: 833 { 834 do_DCMPG(thread); 835 break; 836 } 837 case IL_IFEQ: 838 { 839 do_IFEQ(thread); 840 break; 841 } 842 case IL_IFNE: 843 { 844 do_IFNE(thread); 845 break; 846 } 847 case IL_IFLT: 848 { 849 do_IFLT(thread); 850 break; 851 } 852 case IL_IFGE: 853 { 854 do_IFGE(thread); 855 break; 856 } 857 case IL_IFGT: 858 { 859 do_IFGT(thread); 860 break; 861 } 862 case IL_IFLE: 863 { 864 do_IFLE(thread); 865 break; 866 } 867 case IL_IF_ICMPEQ: 868 { 869 do_IF_ICMPEQ(thread); 870 break; 871 } 872 case IL_IF_ICMPNE: 873 { 874 do_IF_ICMPNE(thread); 875 break; 876 } 877 case IL_IF_ICMPLT: 878 { 879 do_IF_ICMPLT(thread); 880 break; 881 } 882 case IL_IF_ICMPGE: 883 { 884 do_IF_ICMPGE(thread); 885 break; 886 } 887 case IL_IF_ICMPGT: 888 { 889 do_IF_ICMPGT(thread); 890 break; 891 } 892 case IL_IF_ICMPLE: 893 { 894 do_IF_ICMPLE(thread); 895 break; 896 } 897 case IL_IF_ACMPEQ: 898 { 899 do_IF_ACMPEQ(thread); 900 break; 901 } 902 case IL_IF_ACMPNE: 903 { 904 do_IF_ACMPNE(thread); 905 break; 906 } 907 case IL_GOTO: 908 { 909 do_GOTO(thread); 910 break; 911 } 912 case IL_JSR: 913 { 914 do_JSR(thread); 915 break; 916 } 917 case IL_RET: 918 { 919 do_RET(thread); 920 incrementPtr = false; 921 break; 922 } 923 case IL_TABLESWITCH: 924 { 925 do_TABLESWITCH(thread); 926 break; 927 } 928 case IL_LOOKUPSWITCH: 929 { 930 do_LOOKUPSWITCH(thread); 931 break; 932 } 933 case IL_IRETURN: 934 { 935 do_IRETURN(thread); 936 incrementPtr = false; 937 break; 938 } 939 case IL_LRETURN: 940 { 941 do_LRETURN(thread); 942 incrementPtr = false; 943 break; 944 } 945 case IL_FRETURN: 946 { 947 do_FRETURN(thread); 948 incrementPtr = false; 949 break; 950 } 951 case IL_DRETURN: 952 { 953 do_DRETURN(thread); 954 incrementPtr = false; 955 break; 956 } 957 case IL_ARETURN: 958 { 959 do_ARETURN(thread); 960 incrementPtr = false; 961 break; 962 } 963 case IL_RETURN: 964 { 965 do_RETURN(thread); 966 incrementPtr = false; 967 break; 968 } 969 case IL_GETSTATIC: 970 { 971 do_GETSTATIC(thread); 972 break; 973 } 974 case IL_PUTSTATIC: 975 { 976 do_PUTSTATIC(thread); 977 break; 978 } 979 case IL_GETFIELD: 980 { 981 do_GETFIELD(thread); 982 break; 983 } 984 case IL_PUTFIELD: 985 { 986 do_PUTFIELD(thread); 987 break; 988 } 989 case IL_INVOKEVIRTUAL: 990 { 991 do_INVOKEVIRTUAL(thread); 992 incrementPtr = false; 993 break; 994 } 995 case IL_INVOKESPECIAL: 996 { 997 do_INVOKESPECIAL(thread); 998 incrementPtr = false; 999 break; 1000 } 1001 case IL_INVOKESTATIC: 1002 { 1003 do_INVOKESTATIC(thread); 1004 incrementPtr = false; 1005 break; 1006 } 1007 case IL_INVOKEINTERFACE: 1008 { 1009 do_INVOKEINTERFACE(thread); 1010 incrementPtr = false; 1011 break; 1012 } 1013 case IL_NEW: 1014 { 1015 do_NEW(thread); 1016 break; 1017 } 1018 case IL_NEWARRAY: 1019 { 1020 do_NEWARRAY(thread); 1021 break; 1022 } 1023 case IL_ANEWARRAY: 1024 { 1025 do_ANEWARRAY(thread); 1026 break; 1027 } 1028 case IL_ARRAYLENGTH: 1029 { 1030 do_ARRAYLENGTH(thread); 1031 break; 1032 } 1033 case IL_ATHROW: 1034 { 1035 do_ATHROW(thread); 1036 break; 1037 } 1038 case IL_CHECKCAST: 1039 { 1040 do_CHECKCAST(thread); 1041 break; 1042 } 1043 case IL_INSTANCEOF: 1044 { 1045 do_INSTANCEOF(thread); 1046 break; 1047 } 1048 case IL_MONITORENTER: 1049 { 1050 do_MONITORENTER(thread); 1051 break; 1052 } 1053 case IL_MONITOREXIT: 1054 { 1055 do_MONITOREXIT(thread); 1056 break; 1057 } 1058 case IL_WIDE: 1059 { 1060 do_WIDE(thread); 1061 break; 1062 } 1063 case IL_MULTIANEWARRAY: 1064 { 1065 do_MULTIANEWARRAY(thread); 1066 break; 1067 } 1068 case IL_IFNULL: 1069 { 1070 do_IFNULL(thread); 1071 break; 1072 } 1073 case IL_IFNONNULL: 1074 { 1075 do_IFNONNULL(thread); 1076 break; 1077 } 1078 case IL_GOTO_W: 1079 { 1080 do_GOTO_W(thread); 1081 break; 1082 } 1083 case IL_JSR_W: 1084 { 1085 do_JSR_W(thread); 1086 break; 1087 } 1088 1089 /* Reserved opcodes: */ 1090 case IL_RESERVED1: 1091 case IL_BREAKPOINT: 1092 case IL_IMPDEP1: 1093 case IL_IMPDEP2:{ 1094 // Do nothing 1095 break; 1096 } 1097 1098 default:{ 1099 /* Throw unknown opcode exception */ 1100 printf("Unknown opcode %x\n", *(frame->instPtr)); 1101 exit(false); 1102 break; 1103 } 1104 } 1105 1106 // Instruction pointer is incremented by one. Some opcodes have already 1107 // incremented the pointer, but the last incrementation is done here 1108 if(incrementPtr) { 1109 frame->instPtr++; 1110 } 1111 1112 return true; 1113 }