• 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 R {
22        u1             fu1       <static>
23        u8             fu8       <static>
24        i8             fi8       <static>
25        u16            fu16      <static>
26        i16            fi16      <static>
27        u32            fu32      <static>
28        i32            fi32      <static>
29        u64            fu64      <static>
30        i64            fi64      <static>
31        f32            ff32      <static>
32        f64            ff64      <static>
33        # objects:
34        i32[]          fi32Array <static>
35        panda.Object   fObj      <static>
36        panda.Object[] fObjArray <static>
37      }
38
39  - name: java_header
40    template: |
41      .language Java
42
43      .record java.lang.Object <external>
44
45      .record R {
46        u1             fu1       <static>
47        i8             fi8       <static>
48        u16            fu16      <static>
49        i16            fi16      <static>
50        i32            fi32      <static>
51        i64            fi64      <static>
52        f32            ff32      <static>
53        f64            ff64      <static>
54        # objects:
55        i32[]          fi32Array <static>
56        java.lang.Object   fObj      <static>
57        java.lang.Object[] fObjArray <static>
58      }
59
60tests:
61  - file-name: "ldstatic.64"
62    isa:
63      title: Get static field
64      description: >
65        Get static field value by field_id and put it into accumulator.
66      instructions:
67        - sig: ldstatic.64 field_id
68          acc: out:b64
69          format: [op_id_16]
70    commands:
71
72      - file-name: "with_non_static_field_id"
73        description: Check that verifier reports an error when the field doesn't resolve to a static valid field
74        isa:
75          verification:
76            - field_id_static
77        header-template: []
78        check-type: exit-positive
79        code-template: |
80          .record W {
81            u1    fu1
82            i8    fi8
83            u16   fu16
84            i16   fi16
85            i32   fi32
86            i64   fi64
87            f32   ff32
88            f64   ff64
89            W     fW
90            i32[] fi32Array
91            W[]   fWArray
92          }
93          .function void W.object_function(W a0) {
94            return.void
95          }
96          .function void static_function() {
97            return.void
98          }
99
100          .function i32 main() {
101              ldstatic.64 %s
102        cases:
103          - values:
104            - W.fu1
105            tags: [verifier]
106            runner-options: ['verifier-failure', 'verifier-debug-config']
107            bugid: ['1324', '1828']
108          - values:
109            - W.fi8
110            tags: [verifier]
111            runner-options: ['verifier-failure', 'verifier-debug-config']
112            bugid: ['1324', '1828']
113          - values:
114            - W.fu16
115            tags: [verifier]
116            runner-options: ['verifier-failure', 'verifier-debug-config']
117            bugid: ['1324', '1828']
118          - values:
119            - W.fi16
120            tags: [verifier]
121            runner-options: ['verifier-failure', 'verifier-debug-config']
122            bugid: ['1324', '1828']
123          - values:
124            - W.fi32
125            tags: [verifier]
126            runner-options: ['verifier-failure', 'verifier-debug-config']
127            bugid: ['1324', '1828']
128          - values:
129            - W.fi64
130            tags: [verifier]
131            runner-options: ['verifier-failure', 'verifier-debug-config']
132            bugid: ['1324', '1828']
133          - values:
134            - W.ff32
135            tags: [verifier]
136            runner-options: ['verifier-failure', 'verifier-debug-config']
137            bugid: ['1324', '1828']
138          - values:
139            - W.ff64
140            tags: [verifier]
141            runner-options: ['verifier-failure', 'verifier-debug-config']
142            bugid: ['1324', '1828']
143          - values:
144            - W.fW
145            tags: [verifier]
146            runner-options: ['verifier-failure', 'verifier-debug-config']
147            bugid: ['1324', '1828']
148          - values:
149            - W.fi32Array
150            tags: [verifier]
151            runner-options: ['verifier-failure', 'verifier-debug-config']
152            bugid: ['1324', '1828']
153          - values:
154            - W.fWArray
155            tags: [verifier]
156            runner-options: ['verifier-failure', 'verifier-debug-config']
157            bugid: ['1324', '1828']
158          - values:
159            - W
160            runner-options: [compile-failure]
161          - values:
162            - W.object_function
163            runner-options: [compile-failure]
164          - values:
165            - static_function
166            runner-options: [compile-failure]
167          - values:
168            - unknown_function
169            runner-options: [compile-failure]
170          - values:
171            - 0
172            runner-options: [compile-failure]
173          - values:
174            - -1.1
175            runner-options: [compile-failure]
176          - values:
177            - "null"
178            runner-options: [compile-failure]
179          - values:
180            - "\"abc\""
181            runner-options: [compile-failure]
182
183
184      - file-name: "with_wrong_field_size_p"
185        description: Check that verifier reports an error when the field resolves to a field with size that is not corresponding to bytecode in PandaAssembly context.
186        isa:
187          verification:
188            - field_id_size
189        header-template: [pandasm_header]
190        check-type: exit-positive
191        tags: [verifier]
192        runner-options: ['verifier-failure', 'verifier-debug-config']
193        bugid: ['1834', '2088']
194        code-template: |
195
196          .function i32 main() {
197            ldstatic.64 %s
198        cases:
199          - values:
200            - R.fu1
201          - values:
202            - R.fu8
203          - values:
204            - R.fi8
205          - values:
206            - R.fu16
207          - values:
208            - R.fi16
209          - values:
210            - R.fu32
211          - values:
212            - R.fi32
213          - values:
214            - R.fObj
215          - values:
216            - R.fObjArray
217          - values:
218            - R.fi32Array
219
220
221      - file-name: "from_all_int_field_types_p"
222        description: Check that accumulator value is loaded from field into accumulator in PandaAssembly context. More tests on ldstatic.64 can be found in ststatic.64 tests.
223        isa:
224          description: Get static field value by field_id and put it into accumulator.
225        header-template: [pandasm_header]
226        check-type: exit-positive
227        tags: ['tsan']
228        code-template: |
229
230          .function i32 main() {
231            ldai.64 %s
232            ststatic.64 R.f%s
233            movi.64 v15, %s
234            ldstatic.64 R.f%s
235            %s v15
236            jeqz success
237            ldai 1
238            return
239          success:
240        cases:
241          # u64
242          - values: [0, 'u64', 0, 'u64', 'ucmp.64']
243          - values: [0xffffffffffffffff, 'u64', 0xffffffffffffffff, 'u64', 'ucmp.64']
244          - values: [0xa5a5a5a5a5a5a5a5, 'u64', 0xa5a5a5a5a5a5a5a5, 'u64', 'ucmp.64']
245          # i64
246          - values: [0, 'i64', 0, 'i64', 'cmp.64']
247          - values: [-1, 'i64', -1, 'i64', 'cmp.64']
248          - values: [-6510615555426900571, 'i64', -6510615555426900571, 'i64', 'cmp.64']
249
250
251      - file-name: "from_all_float_field_types_p"
252        description: Check that accumulator value is loaded from field into accumulator in PandaAssembly context. More tests on ldstatic.64 can be found in ststatic.64 tests.
253        isa:
254          instructions:
255            - sig: ldstatic.64 field_id
256              acc: out:b64
257              format: [op_id_16]
258        header-template: [pandasm_header]
259        check-type: exit-positive
260        code-template: |
261
262          .function i32 main() {
263            fldai.64 %s
264            ststatic.64 R.ff64
265            lda.null
266            fmovi.64 v15, %s
267            ldstatic.64 R.ff64
268            fcmpg.64 v15
269            %s
270            jeqz success
271            ldai 1
272            return
273          success:
274        cases:
275          # f64
276          - values: ['0.0', '0.0', '']
277          - values: ['-6510615555426900571.0', '-6510615555426900571.0', '']
278          - values: ['0x7FFFFFFFFFFFFFFF', '0x7FFFFFFFFFFFFFFF', 'subi 1']    # NaN
279          - values: ['0x7ff0000000000000', '0x7ff0000000000000', '']    # + Inf
280          - values: ['0xfff0000000000000', '0xfff0000000000000', '']    # - Inf
281
282      - file-name: "x_init_p"
283        description: Check that ExceptionInInitializerError is thrown if an unexpected exception occurs in static initializer.
284        isa:
285          exceptions:
286            - x_init
287        header-template: []
288        check-type: empty
289        tags: ['tsan']
290        bugid: ['5330']
291        ignore: true
292        code-template: |
293
294          .language PandaAssembly
295
296          .record panda.ExceptionInInitializerError <external>
297          .record panda.NullPointerException <external>
298          .record E1 {}
299          .record R {
300              f64     ff64    <static>
301          }
302
303          .function void R.func() <cctor> {
304              %s
305              return.void
306          }
307
308          .function i32 main() {
309          begin:
310              ldstatic.64 R.ff64
311              ldai 2
312              return
313          end:
314          catch:
315              ldai 0
316              return
317          catch_all:
318              ldai 1
319              return
320          .catch panda.ExceptionInInitializerError, begin, end, catch
321          .catchall begin, end, catch_all
322          }
323        cases:
324          - values:
325            - |
326              #
327                  newobj v0, E1
328                  throw v0
329          - values:
330            - |
331              #
332                  newobj v0, panda.NullPointerException
333                  throw v0
334          - values:
335            - |
336              #
337                  movi v1, 0
338                  ldai 1
339                  div2 v1     # divide by zero
340          - values:
341            - |
342              #
343                  movi v1, 10
344                  newarr v1, v1, i32[]
345                  ldai 10
346                  ldarr v1    # get ArrayIndexOutOfBoundsException
347
348