1# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14definitions: 15 - name: pandasm_header 16 template: | 17 .language PandaAssembly 18 19 .record panda.Object <external> 20 21 .record Q {} 22 .function void Q.ctor(Q a0) <ctor> { 23 return.void 24 } 25 26 .record R { 27 u1 fu1 <static> 28 u8 fu8 <static> 29 i8 fi8 <static> 30 u16 fu16 <static> 31 i16 fi16 <static> 32 u32 fu32 <static> 33 i32 fi32 <static> 34 u64 fu64 <static> 35 i64 fi64 <static> 36 f32 ff32 <static> 37 f64 ff64 <static> 38 # objects: 39 i32[] fi32Array <static> 40 Q fQ <static> 41 Q[] fQArray <static> 42 R fR <static> 43 R[] fRArray <static> 44 panda.Object fObj <static> 45 panda.Object[] fObjArray <static> 46 } 47 .function void R.ctor(R a0) <ctor> { 48 return.void 49 } 50 51 - name: PandaAssembly_header 52 template: | 53 .language PandaAssembly 54 55 .record panda.Object <external> 56 .function void panda.Object.ctor(panda.Object a0) <external, ctor> 57 58 .record I <panda.interface> {} 59 60 .record Q <panda.implements=I> {} 61 .function void Q.ctor(Q a0) <ctor> { 62 return.void 63 } 64 65 .record R <panda.extends=Q> { 66 u1 fu1 <static> 67 i8 fi8 <static> 68 u16 fu16 <static> 69 i16 fi16 <static> 70 i32 fi32 <static> 71 i64 fi64 <static> 72 f32 ff32 <static> 73 f64 ff64 <static> 74 # objects 75 i32[] fi32Array <static> 76 Q fQ <static> 77 Q[] fQArray <static> 78 R fR <static> 79 R[] fRArray <static> 80 I fI <static> 81 I[] fIArray <static> 82 panda.Object fObj <static> 83 panda.Object[] fObjArray <static> 84 } 85 .function void R.ctor(R a0) <ctor> { 86 return.void 87 } 88 89tests: 90 - file-name: "ststatic.obj" 91 isa: 92 title: Store to static field 93 description: > 94 Store accumulator content into static field by field_id. 95 instructions: 96 - sig: ststatic.obj field_id 97 acc: in:ref 98 format: [op_id_16] 99 commands: 100 101 - file-name: "check_if_acc_initialized" 102 description: Check that verifier reports an error if accumulator is not initialized 103 isa: 104 description: Store accumulator content into static field by field_id. 105 header-template: ['pandasm_header'] 106 check-type: exit-positive 107 tags: ['verifier'] 108 bugid: ['1324'] 109 runner-options: ['verifier-failure', 'verifier-config'] 110 code-template: | 111 112 .function i32 main() { 113 # acc (value) not initialized, verifier error expected 114 ststatic.obj R.fR 115 116 117 - file-name: "with_non_static_field_id" 118 bugid: ['1324'] 119 description: Check that verifier reports error when the field_id doesn't resolve to a static valid field 120 isa: 121 verification: 122 - field_id_static 123 header-template: ['pandasm_header'] 124 check-type: exit-positive 125 code-template: | 126 .record W { 127 u1 fu1 128 i8 fi8 129 u16 fu16 130 i16 fi16 131 i32 fi32 132 i64 fi64 133 f32 ff32 134 f64 ff64 135 W fW 136 i32[] fi32Array 137 W[] fWArray 138 } 139 .function void W.object_function(W a0) { 140 return.void 141 } 142 .function void static_function() { 143 return.void 144 } 145 146 .function i32 main() { 147 lda.null 148 ststatic.obj %s 149 cases: 150 - values: 151 - W.fu1 152 tags: [verifier] 153 runner-options: ['verifier-failure', 'verifier-config'] 154 bugid: ['1324', '1828'] 155 - values: 156 - W.fi8 157 tags: [verifier] 158 runner-options: ['verifier-failure', 'verifier-config'] 159 bugid: ['1324', '1828'] 160 - values: 161 - W.fu16 162 tags: [verifier] 163 runner-options: ['verifier-failure', 'verifier-config'] 164 bugid: ['1324', '1828'] 165 - values: 166 - W.fi16 167 tags: [verifier] 168 runner-options: ['verifier-failure', 'verifier-config'] 169 bugid: ['1324', '1828'] 170 - values: 171 - W.fi32 172 tags: [verifier] 173 runner-options: ['verifier-failure', 'verifier-config'] 174 bugid: ['1324', '1828'] 175 - values: 176 - W.fi64 177 tags: [verifier] 178 runner-options: ['verifier-failure', 'verifier-config'] 179 bugid: ['1324', '1828'] 180 - values: 181 - W.ff32 182 tags: [verifier] 183 runner-options: ['verifier-failure', 'verifier-config'] 184 bugid: ['1324', '1828'] 185 - values: 186 - W.ff64 187 tags: [verifier] 188 runner-options: ['verifier-failure', 'verifier-config'] 189 bugid: ['1324', '1828'] 190 - values: 191 - W.fW 192 tags: [verifier] 193 runner-options: ['verifier-failure', 'verifier-config'] 194 bugid: ['1324', '1828'] 195 - values: 196 - W.fi32Array 197 tags: [verifier] 198 runner-options: ['verifier-failure', 'verifier-config'] 199 bugid: ['1324', '1828'] 200 - values: 201 - W.fWArray 202 tags: [verifier] 203 runner-options: ['verifier-failure', 'verifier-config'] 204 bugid: ['1324', '1828'] 205 - values: 206 - W 207 runner-options: ['compile-failure'] 208 - values: 209 - W.object_function 210 runner-options: ['compile-failure'] 211 - values: 212 - static_function 213 runner-options: ['compile-failure'] 214 - values: 215 - unknown_function 216 runner-options: ['compile-failure'] 217 - values: 218 - 0 219 runner-options: ['compile-failure'] 220 - values: 221 - -1.1 222 runner-options: ['compile-failure'] 223 - values: 224 - "null" 225 runner-options: ['compile-failure'] 226 - values: 227 - "\"abc\"" 228 runner-options: ['compile-failure'] 229 230 231 - file-name: "with_wrong_acc_type_pa" 232 description: Check that verifier reports an error when the accumulator contains a value of type not corresponding to the bytecode 233 isa: 234 verification: 235 - acc_type 236 header-template: ['pandasm_header'] 237 check-type: exit-positive 238 tags: ['verifier'] 239 runner-options: ['verifier-failure', 'verifier-config'] 240 code-template: | 241 242 .function i32 main() { 243 %s 244 ststatic.obj %s 245 cases: 246 # store into object type field 247 - values: 248 - ldai 0 249 - R.fQ 250 bugid: ['1324', '1834'] 251 - values: 252 - ldai.64 1 253 - R.fQ 254 bugid: ['1324', '1834'] 255 - values: 256 - fldai.64 0x7FFFFFFFFFFFFFFF 257 - R.fQ 258 bugid: ['1324', '1834'] 259 - values: 260 - lda.type R 261 - R.fQ 262 bugid: ['1834'] 263 - values: 264 - | 265 # 266 newobj v1, panda.Object 267 lda.obj v1 268 - R.fQ 269 - values: 270 - | 271 # 272 movi v1, 10 273 newarr v1, v1, Q[] 274 lda.obj v1 275 - R.fQ 276 bugid: ['1834'] 277 # store into object array type field 278 - values: 279 - ldai 0 280 - R.fQArray 281 bugid: ['1324', '1834'] 282 - values: 283 - ldai.64 1 284 - R.fQArray 285 bugid: ['1324', '1834'] 286 - values: 287 - fldai.64 0x7FFFFFFFFFFFFFFF 288 - R.fQArray 289 bugid: ['1324', '1834'] 290 - values: 291 - initobj Q.ctor 292 - R.fQArray 293 bugid: ['1834'] 294 - values: 295 - | 296 # 297 newobj v1, panda.Object 298 lda.obj v1 299 - R.fQArray 300 - values: 301 - | 302 # 303 movi v1, 10 304 newarr v1, v1, R[] 305 lda.obj v1 306 - R.fQArray 307 bugid: ['1834'] 308 - values: 309 - | 310 # 311 movi v1, 10 312 newarr v1, v1, panda.Object[] 313 lda.obj v1 314 - R.fQArray 315 # store into i32[] array field 316 - values: 317 - ldai 0 318 - R.fi32Array 319 bugid: ['1324', '1834'] 320 - values: 321 - ldai.64 1 322 - R.fi32Array 323 bugid: ['1324', '1834'] 324 - values: 325 - fldai.64 0x7FFFFFFFFFFFFFFF 326 - R.fi32Array 327 bugid: ['1324', '1834'] 328 - values: 329 - lda.type R 330 - R.fi32Array 331 bugid: ['1834'] 332 - values: 333 - | 334 # 335 movi v1, 10 336 newarr v1, v1, Q[] 337 lda.obj v1 338 - R.fi32Array 339 bugid: ['1834'] 340 # store into panda.Object field 341 - values: 342 - ldai 0 343 - R.fObj 344 - values: 345 - ldai.64 1 346 - R.fObj 347 - values: 348 - fldai.64 0x7FFFFFFFFFFFFFFF 349 - R.fObj 350 - values: 351 - | 352 # 353 newobj v1, panda.Object 354 lda.obj v1 355 - R.fObj 356 runner-options: ['verifier-only', 'verifier-config'] 357 - values: 358 - lda.type R 359 - R.fObj 360 runner-options: ['verifier-only', 'verifier-config'] 361 bugid: ['3594'] 362 ignore: true 363 - values: 364 - lda.str "" 365 - R.fObj 366 runner-options: ['verifier-only', 'verifier-config'] 367 - values: 368 - lda.null 369 - R.fObj 370 runner-options: ['verifier-only', 'verifier-config'] 371 - values: 372 - | 373 # 374 movi v1, 10 375 newarr v1, v1, Q[] 376 lda.obj v1 377 - R.fObj 378 runner-options: ['verifier-only', 'verifier-config'] 379 # store into panda.Object[] field 380 - values: 381 - ldai 0 382 - R.fObjArray 383 - values: 384 - ldai.64 1 385 - R.fObjArray 386 - values: 387 - fldai.64 0x7FFFFFFFFFFFFFFF 388 - R.fObjArray 389 - values: 390 - | 391 # 392 newobj v1, panda.Object 393 lda.obj v1 394 - R.fObjArray 395 - values: 396 - lda.type R 397 - R.fObjArray 398 - values: 399 - lda.str "" 400 - R.fObjArray 401 - values: 402 - lda.null 403 - R.fObjArray 404 runner-options: ['verifier-only', 'verifier-config'] 405 - values: 406 - | 407 # 408 movi v1, 10 409 newarr v1, v1, Q[] 410 lda.obj v1 411 - R.fObjArray 412 runner-options: ['verifier-only', 'verifier-config'] 413 - values: 414 - | 415 # 416 movi v1, 10 417 newarr v1, v1, panda.Object[] 418 lda.obj v1 419 - R.fObjArray 420 runner-options: ['verifier-only', 'verifier-config'] 421 422 423 - file-name: "with_wrong_acc_type_j" 424 description: Check that verifier reports an error when the accumulator contains a value of type not corresponding to the bytecode 425 isa: 426 verification: 427 - acc_type 428 header-template: ['PandaAssembly_header'] 429 check-type: exit-positive 430 tags: [verifier, pa-verifier] 431 bugid: ['3293'] 432 runner-options: ['verifier-failure', 'verifier-config', 'use-pa'] 433 code-template: | 434 435 .function i32 main() { 436 %s 437 ststatic.obj %s 438 cases: 439 # store into object type field 440 - values: 441 - ldai 0 442 - R.fObj 443 bugid: ['1324', '1834'] 444 - values: 445 - ldai.64 1 446 - R.fObj 447 bugid: ['1324', '1834'] 448 - values: 449 - fldai.64 0x7FFFFFFFFFFFFFFF 450 - R.fObj 451 bugid: ['1324', '1834'] 452 - values: 453 - lda.type R # wrong type 454 - R.fQ 455 bugid: ['1834', '2256'] 456 - values: 457 - lda.str "abc" # wrong interface 458 - R.fI 459 bugid: ['1834'] 460 - values: 461 - initobj Q.ctor # supertype 462 - R.fR 463 bugid: ['1834'] 464 - values: 465 - initobj panda.Object.ctor # supertype 466 - R.fQ 467 bugid: ['1834'] 468 - values: 469 - | 470 movi v1, 10 471 newarr v1, v1, R[] 472 lda.obj v1 473 - R.fR 474 bugid: ['1834'] 475 # store into object array type field 476 - values: 477 - ldai 0 478 - R.fObjArray 479 bugid: ['1324', '1834'] 480 - values: 481 - ldai.64 1 482 - R.fObjArray 483 bugid: ['1324', '1834'] 484 - values: 485 - fldai.64 0x7FFFFFFFFFFFFFFF 486 - R.fObjArray 487 bugid: ['1324', '1834'] 488 - values: 489 - initobj R.ctor # single object to array of same type 490 - R.fRArray 491 bugid: ['1834'] 492 - values: 493 - lda.type R # wrong type 494 - R.fObjArray 495 bugid: ['1834'] 496 - values: 497 - | 498 movi v1, 10 499 newarr v1, v1, panda.Object[] # array of base types 500 lda.obj v1 501 - R.fIArray 502 bugid: ['1834'] 503 - values: 504 - | 505 movi v1, 10 506 newarr v1, v1, Q[] # array of supertypes 507 lda.obj v1 508 - R.fRArray 509 bugid: ['1834'] 510 # store into panda.Object field 511 - values: 512 - ldai 0 513 - R.fObj 514 - values: 515 - ldai.64 1 516 - R.fObj 517 - values: 518 - fldai.64 0x7FFFFFFFFFFFFFFF 519 - R.fObj 520 - values: 521 - lda.type R 522 - R.fObj 523 runner-options: ['verifier-only', 'verifier-config', 'use-pa'] 524 bugid: ['3594'] 525 ignore: true 526 - values: 527 - lda.str "" 528 - R.fObj 529 runner-options: ['verifier-only', 'verifier-config', 'use-pa'] 530 - values: 531 - lda.null 532 - R.fObj 533 runner-options: ['verifier-only', 'verifier-config', 'use-pa'] 534 - values: 535 - | 536 # 537 movi v1, 10 538 newarr v1, v1, Q[] 539 lda.obj v1 540 - R.fObj 541 runner-options: ['verifier-only', 'verifier-config', 'use-pa'] 542 - values: 543 - | 544 # 545 movi v1, 10 546 newarr v1, v1, panda.Object[] 547 lda.obj v1 548 - R.fObj 549 runner-options: ['verifier-only', 'verifier-config', 'use-pa'] 550 # store into panda.Object[] field 551 - values: 552 - ldai 0 553 - R.fObjArray 554 - values: 555 - ldai.64 1 556 - R.fObjArray 557 - values: 558 - fldai.64 0x7FFFFFFFFFFFFFFF 559 - R.fObjArray 560 - values: 561 - lda.type R 562 - R.fObjArray 563 - values: 564 - lda.str "" 565 - R.fObjArray 566 - values: 567 - lda.null 568 - R.fObjArray 569 runner-options: ['verifier-only', 'verifier-config', 'use-pa'] 570 - values: 571 - | 572 # 573 movi v1, 10 574 newarr v1, v1, Q[] 575 lda.obj v1 576 - R.fObjArray 577 runner-options: ['verifier-only', 'verifier-config', 'use-pa'] 578 - values: 579 - | 580 # 581 movi v1, 10 582 newarr v1, v1, panda.Object[] 583 lda.obj v1 584 - R.fObjArray 585 runner-options: ['verifier-only', 'verifier-config', 'use-pa'] 586 587 - file-name: "into_all_field_types_pa" 588 description: Check that accumulator value is stored in field 589 isa: 590 description: Store accumulator content into static field by field_id. 591 header-template: ['pandasm_header'] 592 check-type: exit-positive 593 tags: ['tsan'] 594 code-template: | 595 596 .function i32 main() { 597 %s 598 sta.obj v7 599 ststatic.obj R.%s 600 lda.null 601 ldstatic.obj R.%s 602 jeq.obj v7, success 603 ldai 1 604 return 605 success: 606 cases: 607 - values: 608 - | 609 # store null into Q type field 610 lda.null 611 - fQ 612 - fQ 613 - values: 614 - | 615 # store null into Q[] type field 616 lda.null 617 - fQArray 618 - fQArray 619 - values: 620 - | 621 # store Q into Q type field 622 initobj Q.ctor 623 - fQ 624 - fQ 625 - values: 626 - | 627 # store Q[] into Q[] type field 628 movi v1, 10 629 newarr v1, v1, Q[] 630 lda.obj v1 631 - fQArray 632 - fQArray 633 - values: 634 - | 635 # store Q into panda.Object type field 636 initobj Q.ctor 637 - fObj 638 - fObj 639 - values: 640 - | 641 # store Q[] into panda.Object type field 642 movi v1, 10 643 newarr v1, v1, Q[] 644 lda.obj v1 645 - fObj 646 - fObj 647 - values: 648 - | 649 # store Q[] into panda.Object[] type field 650 movi v1, 10 651 newarr v1, v1, Q[] 652 lda.obj v1 653 - fObjArray 654 - fObjArray 655 656 - file-name: "into_all_field_types_j" 657 description: Check that accumulator value is stored in field 658 isa: 659 description: Store accumulator content into static field by field_id. 660 header-template: ['PandaAssembly_header'] 661 runner-options: ['use-pa'] 662 check-type: exit-positive 663 tags: ['tsan'] 664 code-template: | 665 666 .function i32 main() { 667 %s 668 sta.obj v7 669 ststatic.obj R.%s 670 lda.null 671 ldstatic.obj R.%s 672 jeq.obj v7, success 673 ldai 1 674 return 675 success: 676 cases: 677 - values: 678 - | 679 # store subsclass R into Q type field 680 initobj R.ctor 681 - fQ 682 - fQ 683 - values: 684 - | 685 # store subsclass R into interface type field 686 initobj R.ctor 687 - fI 688 - fI 689 - values: 690 - | 691 # store subsclass R into base type field 692 initobj R.ctor 693 - fObj 694 - fObj 695 - values: 696 - | 697 # store subclass R[] into Q[] type field 698 movi v1, 10 699 newarr v1, v1, R[] 700 lda.obj v1 701 - fQArray 702 - fQArray 703 - values: 704 - | 705 # store subclass R[] into interface [] type field 706 movi v1, 10 707 newarr v1, v1, R[] 708 lda.obj v1 709 - fIArray 710 - fIArray 711 - values: 712 - | 713 # store subclass R[] into base type [] field 714 movi v1, 10 715 newarr v1, v1, R[] 716 lda.obj v1 717 - fObjArray 718 - fObjArray 719 - values: 720 - | 721 # store subclass R[] into base type field 722 movi v1, 10 723 newarr v1, v1, R[] 724 lda.obj v1 725 - fObj 726 - fObj 727 728 - file-name: "x_init_p" 729 description: Check that ExceptionInInitializerError is thrown if an unexpected exception occurs in static initializer. 730 isa: 731 exceptions: 732 - x_init 733 header-template: [] 734 check-type: empty 735 tags: ['tsan', 'irtoc_ignore'] 736 bugid: ['5330'] 737 code-template: | 738 739 .language PandaAssembly 740 741 .record panda.ExceptionInInitializerError <external> 742 .record panda.NullPointerException <external> 743 .record E1 {} 744 .record R { 745 E1 fObj <static> 746 } 747 748 .function void R.func() <cctor> { 749 %s 750 return.void 751 } 752 753 .function i32 main() { 754 begin: 755 newobj v0, E1 756 lda.obj v0 757 ststatic.obj R.fObj 758 ldai 2 759 return 760 end: 761 catch: 762 ldai 0 763 return 764 catch_all: 765 ldai 1 766 return 767 .catch panda.ExceptionInInitializerError, begin, end, catch 768 .catchall begin, end, catch_all 769 } 770 cases: 771 - values: 772 - | 773 # 774 newobj v0, E1 775 throw v0 776 - values: 777 - | 778 # 779 newobj v0, panda.NullPointerException 780 throw v0 781 - values: 782 - | 783 # 784 movi v1, 0 785 ldai 1 786 div2 v1 # divide by zero 787 - values: 788 - | 789 # 790 movi v1, 10 791 newarr v1, v1, i32[] 792 ldai 10 793 ldarr v1 # get ArrayIndexOutOfBoundsException 794 795 - file-name: "x_init_j" 796 description: Check that ExceptionInInitializerError is thrown if an unexpected exception occurs in static initializer. 797 isa: 798 exceptions: 799 - x_init 800 header-template: [] 801 check-type: empty 802 tags: ['tsan', 'irtoc_ignore'] 803 runner-options: ['use-pa'] 804 code-template: | 805 806 .language PandaAssembly 807 808 .record panda.ExceptionInInitializerError <external> 809 .record panda.NullPointerException <external> 810 .record E1 {} 811 .record R { 812 E1 fObj <static> 813 } 814 .record Q <panda.extends=R> { 815 E1 fObj <static> 816 } 817 .function void R.func() <cctor> { 818 %s 819 return.void 820 } 821 822 .function i32 main() { 823 begin: 824 newobj v0, E1 825 lda.obj v0 826 ststatic.obj Q.fObj 827 ldai 2 828 return 829 end: 830 catch: 831 ldai 0 832 return 833 catch_all: 834 ldai 1 835 return 836 .catch panda.ExceptionInInitializerError, begin, end, catch 837 .catchall begin, end, catch_all 838 } 839 cases: 840 - values: 841 - | 842 # 843 newobj v0, E1 844 throw v0 845 - values: 846 - | 847 # 848 newobj v0, panda.NullPointerException 849 throw v0 850 - values: 851 - | 852 # 853 movi v1, 0 854 ldai 1 855 div2 v1 # divide by zero 856 - values: 857 - | 858 # 859 movi v1, 10 860 newarr v1, v1, i32[] 861 ldai 10 862 ldarr v1 # get ArrayIndexOutOfBoundsException 863