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