# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. definitions: - name: pandasm_header template: | .language PandaAssembly .record panda.Object .record Q {} .function void Q.ctor(Q a0) { return.void } .record R { u1 fu1 u8 fu8 i8 fi8 u16 fu16 i16 fi16 u32 fu32 i32 fi32 u64 fu64 i64 fi64 f32 ff32 f64 ff64 i32[] fi32Array Q fQ Q[] fQArray panda.Object fObj panda.Object[] fObjArray } .function void R.ctor(R a0) { return.void } tests: - file-name: "stobj.64" isa: title: Store accumulator content into object field description: > Store accumulator content into object field by field_id. For non-object variant the size of actually stored value is determined by field_id, other accumulator bits are discarded. instructions: - sig: stobj.64 v:in:ref, field_id acc: in:b64 format: [op_v_8_id_16] commands: - file-name: "check_if_regs_initialized" description: Check that verifier reports error if source registers are not initialized isa: description: Store accumulator content into object field by field_id. header-template: ['pandasm_header'] check-type: exit-positive tags: ['verifier'] bugid: ['1324'] runner-options: ['verifier-failure', 'verifier-config'] code-template: | %s .function i32 main() { initobj R.ctor sta.obj v0 fmovi.64 v1, 1.1 call.short check, %s cases: - values: - | # acc (value) not initialized in the frame .function void check(R a0) { stobj.64 a0, R.ff64 return.void } - v0 - values: - | # v0 (object) not initialized in the frame .function void check(f64 a0) { lda.64 a0 stobj.64 v0, R.ff64 return.void } - v1 bugid: ['1324'] - file-name: "with_null_ref" description: Check that NullPointerException is thrown if object ref is null isa: exceptions: - x_null header-template: ['pandasm_header'] check-type: empty tags: ['tsan', 'irtoc_ignore'] bugid: ['3047'] code-template: | .record panda.NullPointerException .function R get_null() { lda.null return.obj } .function i32 main() { call.short get_null sta.obj v0 %s try_begin: stobj.64 v0, %s ldai 1 return try_end: ldai 0 return .catch panda.NullPointerException, try_begin, try_end, try_end } cases: - values: - ldai.64 1 - R.fi64 - values: - ldai.64 1 - R.fu64 - values: - fldai.64 1.1 - R.ff64 bugid: ['1882'] - file-name: "with_non_object_ref" description: Check that verifier reports error when the 1st operand is not a ref to an object (other than array) isa: verification: - v1_object header-template: ['pandasm_header'] check-type: empty tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] code-template: | .function i32 main() { %s ldai.64 1 try_begin: stobj.64 v0, R.fi64 try_end: ldai 0 return .catchall try_begin, try_end, try_end } cases: - values: - movi v0, 0 bugid: ['1324', '1826'] - values: - movi v0, 1 - values: - movi.64 v0, 0x00 bugid: ['1324', '1826'] - values: - movi.64 v0, 0xCAFECAFECAFECAFE - values: - fmovi.64 v0, 0.0 bugid: ['1324', '1826'] - values: - fmovi.64 v0, 6.62607015 - values: - | movi v1, 10 newarr v0, v1, R[] bugid: ['1827'] - file-name: "with_static_field_id" description: Check that verifier reports error when the field doesn't resolve to a non-static valid object field isa: verification: - field_id_non_static header-template: [] check-type: exit-positive code-template: | .record W { i64 static_field } .function void W.ctor(W a0) { return.void } .record random_record_name { i64 random_field_name } .function void random_function_name() { return.void } .function i32 main() { initobj W.ctor sta.obj v0 ldai.64 1 stobj.64 v0, %s cases: - values: - W.static_field runner-options: ['verifier-failure', 'verifier-config'] tags: ['verifier'] bugid: ['1324', '1828'] - values: - random_record_name runner-options: ['compile-failure'] - values: - random_function_name runner-options: ['compile-failure'] - values: - W.field_not_exists runner-options: ['compile-failure'] - values: - random_record_name.random_field_name tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] bugid: ['3536'] - values: - 0 runner-options: ['compile-failure'] - values: - -1.1 runner-options: ['compile-failure'] - values: - "null" runner-options: ['compile-failure'] - values: - "\"abc\"" runner-options: ['compile-failure'] - file-name: "with_wrong_field_size" description: Check that verifier reports error when the field resolves to a field with size that is not corresponding to bytecode isa: verification: - field_id_size header-template: ['pandasm_header'] check-type: exit-positive tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] bugid: ['1834'] code-template: | .function i32 main() { initobj R.ctor sta.obj v0 %s stobj.64 v0, %s cases: - values: - ldai.64 0 - R.fu1 - values: - ldai.64 0 - R.fu8 - values: - ldai.64 0 - R.fi8 - values: - ldai.64 0 - R.fu16 - values: - ldai.64 0 - R.fi16 - values: - ldai.64 0 - R.fu32 - values: - ldai.64 0 - R.fi32 - values: - fldai.64 0.0 - R.ff32 bugid: ['6094'] - values: - ldai.64 0 - R.fObj - values: - fldai.64 0.0 - R.fObjArray - values: - ldai.64 0 - R.fi32Array - file-name: "with_wrong_acc_type" description: Check that verifier reports error when the accumulator contains a value of type not corresponding to the bytecode isa: verification: - acc_type header-template: ['pandasm_header'] check-type: exit-positive tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] bugid: ['1834'] code-template: | .function i32 main() { initobj R.ctor sta.obj v0 %s stobj.64 v0, %s cases: # u64 - values: - ldai 0 - R.fu64 - values: - ldai 0xCAFECAFE - R.fu64 - values: - fldai 1.1 - R.fu64 - values: - fldai.64 1.1 - R.fu64 - values: - lda.null - R.fu64 - values: - initobj Q.ctor - R.fu64 - values: - | movi v1, 10 newarr v1, v1, i32[] lda.obj v1 - R.fu64 # i64 - values: - ldai 0 - R.fi64 - values: - ldai 0xCAFECAFE - R.fi64 - values: - fldai 1.1 - R.fi64 - values: - fldai.64 1.1 - R.fi64 - values: - lda.null - R.fi64 - values: - initobj Q.ctor - R.fi64 - values: - | movi v1, 10 newarr v1, v1, i32[] lda.obj v1 - R.fi64 # f64 - values: - ldai 0 - R.ff64 - values: - ldai 0xCAFECAFE - R.ff64 - values: - fldai 1.1 - R.ff64 bugid: ['6094'] - values: - ldai.64 1 - R.ff64 - values: - lda.null - R.ff64 - values: - initobj Q.ctor - R.ff64 - values: - | movi v1, 10 newarr v1, v1, i32[] lda.obj v1 - R.ff64 - file-name: "op_v_8_id_16" description: Check that compiler reports error when the register number is out of 8 bit size isa: instructions: - sig: stobj.64 v:in:ref, field_id acc: in:b64 format: [op_v_8_id_16] header-template: ['pandasm_header'] check-type: exit-positive code-template: | .function i32 main() { stobj.64 %s, R.fi64 cases: - values: ['v255'] runner-options: ['compile-only'] - values: ['v256'] runner-options: ['compile-failure'] - values: ['v65535'] runner-options: ['compile-failure'] - file-name: "into_all_field_types" description: Check that accumulator value is stored in field isa: instructions: - sig: stobj.64 v:in:ref, field_id acc: in:b64 format: [op_v_8_id_16] header-template: ['pandasm_header'] check-type: exit-positive tags: ['tsan', 'irtoc_ignore'] code-template: | .function i32 main() { initobj R.ctor sta.obj v0 %s stobj.64 v0, R.%s lda.null ldobj.64 v0, R.%s %s jeqz success ldai 1 return success: cases: # u64 - values: - ldai.64 0x0000000000000000 - fu64 - fu64 - | movi.64 v1, 0x0000000000000000 ucmp.64 v1 - values: - ldai.64 0xffffffffffffffff - fu64 - fu64 - | movi.64 v1, 0xffffffffffffffff ucmp.64 v1 - values: - ldai.64 0xa5a5a5a5a5a5a5a5 - fu64 - fu64 - | movi.64 v1, 0xa5a5a5a5a5a5a5a5 ucmp.64 v1 # i64 - values: - ldai.64 0 - fi64 - fi64 - | movi.64 v1, 0 cmp.64 v1 - values: - ldai.64 -1 - fi64 - fi64 - | movi.64 v1, -1 cmp.64 v1 - values: - ldai.64 -6510615555426900571 - fi64 - fi64 - | movi.64 v1, -6510615555426900571 cmp.64 v1 # f64 - values: - fldai.64 0.0 - ff64 - ff64 - | fmovi.64 v1, 0.0 fcmpg.64 v1 - values: - fldai.64 -6510615555426900571.0 - ff64 - ff64 - | fmovi.64 v1, -6510615555426900571.0 fcmpg.64 v1 - values: - fldai.64 0x7FFFFFFFFFFFFFFF # NaN - ff64 - ff64 - | fmovi.64 v1, 0.0 fcmpg.64 v1 subi 1 - values: - fldai.64 0x7ff0000000000000 # + Inf - ff64 - ff64 - | fmovi.64 v1, 0x7ff0000000000000 fcmpg.64 v1 - values: - fldai.64 0xfff0000000000000 # - Inf - ff64 - ff64 - | fmovi.64 v1, 0xfff0000000000000 fcmpg.64 v1 - file-name: "implicit_type_converting" description: Check that verifier does not allow to convert f64 -> f32 implicitly isa: instructions: - sig: stobj.64 v:in:ref, field_id acc: in:b64 format: [op_v_8_id_16] header-template: ['pandasm_header'] check-type: exit-positive tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] bugid: ['6094'] code-template: | .function i32 main() { initobj R.ctor sta.obj v0 %s stobj.64 v0, R.%s ldai 1 return success: cases: # f32 - values: - fldai.64 0.0 - ff32 - values: - fldai.64 -6510615555426900571.0 - ff32 - values: - fldai.64 0x7FFFFFFFFFFFFFFF # NaN - ff32 - values: - fldai.64 0x7ff0000000000000 # + Inf - ff32 - values: - fldai.64 0xfff0000000000000 # - Inf - ff32