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 # objects: 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" 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 v:in:ref, field_id 58 acc: in:i32 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 movi v1, 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 a0, R.fi32 86 return.void 87 } 88 - v0 89 - values: 90 - | 91 # v0 (object) not initialized in the frame 92 .function void check(i32 a0) { 93 lda a0 94 stobj v0, R.fi32 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: ['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 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 1 133 - R.fu1 134 - values: 135 - ldai 1 136 - R.fu8 137 - values: 138 - ldai 1 139 - R.fi8 140 - values: 141 - ldai 1 142 - R.fu16 143 - values: 144 - ldai 1 145 - R.fi16 146 - values: 147 - ldai 1 148 - R.fu32 149 - values: 150 - ldai 1 151 - R.fi32 152 - values: 153 - fldai 1.1 154 - R.ff32 155 bugid: ['1882'] 156 157 - file-name: "with_non_object_ref" 158 description: Check that verifier reports error when the 1st operand is not a ref to an object (other than array) 159 isa: 160 verification: 161 - v1_object 162 header-template: ['pandasm_header'] 163 check-type: empty 164 tags: ['verifier'] 165 bugid: ['1324', '1826', '1827'] 166 runner-options: ['verifier-failure', 'verifier-debug-config'] 167 code-template: | 168 169 .function i32 main() { 170 %s 171 ldai 1 172 try_begin: 173 stobj v0, R.fi32 174 try_end: 175 ldai 0 176 return 177 .catchall try_begin, try_end, try_end 178 } 179 cases: 180 - values: 181 - movi v0, 0 182 - values: 183 - movi v0, 1 184 - values: 185 - movi.64 v0, 0x00 186 - values: 187 - movi.64 v0, 0xCAFECAFECAFECAFE 188 - values: 189 - fmovi.64 v0, 0.0 190 - values: 191 - fmovi.64 v0, 6.62607015 192 - values: 193 - | 194 movi v1, 10 195 newarr v0, v1, R[] 196 197 198 - file-name: "with_static_field_id" 199 description: Check that verifier reports error if the field doesn't resolve to a non-static valid object field 200 isa: 201 verification: 202 - field_id_non_static 203 header-template: [] 204 check-type: exit-positive 205 bugid: ['1324', '1828', '1833'] 206 runner-options: ['verifier-failure', 'verifier-debug-config'] 207 tags: ['verifier'] 208 code-template: | 209 .record W { 210 i32 static_field <static> 211 } 212 .function void W.ctor(W a0) <ctor> { 213 return.void 214 } 215 .record random_record_name { 216 i32 random_field_name 217 } 218 .function void random_function_name() { 219 return.void 220 } 221 222 .function i32 main() { 223 initobj W.ctor 224 sta.obj v0 225 ldai 1 226 stobj v0, %s 227 cases: 228 - values: 229 - W.static_field 230 - values: 231 - random_record_name 232 runner-options: ['compile-failure'] 233 - values: 234 - random_function_name 235 runner-options: ['compile-failure'] 236 - values: 237 - W.field_not_exists 238 runner-options: ['compile-failure'] 239 - values: 240 - random_record_name.random_field_name 241 bugid: ['3536'] 242 ignore: true 243 - values: 244 - 0 245 runner-options: ['compile-failure'] 246 - values: 247 - -1.1 248 runner-options: ['compile-failure'] 249 - values: 250 - "null" 251 runner-options: ['compile-failure'] 252 - values: 253 - "\"abc\"" 254 runner-options: ['compile-failure'] 255 256 257 - file-name: "with_wrong_field_size" 258 description: Check that verifier reports error when the field resolves to a field with size that is not corresponding to bytecode 259 isa: 260 verification: 261 - field_id_size 262 header-template: ['pandasm_header'] 263 check-type: exit-positive 264 tags: ['verifier'] 265 runner-options: ['verifier-failure', 'verifier-debug-config'] 266 bugid: ['1834'] 267 code-template: | 268 .function i32 main() { 269 initobj R.ctor 270 sta.obj v0 271 ldai 0 272 stobj v0, %s 273 cases: 274 - values: 275 - R.fi64 276 - values: 277 - R.fu64 278 - values: 279 - R.ff64 280 - values: 281 - R.ff32 282 - values: 283 - R.fObj 284 - values: 285 - R.fObjArray 286 - values: 287 - R.fi32Array 288 289 - file-name: "with_wrong_acc_type" 290 description: Check that verifier reports error when the accumulator contains a value of type not corresponding to the bytecode 291 isa: 292 verification: 293 - acc_type 294 header-template: ['pandasm_header'] 295 check-type: exit-positive 296 tags: ['verifier'] 297 runner-options: ['verifier-failure', 'verifier-debug-config'] 298 code-template: | 299 .function i32 main() { 300 initobj R.ctor 301 sta.obj v0 302 %s 303 stobj v0, %s 304 cases: 305 - values: 306 - ldai.64 0xF000F000F000F000 307 - R.fu1 308 ignore: true 309 bugid: ['4166'] 310 - values: 311 - ldai.64 0 312 - R.fi8 313 ignore: true 314 bugid: ['4166'] 315 - values: 316 - ldai.64 0xCAFECAFECAFECAFE 317 - R.fu8 318 ignore: true 319 bugid: ['4166'] 320 - values: 321 - ldai.64 0 322 - R.fi16 323 ignore: true 324 bugid: ['4166'] 325 - values: 326 - ldai.64 0x5A5A5A5A5A5A5A5A 327 - R.fi32 328 ignore: true 329 bugid: ['1834'] 330 - values: 331 - ldai.64 1234567890 332 - R.fu32 333 ignore: true 334 bugid: ['1834'] 335 - values: 336 - fldai.64 0x7FFFFFFFFFFFFFFF 337 - R.fu1 338 - values: 339 - fldai.64 0.0 340 - R.fu8 341 - values: 342 - fldai.64 -0.0 343 - R.fi8 344 - values: 345 - fldai.64 1.0 346 - R.fu16 347 - values: 348 - fldai.64 3.0 349 - R.fi16 350 - values: 351 - fldai.64 0.123456 352 - R.fu32 353 - values: 354 - fldai.64 123456.0 355 - R.fi32 356 - values: 357 - lda.null 358 - R.fu32 359 - values: 360 - initobj Q.ctor 361 - R.fi32 362 - values: 363 - | 364 movi v1, 10 365 newarr v1, v1, i32[] 366 lda.obj v1 367 - R.fi32 368 369 370 - file-name: "op_v_8_id_16" 371 description: Check that compiler reports error when the register number is out of 8 bit size 372 isa: 373 instructions: 374 - sig: stobj v:in:ref, field_id 375 acc: in:i32 376 format: [op_v_8_id_16] 377 header-template: ['pandasm_header'] 378 check-type: exit-positive 379 code-template: | 380 381 .function i32 main() { 382 stobj %s, R.fi32 383 cases: 384 - values: ['v255'] 385 runner-options: ['compile-only'] 386 - values: ['v256'] 387 runner-options: ['compile-failure'] 388 - values: ['v65535'] 389 runner-options: ['compile-failure'] 390 391 392 - file-name: "into_all_field_types" 393 description: Check that accumulator value is stored in field 394 isa: 395 description: If field type size is less than 32, accumulator content will be truncated to storage size before storing. 396 header-template: ['pandasm_header'] 397 check-type: exit-positive 398 tags: ['tsan'] 399 code-template: | 400 401 .function i32 main() { 402 initobj R.ctor 403 sta.obj v0 404 %s 405 stobj v0, R.%s 406 lda.null 407 ldobj v0, R.%s 408 %s v1, %s 409 %s v1 410 %s 411 jeqz success 412 ldai 1 413 return 414 success: 415 cases: 416 # u1 417 - values: ['ldai 0x00000000', 'fu1', 'fu1', 'movi', 0, 'ucmp', ''] 418 - values: ['ldai 0xffffffff', 'fu1', 'fu1', 'movi', 1, 'ucmp', ''] 419 bugid: ['1848'] 420 ignore: true 421 - values: ['ldai 0x00000001', 'fu1', 'fu1', 'movi', 1, 'ucmp', ''] 422 - values: ['ldai 0xfffffffe', 'fu1', 'fu1', 'movi', 0, 'ucmp', ''] 423 bugid: ['1848'] 424 ignore: true 425 - values: ['ldai 0x11111111', 'fu1', 'fu1', 'movi', 1, 'ucmp', ''] 426 bugid: ['1848'] 427 ignore: true 428 - values: ['ldai 0x88888888', 'fu1', 'fu1', 'movi', 0, 'ucmp', ''] 429 bugid: ['1848'] 430 ignore: true 431 # u8 432 - values: ['ldai 0x00000000', 'fu8', 'fu8', 'movi', 0, 'ucmp', ''] 433 - values: ['ldai 0xffffffff', 'fu8', 'fu8', 'movi', 255, 'ucmp', ''] 434 - values: ['ldai 0x000000ff', 'fu8', 'fu8', 'movi', 255, 'ucmp', ''] 435 - values: ['ldai 0xffffff00', 'fu8', 'fu8', 'movi', 0, 'ucmp', ''] 436 - values: ['ldai 0x11111111', 'fu8', 'fu8', 'movi', 17, 'ucmp', ''] 437 - values: ['ldai 0x88888888', 'fu8', 'fu8', 'movi', 136, 'ucmp', ''] 438 # u16 439 - values: ['ldai 0x00000000', 'fu16', 'fu16', 'movi', 0, 'ucmp', ''] 440 - values: ['ldai 0xffffffff', 'fu16', 'fu16', 'movi', 65535, 'ucmp', ''] 441 - values: ['ldai 0x0000ffff', 'fu16', 'fu16', 'movi', 65535, 'ucmp', ''] 442 - values: ['ldai 0xffff0000', 'fu16', 'fu16', 'movi', 0, 'ucmp', ''] 443 - values: ['ldai 0x11111111', 'fu16', 'fu16', 'movi', 4369, 'ucmp', ''] 444 - values: ['ldai 0x88888888', 'fu16', 'fu16', 'movi', 34952, 'ucmp', ''] 445 # u32 446 - values: ['ldai 0x00000000', 'fu32', 'fu32', 'movi', 0, 'ucmp', ''] 447 - values: ['ldai 0xffffffff', 'fu32', 'fu32', 'movi', 4294967295, 'ucmp', ''] 448 - values: ['ldai 0x11111111', 'fu32', 'fu32', 'movi', 286331153, 'ucmp', ''] 449 - values: ['ldai 0x88888888', 'fu32', 'fu32', 'movi', 2290649224, 'ucmp', ''] 450 # f32 451 - values: ['fldai 0.0', 'ff32', 'ff32', 'fmovi', 0.0, 'fcmpg', ''] 452 bugid: ['3292'] 453 - values: ['fldai -6510615.0', 'ff32', 'ff32', 'fmovi', -6510615.0, 'fcmpg', ''] 454 bugid: ['3292'] 455 - values: ['fldai 0x7fffffff', 'ff32', 'ff32', 'fmovi', 0.0, 'fcmpg', 'subi 1'] 456 bugid: ['3292'] 457 - values: ['fldai 0x7f800000', 'ff32', 'ff32', 'fmovi', '0x7f800000', 'fcmpg', ''] 458 bugid: ['3292'] 459 - values: ['fldai 0xff800000', 'ff32', 'ff32', 'fmovi', '0xff800000', 'fcmpg', ''] 460 bugid: ['3292'] 461 462 - file-name: "into_all_field_types_int" 463 description: Version for integer types 464 isa: 465 description: If field type size is less than 32, accumulator content will be truncated to storage size before storing. 466 header-template: ['pandasm_header'] 467 check-type: exit-positive 468 tags: ['tsan'] 469 code-template: | 470 471 .function i32 main() { 472 initobj R.ctor 473 sta.obj v0 474 %s 475 stobj v0, R.%s 476 lda.null 477 ldobj v0, R.%s 478 movi v1, %s 479 jeq v1, success 480 ldai 1 481 return 482 success: 483 cases: 484 # i8 485 - values: ['ldai 0x00000000', 'fi8', 'fi8', 0] 486 - values: ['ldai 0xffffffff', 'fi8', 'fi8', -1] 487 - values: ['ldai 0x000000ff', 'fi8', 'fi8', -1] 488 - values: ['ldai 0xffffff00', 'fi8', 'fi8', 0] 489 - values: ['ldai 0x11111111', 'fi8', 'fi8', 17] 490 - values: ['ldai 0x88888888', 'fi8', 'fi8', -120] 491 # i16 492 - values: ['ldai 0x00000000', 'fi16', 'fi16', 0] 493 - values: ['ldai 0xffffffff', 'fi16', 'fi16', -1] 494 - values: ['ldai 0x0000ffff', 'fi16', 'fi16', -1] 495 - values: ['ldai 0xffff0000', 'fi16', 'fi16', 0] 496 - values: ['ldai 0x11111111', 'fi16', 'fi16', 4369] 497 - values: ['ldai 0x88888888', 'fi16', 'fi16', -30584] 498 # i32 499 - values: ['ldai 0x00000000', 'fi32', 'fi32', 0] 500 - values: ['ldai 0xffffffff', 'fi32', 'fi32', -1] 501 - values: ['ldai 0x11111111', 'fi32', 'fi32', 286331153] 502 - values: ['ldai 0x88888888', 'fi32', 'fi32', -2004318072] 503 504