• 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: 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
28        u8             fu8
29        i8             fi8
30        u16            fu16
31        i16            fi16
32        u32            fu32
33        i32            fi32
34        u64            fu64
35        i64            fi64
36        f32            ff32
37        f64            ff64
38
39        i32[]          fi32Array
40        Q              fQ
41        Q[]            fQArray
42        panda.Object   fObj
43        panda.Object[] fObjArray
44      }
45      .function void R.ctor(R a0) <ctor> {
46        return.void
47      }
48
49tests:
50  - file-name: "stobj.64"
51    isa:
52      title: Store accumulator content into object field
53      description: >
54        Store accumulator content into object field by field_id. For non-object variant the size of actually stored
55        value is determined by field_id, other accumulator bits are discarded.
56      instructions:
57        - sig: stobj.64 v:in:ref, field_id
58          acc: in:b64
59          format: [op_v_8_id_16]
60    commands:
61
62      - file-name: "check_if_regs_initialized"
63        description: Check that verifier reports error if source registers are not initialized
64        isa:
65          description: Store accumulator content into object field by field_id.
66        header-template: ['pandasm_header']
67        check-type: exit-positive
68        tags: ['verifier']
69        bugid: ['1324']
70        runner-options: ['verifier-failure', 'verifier-debug-config']
71        code-template: |
72
73          %s
74
75          .function i32 main() {
76            initobj R.ctor
77            sta.obj v0
78            fmovi.64 v1, 1.1
79            call.short check, %s
80        cases:
81          - values:
82            - |
83              # acc (value) not initialized in the frame
84              .function void check(R a0) {
85                stobj.64 a0, R.ff64
86                return.void
87              }
88            - v0
89          - values:
90            - |
91              # v0 (object) not initialized in the frame
92              .function void check(f64 a0) {
93                lda.64 a0
94                stobj.64 v0, R.ff64
95                return.void
96              }
97            - v1
98            bugid: ['1324']
99
100      - file-name: "with_null_ref"
101        description: Check that NullPointerException is thrown if object ref is null
102        isa:
103          exceptions:
104            - x_null
105        header-template: ['pandasm_header']
106        check-type: empty
107        tags: ['tsan', 'arm64-jit']
108        bugid: ['3047']
109        code-template: |
110          .record panda.NullPointerException <external>
111
112          .function R get_null() {
113            lda.null
114            return.obj
115          }
116
117          .function i32 main() {
118            call.short get_null
119            sta.obj v0
120            %s
121          try_begin:
122            stobj.64 v0, %s
123            ldai 1
124            return
125          try_end:
126            ldai 0
127            return
128          .catch panda.NullPointerException, try_begin, try_end, try_end
129          }
130        cases:
131          - values:
132            - ldai.64 1
133            - R.fi64
134          - values:
135            - ldai.64 1
136            - R.fu64
137          - values:
138            - fldai.64 1.1
139            - R.ff64
140            bugid: ['1882']
141
142      - file-name: "with_non_object_ref"
143        description: Check that verifier reports error when the 1st operand is not a ref to an object (other than array)
144        isa:
145          verification:
146            - v1_object
147        header-template: ['pandasm_header']
148        check-type: empty
149        tags: ['verifier']
150        runner-options: ['verifier-failure', 'verifier-debug-config']
151        code-template: |
152          .function i32 main() {
153            %s
154            ldai.64 1
155          try_begin:
156            stobj.64 v0, R.fi64
157          try_end:
158            ldai 0
159            return
160          .catchall try_begin, try_end, try_end
161          }
162        cases:
163          - values:
164            - movi v0, 0
165            bugid: ['1324', '1826']
166          - values:
167            - movi v0, 1
168          - values:
169            - movi.64 v0, 0x00
170            bugid: ['1324', '1826']
171          - values:
172            - movi.64 v0, 0xCAFECAFECAFECAFE
173          - values:
174            - fmovi.64 v0, 0.0
175            bugid: ['1324', '1826']
176          - values:
177            - fmovi.64 v0, 6.62607015
178          - values:
179            - |
180                movi v1, 10
181                  newarr v0, v1, R[]
182            bugid: ['1827']
183
184
185      - file-name: "with_static_field_id"
186        description: Check that verifier reports error when the field doesn't resolve to a non-static valid object field
187        isa:
188          verification:
189            - field_id_non_static
190        header-template: []
191        check-type: exit-positive
192        code-template: |
193          .record W {
194            i64   static_field  <static>
195          }
196          .function void W.ctor(W a0) <ctor> {
197            return.void
198          }
199          .record random_record_name {
200            i64 random_field_name
201          }
202          .function void random_function_name() {
203            return.void
204          }
205
206          .function i32 main() {
207            initobj W.ctor
208            sta.obj v0
209            ldai.64 1
210            stobj.64 v0, %s
211        cases:
212          - values:
213            - W.static_field
214            runner-options: ['verifier-failure', 'verifier-debug-config']
215            tags: ['verifier']
216            bugid: ['1324', '1828']
217          - values:
218            - random_record_name
219            runner-options: ['compile-failure']
220          - values:
221            - random_function_name
222            runner-options: ['compile-failure']
223          - values:
224            - W.field_not_exists
225            runner-options: ['compile-failure']
226          - values:
227            - random_record_name.random_field_name
228            tags: ['verifier']
229            runner-options: ['verifier-failure', 'verifier-debug-config']
230            bugid: ['3536']
231            ignore: true
232          - values:
233            - 0
234            runner-options: ['compile-failure']
235          - values:
236            - -1.1
237            runner-options: ['compile-failure']
238          - values:
239            - "null"
240            runner-options: ['compile-failure']
241          - values:
242            - "\"abc\""
243            runner-options: ['compile-failure']
244
245      - file-name: "with_wrong_field_size"
246        description: Check that verifier reports error when the field resolves to a field with size that is not corresponding to bytecode
247        isa:
248          verification:
249            - field_id_size
250        header-template: ['pandasm_header']
251        check-type: exit-positive
252        tags: ['verifier']
253        runner-options: ['verifier-failure', 'verifier-debug-config']
254        bugid: ['1834']
255        code-template: |
256
257          .function i32 main() {
258            initobj R.ctor
259            sta.obj v0
260            ldai.64 0
261            stobj.64 v0, %s
262        cases:
263          - values:
264            - R.fu1
265          - values:
266            - R.fu8
267          - values:
268            - R.fi8
269          - values:
270            - R.fu16
271          - values:
272            - R.fi16
273          - values:
274            - R.fu32
275          - values:
276            - R.fi32
277          - values:
278            - R.fObj
279          - values:
280            - R.fObjArray
281          - values:
282            - R.fi32Array
283
284      - file-name: "with_wrong_acc_type"
285        description: Check that verifier reports error when the accumulator contains a value of type not corresponding to the bytecode
286        isa:
287          verification:
288            - acc_type
289        header-template: ['pandasm_header']
290        check-type: exit-positive
291        tags: ['verifier']
292        runner-options: ['verifier-failure', 'verifier-debug-config']
293        bugid: ['1834']
294        code-template: |
295          .function i32 main() {
296            initobj R.ctor
297            sta.obj v0
298            %s
299            stobj.64 v0, %s
300        cases:
301          # u64
302          - values:
303            - ldai 0
304            - R.fu64
305          - values:
306            - ldai 0xCAFECAFE
307            - R.fu64
308          - values:
309            - fldai.64 1.1
310            - R.fu64
311          - values:
312            - lda.null
313            - R.fu64
314          - values:
315            - initobj Q.ctor
316            - R.fu64
317          - values:
318            - |
319              movi v1, 10
320                newarr v1, v1, i32[]
321                lda.obj v1
322            - R.fu64
323          # i64
324          - values:
325            - ldai 0
326            - R.fi64
327          - values:
328            - ldai 0xCAFECAFE
329            - R.fi64
330          - values:
331            - fldai.64 1.1
332            - R.fi64
333          - values:
334            - lda.null
335            - R.fi64
336          - values:
337            - initobj Q.ctor
338            - R.fi64
339          - values:
340            - |
341              movi v1, 10
342                newarr v1, v1, i32[]
343                lda.obj v1
344            - R.fi64
345          # f64
346          - values:
347            - ldai 0
348            - R.ff64
349          - values:
350            - ldai 0xCAFECAFE
351            - R.ff64
352          - values:
353            - ldai.64 1
354            - R.ff64
355          - values:
356            - lda.null
357            - R.ff64
358          - values:
359            - initobj Q.ctor
360            - R.ff64
361          - values:
362            - |
363              movi v1, 10
364                newarr v1, v1, i32[]
365                lda.obj v1
366            - R.ff64
367          # f32
368          - values:
369            - ldai 0
370            - R.ff32
371          - values:
372            - ldai 0xCAFECAFE
373            - R.ff32
374          - values:
375            - ldai.64 1
376            - R.ff32
377          - values:
378            - lda.null
379            - R.ff32
380          - values:
381            - initobj Q.ctor
382            - R.ff32
383          - values:
384            - |
385              movi v1, 10
386                newarr v1, v1, i32[]
387                lda.obj v1
388            - R.ff32
389
390
391      - file-name: "op_v_8_id_16"
392        description: Check that compiler reports error when the register number is out of 8 bit size
393        isa:
394          instructions:
395            - sig: stobj.64 v:in:ref, field_id
396              acc: in:b64
397              format: [op_v_8_id_16]
398        header-template: ['pandasm_header']
399        check-type: exit-positive
400        code-template: |
401          .function i32 main() {
402            stobj.64 %s, R.fi64
403        cases:
404          - values: ['v255']
405            runner-options: ['compile-only']
406          - values: ['v256']
407            runner-options: ['compile-failure']
408          - values: ['v65535']
409            runner-options: ['compile-failure']
410
411      - file-name: "into_all_field_types"
412        description: Check that accumulator value is stored in field
413        isa:
414          description: If field type is f32, accumulator content will be implicitly converted from f64 to f32 before storing.
415        header-template: ['pandasm_header']
416        check-type: exit-positive
417        tags: ['tsan']
418        code-template: |
419          .function i32 main() {
420            initobj R.ctor
421            sta.obj v0
422            %s
423            stobj.64 v0, R.%s
424            lda.null
425            ldobj.64 v0, R.%s
426            %s
427            jeqz success
428            ldai 1
429            return
430          success:
431        cases:
432          # u64
433          - values:
434            - ldai.64 0x0000000000000000
435            - fu64
436            - fu64
437            - |
438                movi.64 v1, 0x0000000000000000
439                  ucmp.64 v1
440          - values:
441            - ldai.64 0xffffffffffffffff
442            - fu64
443            - fu64
444            - |
445                movi.64 v1, 0xffffffffffffffff
446                  ucmp.64 v1
447          - values:
448            - ldai.64 0xa5a5a5a5a5a5a5a5
449            - fu64
450            - fu64
451            - |
452                movi.64 v1, 0xa5a5a5a5a5a5a5a5
453                  ucmp.64 v1
454          # i64
455          - values:
456            - ldai.64 0
457            - fi64
458            - fi64
459            - |
460                movi.64 v1, 0
461                  cmp.64 v1
462          - values:
463            - ldai.64 -1
464            - fi64
465            - fi64
466            - |
467                movi.64 v1, -1
468                  cmp.64 v1
469          - values:
470            - ldai.64 -6510615555426900571
471            - fi64
472            - fi64
473            - |
474                movi.64 v1, -6510615555426900571
475                  cmp.64 v1
476          # f64
477          - values:
478            - fldai.64 0.0
479            - ff64
480            - ff64
481            - |
482                fmovi.64 v1, 0.0
483                  fcmpg.64 v1
484          - values:
485            - fldai.64 -6510615555426900571.0
486            - ff64
487            - ff64
488            - |
489                fmovi.64 v1, -6510615555426900571.0
490                  fcmpg.64 v1
491          - values:
492            - fldai.64 0x7FFFFFFFFFFFFFFF  # NaN
493            - ff64
494            - ff64
495            - |
496                fmovi.64 v1, 0.0
497                  fcmpg.64 v1
498                  subi 1
499          - values:
500            - fldai.64 0x7ff0000000000000  # + Inf
501            - ff64
502            - ff64
503            - |
504                fmovi.64 v1, 0x7ff0000000000000
505                  fcmpg.64 v1
506          - values:
507            - fldai.64 0xfff0000000000000  # - Inf
508            - ff64
509            - ff64
510            - |
511                fmovi.64 v1, 0xfff0000000000000
512                  fcmpg.64 v1
513