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