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 14#! CHECKER Use implicit NullCheck for array and object 15#! SKIP_IF @architecture == "arm32" 16#! RUN force_jit: true, options: "", entry: "_GLOBAL::main" 17#! EVENT /Compilation,.*__noinline__call_ldarray.*/ 18#! EVENT_NEXT /ImplicitNullcheck,.*/ 19#! EVENT_NEXT /Compilation,.*__noinline__call_starray.*/ 20#! EVENT_NEXT /ImplicitNullcheck,.*/ 21#! EVENT_NEXT /Compilation,.*__noinline__call_ldobj_i32.*/ 22#! EVENT_NEXT /ImplicitNullcheck,.*/ 23#! EVENT_NEXT /Compilation,.*__noinline__call_stobj_i32.*/ 24#! EVENT_NEXT /ImplicitNullcheck,.*/ 25#! EVENT_NEXT /Compilation,.*__noinline__call_ldobj_f64.*/ 26#! EVENT_NEXT /ImplicitNullcheck,.*/ 27#! EVENT_NEXT /Compilation,.*__noinline__call_stobj_f64.*/ 28#! EVENT_NEXT /ImplicitNullcheck,.*/ 29#! EVENT_NEXT /Compilation,.*__noinline__call_ldobj_obj.*/ 30#! EVENT_NEXT /ImplicitNullcheck,.*/ 31#! EVENT_NEXT /Compilation,.*__noinline__call_stobj_obj.*/ 32#! EVENT_NEXT /ImplicitNullcheck,.*/ 33 34#! CHECKER Use implicit NullCheck for array and object in AOT 35#! SKIP_IF @architecture == "arm32" 36#! RUN_PAOC options: "" 37#! EVENT /Compilation,.*__noinline__call_ldarray.*/ 38#! EVENT /Compilation,.*__noinline__call_starray.*/ 39#! EVENT /Compilation,.*__noinline__call_ldobj_i32.*/ 40#! EVENT /Compilation,.*__noinline__call_stobj_i32.*/ 41#! RUN options: "", entry: "_GLOBAL::main" 42#! EVENT /ImplicitNullcheck,.*/ 43#! EVENT_NEXT /Exception,.*__noinline__call_ldarray.*NULL_CHECK/ 44#! EVENT_NEXT /ImplicitNullcheck,.*/ 45#! EVENT_NEXT /Exception,.*__noinline__call_starray.*NULL_CHECK/ 46#! EVENT_NEXT /ImplicitNullcheck,.*/ 47#! EVENT_NEXT /Exception,.*__noinline__call_ldobj_i32.*NULL_CHECK/ 48#! EVENT_NEXT /ImplicitNullcheck,.*/ 49#! EVENT_NEXT /Exception,.*__noinline__call_stobj_i32.*NULL_CHECK/ 50#! EVENT_NEXT /ImplicitNullcheck,.*/ 51#! EVENT_NEXT /Exception,.*__noinline__call_ldobj_f64.*NULL_CHECK/ 52#! EVENT_NEXT /ImplicitNullcheck,.*/ 53#! EVENT_NEXT /Exception,.*__noinline__call_stobj_f64.*NULL_CHECK/ 54#! EVENT_NEXT /ImplicitNullcheck,.*/ 55#! EVENT_NEXT /Exception,.*__noinline__call_ldobj_obj.*NULL_CHECK/ 56#! EVENT_NEXT /ImplicitNullcheck,.*/ 57#! EVENT_NEXT /Exception,.*__noinline__call_stobj_obj.*NULL_CHECK/ 58 59.record panda.String <external> 60.record panda.NullPointerException <external> 61 62.function panda.String panda.NullPointerException.getMessage(panda.NullPointerException a0) <external> 63 64.record A { 65 i32 data 66 f64 data_f64 67 A data_obj 68} 69 70.function i32 __noinline__call_ldarray(i32[] a0) { 71try_begin: 72 ldai 0 73 ldarr a0 74 addi 2 75 return 76try_end: 77 78catch_block1_begin: 79 sta.obj a0 80 call.virt panda.NullPointerException.getMessage, a0 81 jnez.obj catch_block2_begin 82 ldai 0 83 return 84 85catch_block2_begin: 86 ldai 1 87 return 88 89.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin 90.catchall try_begin, try_end, catch_block2_begin 91} 92 93.function i32 __noinline__call_starray(i32[] a0) { 94try_begin: 95 ldai 0 96 movi v0, 0 97 starr a0, v0 98 ldai 2 99 return 100try_end: 101 102catch_block1_begin: 103 sta.obj a0 104 call.virt panda.NullPointerException.getMessage, a0 105 jnez.obj catch_block2_begin 106 ldai 0 107 return 108 109catch_block2_begin: 110 ldai 1 111 return 112 113.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin 114.catchall try_begin, try_end, catch_block2_begin 115} 116 117.function i32 __noinline__call_ldobj_i32(A a0) { 118try_begin: 119 ldobj a0, A.data 120 addi 2 121 return 122try_end: 123 124catch_block1_begin: 125 sta.obj a0 126 call.virt panda.NullPointerException.getMessage, a0 127 jnez.obj catch_block2_begin 128 ldai 0 129 return 130 131catch_block2_begin: 132 ldai 1 133 return 134 135.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin 136.catchall try_begin, try_end, catch_block2_begin 137} 138 139.function i32 __noinline__call_stobj_i32(A a0) { 140try_begin: 141 ldai 0x9 142 stobj a0, A.data 143 ldai 2 144 return 145try_end: 146 147catch_block1_begin: 148 sta.obj a0 149 call.virt panda.NullPointerException.getMessage, a0 150 jnez.obj catch_block2_begin 151 ldai 0 152 return 153 154catch_block2_begin: 155 ldai 1 156 return 157 158.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin 159.catchall try_begin, try_end, catch_block2_begin 160} 161 162.function i32 __noinline__call_ldobj_f64(A a0) { 163try_begin: 164 ldobj a0, A.data_f64 165 f64toi32 166 addi 2 167 return 168try_end: 169 170catch_block1_begin: 171 sta.obj a0 172 call.virt panda.NullPointerException.getMessage, a0 173 jnez.obj catch_block2_begin 174 ldai 0 175 return 176 177catch_block2_begin: 178 ldai 1 179 return 180 181.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin 182.catchall try_begin, try_end, catch_block2_begin 183} 184 185.function i32 __noinline__call_stobj_f64(A a0) { 186try_begin: 187 fldai.64 1.1 188 stobj.64 a0, A.data_f64 189 ldai 2 190 return 191try_end: 192 193catch_block1_begin: 194 sta.obj a0 195 call.virt panda.NullPointerException.getMessage, a0 196 jnez.obj catch_block2_begin 197 ldai 0 198 return 199 200catch_block2_begin: 201 ldai 1 202 return 203 204.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin 205.catchall try_begin, try_end, catch_block2_begin 206} 207 208.function i32 __noinline__call_ldobj_obj(A a0) { 209try_begin: 210 ldobj a0, A.data_obj 211 isinstance A 212 addi 2 213 return 214try_end: 215 216catch_block1_begin: 217 sta.obj a0 218 call.virt panda.NullPointerException.getMessage, a0 219 jnez.obj catch_block2_begin 220 ldai 0 221 return 222 223catch_block2_begin: 224 ldai 1 225 return 226 227.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin 228.catchall try_begin, try_end, catch_block2_begin 229} 230 231.function i32 __noinline__call_stobj_obj(A a0) { 232try_begin: 233 newobj v0, A 234 lda.obj v0 235 stobj a0, A.data_obj 236 ldai 2 237 return 238try_end: 239 240catch_block1_begin: 241 sta.obj a0 242 call.virt panda.NullPointerException.getMessage, a0 243 jnez.obj catch_block2_begin 244 ldai 0 245 return 246 247catch_block2_begin: 248 ldai 1 249 return 250 251.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin 252.catchall try_begin, try_end, catch_block2_begin 253} 254 255.function u1 main() { 256 mov.null v0 257 call __noinline__call_ldarray, v0 258 jnez error_exit_1 259 call __noinline__call_starray, v0 260 jnez error_exit_2 261 call __noinline__call_ldobj_i32, v0 262 jnez error_exit_3 263 call __noinline__call_stobj_i32, v0 264 jnez error_exit_4 265 call __noinline__call_ldobj_f64, v0 266 jnez error_exit_5 267 call __noinline__call_stobj_f64, v0 268 jnez error_exit_6 269 call __noinline__call_ldobj_obj, v0 270 jnez error_exit_7 271 call __noinline__call_stobj_obj, v0 272 jnez error_exit_8 273 ldai 0 274 return 275error_exit_1: 276 ldai 1 277 return 278error_exit_2: 279 ldai 2 280 return 281error_exit_3: 282 ldai 3 283 return 284error_exit_4: 285 ldai 4 286 return 287error_exit_5: 288 ldai 5 289 return 290error_exit_6: 291 ldai 6 292error_exit_7: 293 ldai 7 294 return 295error_exit_8: 296 ldai 8 297 return 298}