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# Check that OOM during class loading is handled correctly 15 16.record panda.Object <external> 17.record panda.OutOfMemoryError <external> 18.record Object <external> 19.record panda.Class <external> 20 21.function panda.Object Object.createNonMovable(panda.Class a0) <external> 22 23.record A { 24 A next 25 26 i64 f0 27 i64 f1 28 i64 f2 29 i64 f3 30 i64 f4 31 i64 f5 32 i64 f6 33 i64 f7 34 i64 f8 35 i64 f9 36 37 i64 f10 38 i64 f11 39 i64 f12 40 i64 f13 41 i64 f14 42 i64 f15 43 i64 f16 44 i64 f17 45 i64 f18 46 i64 f19 47} 48 49.function void A.ctor(A a0) <ctor> { 50 return.void 51} 52 53.function i32 main() { 54 movi v0, 100000 55 movi v1, 0 56 lda.type A 57 sta.obj v3 58 call Object.createNonMovable, v3 59 checkcast A 60 sta.obj v3 61 call.short A.ctor, v3 62 mov.obj v6, v3 63label_trystart: 64 lda v1 65 jge v0, label_foo 66 lda.type A 67 sta.obj v4 68 call Object.createNonMovable, v4 69 checkcast A 70 sta.obj v4 71 call.short A.ctor, v4 72 stobj.v.obj v4, v3, A.next 73 mov.obj v3, v4 74 inci v1, 1 75label_tryend: 76 jmp label_trystart 77label_catch: 78 jmp label_foo 79label_foo: 80 call.short foo, v6 81 ldai 1 82label_fooend: 83 return 84label_catch2: 85 ldai 0 86 return 87 88.catch panda.OutOfMemoryError, label_trystart, label_tryend, label_catch 89.catch panda.OutOfMemoryError, label_foo, label_fooend, label_catch2 90} 91 92.function panda.Object[] foo(A a0) { 93 movi v0, 0 94 mov v1, v0 95 mov.obj v0, a0 96label_1: 97 lda.obj v0 98 jeqz.obj label_0 99 ldobj.v.obj v0, v0, A.next 100 lda v1 101 addi 1 102 sta v2 103 mov v1, v2 104 jmp label_1 105label_0: 106 newarr v0, v1, A[] 107 lda.obj v0 108 return.obj 109} 110