1# Copyright (c) 2021-2022 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: PandaAssembly_header 40 template: | 41 .language PandaAssembly 42 43 .record panda.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 panda.Object fObj <static> 57 panda.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-config'] 107 bugid: ['1324', '1828'] 108 - values: 109 - W.fi8 110 tags: [verifier] 111 runner-options: ['verifier-failure', 'verifier-config'] 112 bugid: ['1324', '1828'] 113 - values: 114 - W.fu16 115 tags: [verifier] 116 runner-options: ['verifier-failure', 'verifier-config'] 117 bugid: ['1324', '1828'] 118 - values: 119 - W.fi16 120 tags: [verifier] 121 runner-options: ['verifier-failure', 'verifier-config'] 122 bugid: ['1324', '1828'] 123 - values: 124 - W.fi32 125 tags: [verifier] 126 runner-options: ['verifier-failure', 'verifier-config'] 127 bugid: ['1324', '1828'] 128 - values: 129 - W.fi64 130 tags: [verifier] 131 runner-options: ['verifier-failure', 'verifier-config'] 132 bugid: ['1324', '1828'] 133 - values: 134 - W.ff32 135 tags: [verifier] 136 runner-options: ['verifier-failure', 'verifier-config'] 137 bugid: ['1324', '1828'] 138 - values: 139 - W.ff64 140 tags: [verifier] 141 runner-options: ['verifier-failure', 'verifier-config'] 142 bugid: ['1324', '1828'] 143 - values: 144 - W.fW 145 tags: [verifier] 146 runner-options: ['verifier-failure', 'verifier-config'] 147 bugid: ['1324', '1828'] 148 - values: 149 - W.fi32Array 150 tags: [verifier] 151 runner-options: ['verifier-failure', 'verifier-config'] 152 bugid: ['1324', '1828'] 153 - values: 154 - W.fWArray 155 tags: [verifier] 156 runner-options: ['verifier-failure', 'verifier-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-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.ff32 215 bugid: ['6094'] 216 - values: 217 - R.fObj 218 - values: 219 - R.fObjArray 220 - values: 221 - R.fi32Array 222 223 224 - file-name: "with_wrong_field_size_j" 225 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. 226 isa: 227 verification: 228 - field_id_size 229 header-template: [PandaAssembly_header] 230 check-type: exit-positive 231 tags: [verifier, pa-verifier] 232 runner-options: [verifier-failure, use-pa, verifier-config] 233 bugid: ["5271"] 234 code-template: | 235 236 .function i32 main() { 237 ldstatic.64 %s 238 cases: 239 - values: 240 - R.fu1 241 - values: 242 - R.fi8 243 - values: 244 - R.fu16 245 - values: 246 - R.fi16 247 - values: 248 - R.fi32 249 - values: 250 - R.ff32 251 bugid: ['6094'] 252 - values: 253 - R.fObj 254 - values: 255 - R.fObjArray 256 - values: 257 - R.fi32Array 258 259 260 - file-name: "from_all_int_field_types_p" 261 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. 262 isa: 263 description: Get static field value by field_id and put it into accumulator. 264 header-template: [pandasm_header] 265 check-type: exit-positive 266 tags: ['tsan'] 267 code-template: | 268 269 .function i32 main() { 270 ldai.64 %s 271 ststatic.64 R.f%s 272 movi.64 v15, %s 273 ldstatic.64 R.f%s 274 %s v15 275 jeqz success 276 ldai 1 277 return 278 success: 279 cases: 280 # u64 281 - values: [0, 'u64', 0, 'u64', 'ucmp.64'] 282 - values: [0xffffffffffffffff, 'u64', 0xffffffffffffffff, 'u64', 'ucmp.64'] 283 - values: [0xa5a5a5a5a5a5a5a5, 'u64', 0xa5a5a5a5a5a5a5a5, 'u64', 'ucmp.64'] 284 # i64 285 - values: [0, 'i64', 0, 'i64', 'cmp.64'] 286 - values: [-1, 'i64', -1, 'i64', 'cmp.64'] 287 - values: [-6510615555426900571, 'i64', -6510615555426900571, 'i64', 'cmp.64'] 288 289 290 - file-name: "from_all_int_field_types_j" 291 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. 292 isa: 293 description: Get static field value by field_id and put it into accumulator. 294 header-template: [PandaAssembly_header] 295 runner-options: [use-pa] 296 check-type: exit-positive 297 tags: ['tsan'] 298 code-template: | 299 300 .function i32 main() { 301 ldai.64 %s 302 ststatic.64 R.f%s 303 movi.64 v15, %s 304 ldstatic.64 R.f%s 305 %s v15 306 jeqz success 307 ldai 1 308 return 309 success: 310 cases: 311 # i64 312 - values: [0, 'i64', 0, 'i64', 'cmp.64'] 313 - values: [-1, 'i64', -1, 'i64', 'cmp.64'] 314 - values: [-6510615555426900571, 'i64', -6510615555426900571, 'i64', 'cmp.64'] 315 316 317 - file-name: "from_float_field_type_p" 318 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. 319 isa: 320 instructions: 321 - sig: ldstatic.64 field_id 322 acc: out:b64 323 format: [op_id_16] 324 tags: ['irtoc_ignore'] 325 header-template: [pandasm_header] 326 check-type: exit-positive 327 code-template: | 328 329 .function i32 main() { 330 fldai.64 %s 331 ststatic.64 R.ff64 332 lda.null 333 fmovi.64 v15, %s 334 ldstatic.64 R.ff64 335 fcmpg.64 v15 336 %s 337 jeqz success 338 ldai 1 339 return 340 success: 341 cases: 342 # f64 343 - values: ['0.0', '0.0', ''] 344 - values: ['-6510615555426900571.0', '-6510615555426900571.0', ''] 345 - values: ['0x7FFFFFFFFFFFFFFF', '0x7FFFFFFFFFFFFFFF', 'subi 1'] # NaN 346 - values: ['0x7ff0000000000000', '0x7ff0000000000000', ''] # + Inf 347 - values: ['0xfff0000000000000', '0xfff0000000000000', ''] # - Inf 348 349 - file-name: "from_float_field_type_j" 350 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. 351 isa: 352 instructions: 353 - sig: ldstatic.64 field_id 354 acc: out:b64 355 format: [op_id_16] 356 header-template: [PandaAssembly_header] 357 tags: ['irtoc_ignore'] 358 runner-options: [use-pa] 359 check-type: exit-positive 360 code-template: | 361 362 .function i32 main() { 363 fldai.64 %s 364 ststatic.64 R.ff64 365 lda.null 366 fmovi.64 v15, %s 367 ldstatic.64 R.ff64 368 fcmpg.64 v15 369 %s 370 jeqz success 371 ldai 1 372 return 373 success: 374 cases: 375 # f64 376 - values: ['0.0', '0.0', ''] 377 - values: ['-6510615555426900571.0', '-6510615555426900571.0', ''] 378 - values: ['0x7FFFFFFFFFFFFFFF', '0x7FFFFFFFFFFFFFFF', 'subi 1'] # NaN 379 - values: ['0x7ff0000000000000', '0x7ff0000000000000', ''] # + Inf 380 - values: ['0xfff0000000000000', '0xfff0000000000000', ''] # - Inf 381 382 - file-name: "x_init_p" 383 description: Check that ExceptionInInitializerError is thrown if an unexpected exception occurs in static initializer. 384 isa: 385 exceptions: 386 - x_init 387 header-template: [] 388 check-type: empty 389 tags: ['tsan', 'irtoc_ignore'] 390 bugid: ['5330'] 391 code-template: | 392 393 .language PandaAssembly 394 395 .record panda.ExceptionInInitializerError <external> 396 .record panda.NullPointerException <external> 397 .record E1 {} 398 .record R { 399 f64 ff64 <static> 400 } 401 402 .function void R.func() <cctor> { 403 %s 404 return.void 405 } 406 407 .function i32 main() { 408 begin: 409 ldstatic.64 R.ff64 410 ldai 2 411 return 412 end: 413 catch: 414 ldai 0 415 return 416 catch_all: 417 ldai 1 418 return 419 .catch panda.ExceptionInInitializerError, begin, end, catch 420 .catchall begin, end, catch_all 421 } 422 cases: 423 - values: 424 - | 425 # 426 newobj v0, E1 427 throw v0 428 - values: 429 - | 430 # 431 newobj v0, panda.NullPointerException 432 throw v0 433 - values: 434 - | 435 # 436 movi v1, 0 437 ldai 1 438 div2 v1 # divide by zero 439 - values: 440 - | 441 # 442 movi v1, 10 443 newarr v1, v1, i32[] 444 ldai 10 445 ldarr v1 # get ArrayIndexOutOfBoundsException 446 447 - file-name: "x_init_j" 448 description: Check that ExceptionInInitializerError is thrown if an unexpected exception occurs in static initializer. 449 isa: 450 exceptions: 451 - x_init 452 header-template: [] 453 check-type: empty 454 tags: ['tsan', 'irtoc_ignore'] 455 runner-options: ['use-pa'] 456 code-template: | 457 458 .language PandaAssembly 459 460 .record panda.ExceptionInInitializerError <external> 461 .record panda.NullPointerException <external> 462 .record E1 {} 463 .record R { 464 f64 ff64 <static> 465 } 466 .record Q <panda.extends=R> { 467 f64 ff64 <static> 468 } 469 .function void R.func() <cctor> { 470 %s 471 return.void 472 } 473 474 .function i32 main() { 475 begin: 476 ldstatic.64 Q.ff64 477 ldai 2 478 return 479 end: 480 catch: 481 ldai 0 482 return 483 catch_all: 484 ldai 1 485 return 486 .catch panda.ExceptionInInitializerError, begin, end, catch 487 .catchall begin, end, catch_all 488 } 489 cases: 490 - values: 491 - | 492 # 493 newobj v0, E1 494 throw v0 495 - values: 496 - | 497 # 498 newobj v0, panda.NullPointerException 499 throw v0 500 - values: 501 - | 502 # 503 movi v1, 0 504 ldai 1 505 div2 v1 # divide by zero 506 - values: 507 - | 508 # 509 movi v1, 10 510 newarr v1, v1, i32[] 511 ldai 10 512 ldarr v1 # get ArrayIndexOutOfBoundsException 513