1# Copyright (c) 2021 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: java 16 template: | 17 .language Java 18 - name: aoobe_p 19 template: | 20 .record panda.ArrayIndexOutOfBoundsException<external> 21 - name: aoobe_j 22 template: | 23 .record java.lang.ArrayIndexOutOfBoundsException<external> 24 - name: npe_p 25 template: | 26 .record panda.NullPointerException <external> 27 - name: npe_j 28 template: | 29 .record java.lang.NullPointerException <external> 30 31tests: 32 - file-name: "starr.8" 33 isa: 34 title: Store to array 35 description: > 36 Store accumulator content into array slot pointed by index. 37 If size of element to store is less than 32, accumulator content will be truncated 38 to storage size before storing. 39 instructions: 40 - sig: starr.8 v1:in:i8[], v2:in:i32 41 acc: in:i8 42 format: [op_v1_4_v2_4] 43 commands: 44 45 46 - file-name: "reg_valid" 47 isa: 48 instructions: 49 - sig: starr.8 v1:in:i8[], v2:in:i32 50 acc: in:i8 51 format: [op_v1_4_v2_4] 52 check-type: empty 53 runner-options: [compile-only] 54 description: Check 'starr.8' instruction with valid register numbers. 55 header-template: [] 56 code-template: | 57 # 58 .function i32 main() { 59 starr.8 %s, %s 60 ldai 0 61 return 62 } 63 cases: 64 - values: [v0, v15] 65 - values: [v15, v0] 66 - values: [v15, v15] 67 - case-template: | 68 # 69 .function i32 f1(i8[] a0, i32 a1) { 70 starr.8 a0, a1 # valid registers 71 ldai 0 72 return 73 } 74 75 .function i32 main() { 76 call.short f1, v1, v2 77 return 78 } 79 80 81 - file-name: "reg_v_invalid" 82 isa: 83 instructions: 84 - sig: starr.8 v1:in:i8[], v2:in:i32 85 acc: in:i8 86 format: [op_v1_4_v2_4] 87 runner-options: [compile-failure] 88 description: Check 'starr.8' instruction with invalid register numbers. 89 code-template: | 90 # 91 starr.8 %s, *s 92 check-type: exit-positive 93 template-cases: 94 - values: [v0] 95 exclude: [v0, v15] 96 - values: [v15] 97 exclude: [v0, v15] 98 - values: [v255] 99 - values: [v256] 100 - values: [v65536] 101 - values: [a0] 102 - values: ['V1'] 103 - values: [null] 104 - values: [0] 105 cases: 106 - values: [v0] 107 id: v0 108 - values: [v15] 109 id: v15 110 - values: [v255] 111 - values: [v256] 112 - values: [v65536] 113 - values: [a0] 114 - values: ['V1'] 115 - values: [null] 116 - values: [0] 117 118 119 - file-name: "reg_a_invalid" 120 isa: 121 instructions: 122 - sig: starr.8 v1:in:i8[], v2:in:i32 123 acc: in:i8 124 format: [op_v1_4_v2_4] 125 runner-options: [compile-failure] 126 description: Check 'starr.8' instruction with invalid register numbers. 127 header-template: [] 128 code-template: | 129 # 130 .function void f1(i8[] a0, i32 a1) { 131 starr.8 %s 132 return.void 133 } 134 135 .function i32 main() { 136 call.short f1, v1, v2 137 check-type: exit-positive 138 cases: 139 - values: 140 - 'a0, a2' 141 - values: 142 - 'a2, a1' 143 144 145 - file-name: null_pointer_p 146 isa: 147 exceptions: 148 - x_null 149 description: Check 'starr.8' behavior when array is null reference. 150 header-template: [npe_p] 151 code-template: | 152 .function i8[] get_null() { 153 lda.null 154 return.obj 155 } 156 .function i32 main() { 157 call.short get_null 158 sta.obj v0 159 movi v1, %s 160 ldai 0 161 begin: 162 starr.8 v0, v1 163 end: 164 ldai 1 # Should not reach this line 165 return 166 167 catch_NPE: 168 ldai 0 # Expected panda.NullPointerException 169 return 170 171 catch_all: 172 ldai 2 # Unexpected exception, test failed 173 return 174 175 .catch panda.NullPointerException, begin, end, catch_NPE 176 .catchall begin, end, catch_all 177 check-type: none 178 cases: 179 - values: [0] 180 tags: ['tsan'] 181 - values: [1] 182 - values: [10] 183 - values: [128] 184 - values: [255] 185 - values: [65535] 186 tags: ['tsan'] 187 - values: [0x7FFFFFFF] 188 - values: [0xFFFFFFFF] 189 - values: [0x80000000] 190 191 192 - file-name: array_out_of_bounds_exception_p 193 isa: 194 exceptions: 195 - x_bounds 196 description: Check 'starr.8' behavior when index is out of array bounds. 197 header-template: [aoobe_p, main] 198 code-template: | 199 # 200 movi v0, *s 201 newarr v0, v0, %s 202 movi v1, *s 203 ldai 0 204 begin: 205 starr.8 v0, v1 206 end: 207 ldai 1 # Should not reach this line 208 return 209 210 catch_AOOBE: 211 ldai 0 # Expected panda.ArrayIndexOutOfBoundsException 212 return 213 214 catch_all: 215 ldai 2 # Unexpected exception, test failed 216 return 217 218 .catch panda.ArrayIndexOutOfBoundsException, begin, end, catch_AOOBE 219 .catchall begin, end, catch_all 220 check-type: none 221 template-cases: 222 - values: ['u1[]'] 223 - values: ['i8[]'] 224 cases: 225 - values: [0, 0] 226 tags: ['tsan'] 227 - values: [0, 1] 228 - values: [10, -10] 229 - values: [10, 128] 230 - values: [255, 255] 231 - values: [254, 255] 232 - values: [65535, 65535] 233 tags: ['tsan'] 234 - values: [65535, 65536] 235 - values: [10, 0xFFFFFFFF] 236 - values: [256, 0xFFFFFFFE] 237 - values: [65536, 0xFFFFFFFD] 238 tags: ['tsan'] 239 - values: [0x100000, 0xFFFFFFFC] 240 - values: [10, 0x80000000] 241 - values: [256, 0x80000001] 242 - values: [65536, 0x80000002] 243 tags: ['tsan'] 244 - values: [0x100000, 0x80000003] 245 246 247 - file-name: uninitialized_regs 248 isa: 249 verification: 250 - v1_array_type 251 - v2_i32 252 - acc_type 253 description: Check 'starr.8' with uninitialized registers 254 tags: ['verifier'] 255 runner-options: ['verifier-failure', 'verifier-debug-config'] 256 header-template: [] 257 code-template: | 258 # 259 .function i32 main() { 260 %s 261 starr.8 v1, v2 262 check-type: exit-positive 263 cases: 264 - values: 265 - | 266 # acc is not initialized 267 movi v0, 10 268 newarr v1, v0, i8[] 269 movi v2, 0 270 - values: 271 - | 272 # v1 is not initialized 273 movi v2, 0 274 ldai 0 275 - values: 276 - | 277 # v2 is not initialized 278 movi v0, 10 279 newarr v1, v0, i8[] 280 ldai 0 281 - values: 282 - | 283 # no regs are initialized 284 285 286 - file-name: "acceptable_primitive_types_p" 287 isa: 288 verification: 289 - v1_array_type 290 description: Check acceptable array of primitive types for starr.8 instruction in Panda Assembly context. 291 runner-options: ['verifier-only', 'verifier-debug-config'] 292 tags: ['verifier'] 293 header-template: [main] 294 code-template: | 295 # 296 movi v0, 1 297 newarr v1, v0, %s 298 movi v2, 0 299 ldai 0 300 starr.8 v1, v2 301 check-type: exit-positive 302 cases: 303 - values: ['u1[]'] 304 - values: ['i8[]'] 305 - values: ['u8[]'] 306 307 308 - file-name: "rejectable_primitive_types_p" 309 isa: 310 verification: 311 - v1_array_type 312 description: Check rejectable array of primitive types for starr.8 instruction in Panda Assembly context. 313 runner-options: ['verifier-failure', 'verifier-debug-config'] 314 tags: ['verifier'] 315 header-template: [main] 316 code-template: | 317 # 318 movi v0, 1 319 newarr v1, v0, %s 320 movi v2, 0 321 ldai 0 322 starr.8 v1, v2 323 check-type: exit-positive 324 cases: 325 - values: ['i16[]'] 326 - values: ['u16[]'] 327 - values: ['i32[]'] 328 - values: ['u32[]'] 329 - values: ['i64[]'] 330 - values: ['u64[]'] 331 - values: ['f32[]'] 332 - values: ['f64[]'] 333 334 335 - file-name: "arr_type_p" 336 isa: 337 verification: 338 - v1_array_type 339 description: Check 'starr.8' with incorrect array type in Panda Assembly context. See also "rejectable_primitive_types" tests. 340 runner-options: ['verifier-failure', 'verifier-debug-config'] 341 tags: ['verifier'] 342 header-template: [] 343 code-template: | 344 # 345 .record A {} 346 .function void A.ctor(A a0) <ctor> { 347 return.void 348 } 349 .record panda.String <external> 350 .record panda.Object <external> 351 .function i32 main() { 352 %s 353 movi v1, 0 354 ldai 0 355 starr.8 v0, v1 356 check-type: exit-positive 357 cases: 358 - values: 359 - movi v0, 0 360 - values: 361 - movi.64 v0, 0 362 - values: 363 - fmovi.64 v0, 0 364 - values: 365 - | 366 # 367 initobj A.ctor 368 sta.obj v0 369 - values: 370 - | 371 # 372 movi v0, 1 373 newarr v0, v0, A[] 374 - values: 375 - | 376 # 377 lda.type A 378 sta.obj v0 379 - values: 380 - | 381 # 382 lda.type A[] 383 sta.obj v0 384 - values: 385 - | 386 # 387 lda.type panda.String 388 sta.obj v0 389 - values: 390 - | 391 # 392 lda.type panda.String[] 393 sta.obj v0 394 - values: 395 - | 396 # 397 lda.type panda.Object 398 sta.obj v0 399 - values: 400 - | 401 # 402 lda.type panda.Object[] 403 sta.obj v0 404 - values: 405 - | 406 # 407 lda.str "string" 408 sta.obj v0 409 - values: 410 - | 411 # 412 movi v0, 1 413 newarr v0, v0, panda.Object[] 414 - values: 415 - | 416 # 417 movi v0, 1 418 newarr v0, v0, panda.String[] 419 420 421 - file-name: "index_type_p" 422 isa: 423 verification: 424 - v2_i32 425 description: Check 'starr.8' with incorrect array index type in Panda Assembly context. 426 runner-options: ['verifier-failure', 'verifier-debug-config'] 427 tags: ['verifier'] 428 header-template: [] 429 code-template: | 430 # 431 .record A {} 432 .function void A.ctor(A a0) <ctor> { 433 return.void 434 } 435 .record panda.String <external> 436 .record panda.Object <external> 437 .function i32 main() { 438 movi v0, 1 439 newarr v1, v0, *s 440 %s 441 ldai 0 442 starr.8 v1, v2 443 check-type: exit-positive 444 cases: 445 - values: ['u1[]'] 446 - values: ['u8[]'] 447 - values: ['i8[]'] 448 template-cases: 449 - values: 450 - mov.null v2 451 - values: 452 - movi.64 v2, 0 453 - values: 454 - fmovi.64 v2, 0 455 - values: 456 - | 457 # 458 initobj A.ctor 459 sta.obj v1 460 - values: 461 - | 462 # 463 movi v0, 1 464 newarr v2, v0, A[] 465 - values: 466 - | 467 # 468 lda.type A 469 sta.obj v2 470 - values: 471 - | 472 # 473 lda.type A[] 474 sta.obj v2 475 - values: 476 - | 477 # 478 lda.type panda.String 479 sta.obj v2 480 - values: 481 - | 482 # 483 lda.type panda.String[] 484 sta.obj v2 485 - values: 486 - | 487 # 488 lda.type panda.Object 489 sta.obj v2 490 - values: 491 - | 492 # 493 lda.type panda.Object[] 494 sta.obj v2 495 - values: 496 - | 497 # 498 lda.str "string" 499 sta.obj v2 500 - values: 501 - | 502 # 503 movi v0, 1 504 newarr v2, v0, panda.Object[] 505 - values: 506 - | 507 # 508 movi v0, 1 509 newarr v2, v0, panda.String[] 510 511 512 - file-name: "acc_type_p" 513 isa: 514 verification: 515 - acc_type 516 description: Check 'starr.8' with incorrect accumulator type in Panda Assembly context. 517 runner-options: ['verifier-failure', 'verifier-debug-config'] 518 tags: ['verifier'] 519 header-template: [] 520 code-template: | 521 # 522 .record A {} 523 .function void A.ctor(A a0) <ctor> { 524 return.void 525 } 526 .record panda.String <external> 527 .record panda.Object <external> 528 .function i32 main() { 529 movi v0, 1 530 newarr v1, v0, *s 531 movi v2, 0 532 %s 533 starr.8 v1, v2 534 check-type: exit-positive 535 cases: 536 - values: ['u1[]'] 537 - values: ['u8[]'] 538 - values: ['i8[]'] 539 template-cases: 540 - values: 541 - lda.null 542 - values: 543 - ldai.64 0 544 - values: 545 - fldai.64 0 546 - values: 547 - | 548 # 549 initobj A.ctor 550 - values: 551 - | 552 # 553 lda.type A 554 - values: 555 - | 556 # 557 lda.type panda.String 558 - values: 559 - | 560 # 561 lda.type panda.String[] 562 - values: 563 - | 564 # 565 lda.type panda.Object 566 - values: 567 - | 568 # 569 lda.type panda.Object[] 570 - values: 571 - | 572 # 573 lda.str "string" 574 - values: 575 - | 576 # 577 movi v0, 1 578 newarr v0, v0, panda.Object[] 579 lda.obj v0 580 - values: 581 - | 582 # 583 movi v0, 1 584 newarr v0, v0, panda.String[] 585 lda.obj v0 586 587 588 - file-name: "mult_regs_types_p" 589 isa: 590 verification: 591 - v1_array_type 592 - v2_i32 593 - acc_type 594 description: Check 'starr.8' with multiple incorrect register types in Panda Assembly context. 595 runner-options: ['verifier-failure', 'verifier-debug-config'] 596 tags: ['verifier'] 597 header-template: [] 598 code-template: | 599 # 600 .record A {} 601 .function void A.ctor(A a0) <ctor> { 602 return.void 603 } 604 .record panda.String <external> 605 .record panda.Object <external> 606 .function void panda.Object.ctor(panda.Object a0) <external,ctor> 607 .function i32 main() { 608 %s 609 starr.8 v1, v2 610 check-type: exit-positive 611 cases: 612 - values: 613 - | 614 # all registers invalid 615 initobj panda.Object.ctor 616 sta.obj v1 617 movi.64 v2, 0 618 lda.str "test string" 619 - values: 620 - | 621 # v1 and v2 invalid 622 lda.str "test string" 623 sta.obj v1 624 fmovi.64 v2, 1 625 ldai 0 626 - values: 627 - | 628 # v1 and acc invalid 629 lda.type panda.Object 630 sta.obj v1 631 movi v2, 0 632 lda.str "test string" 633 - values: 634 - | 635 # v2 and acc invalid 636 movi v0, 1 637 newarr v1, v0, i8[] 638 sta.obj v2 639 initobj A.ctor 640 641 642 - file-name: "store_arr_p" 643 isa: 644 instructions: 645 - sig: starr.8 v1:in:i8[], v2:in:i32 646 acc: in:i8 647 format: [op_v1_4_v2_4] 648 description: Check starr.8 stores items to array of different size and type in Panda Assembly context. 649 code-template: | 650 # 651 movi v0, *s 652 newarr v1, v0, %s 653 movi v2, *s 654 ldai 1234567 # will be truncated 655 starr.8 v1, v2 656 check-type: exit-positive 657 template-cases: 658 - values: ['u1[]'] 659 - values: ['i8[]'] 660 - values: ['u8[]'] 661 cases: 662 - values: ['1', '0'] 663 - values: ['255', '254'] 664 tags: ['tsan'] 665 - values: ['65536', '65535'] 666 667 668 - file-name: "store_all_elements" 669 isa: 670 description: > 671 Store accumulator content into array slot pointed by index. 672 description: Check starr.8 stores correct items into array of primitives. 673 header-template: [] 674 code-template: | 675 .function i32 main() { 676 movi v7, *s # v7 is array size 677 newarr v1, v7, %s # v1 - testable array 678 679 movi v2, 0 # array index 680 fill_array: 681 lda v2 682 starr.8 v1, v2 # v1[v2] = acc 683 inci v2, 1 # v2 = v2 + 1 684 lda v2 685 jne v7, fill_array 686 inci v2, -1 687 check_array: 688 lda v2 689 %s 690 sta v3 # value to compare with 691 lda v2 692 %s 693 jeqz ok 694 ldai 2 695 return 696 ok: 697 inci v2, -1 698 lda v2 699 jgez check_array 700 check-type: exit-positive 701 template-cases: 702 - values: 703 - u1[] 704 - | 705 # 706 andi 0x00000001 707 - | 708 # 709 ldarru.8 v1 710 jne v3, exit_failure 711 ldai 0 712 return 713 exit_failure: ldai 1 714 return 715 bugid: ['4019'] 716 ignore: true 717 - values: 718 - i8[] 719 - | 720 # 721 shli 24 722 ashri 24 723 - | 724 # 725 ldarr.8 v1 726 jne v3, exit_failure 727 ldai 0 728 return 729 exit_failure: ldai 1 730 return 731 tags: ['tsan'] 732 - values: 733 - u8[] 734 - | 735 # 736 shli 24 737 shri 24 738 - | 739 # 740 ldarru.8 v1 741 ucmp v3 742 cases: 743 - values: [10000] 744 745