• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15.record Object <external>
16.record panda.Object <external>
17.function void Object.monitorEnter(panda.Object a0) <external>
18.function void Object.monitorExit(panda.Object a0) <external>
19
20.record Obj {
21    i32 data
22}
23
24#! CHECKER      Check monitors for inlined functions: lse isn't applied
25#! RUN          force_jit: true, options: "", entry: "_GLOBAL::main"
26#! EVENT        /Inline,_GLOBAL::main,_GLOBAL::foo,.*STATIC,SUCCESS/
27#! METHOD       "_GLOBAL::main"
28#! PASS_AFTER   "LSE"
29#! INST         "CallStatic.Inlined"
30#! INST         "Monitor"
31#! INST         "LoadObject"
32#! INST         "Monitor"
33
34.function i32 foo(Obj a0) {
35    call Object.monitorEnter, a0
36    ldobj a0, Obj.data
37    sta v0
38    call Object.monitorExit, a0
39    lda v0
40    return
41}
42
43.function u1 main() {
44    newobj v0, Obj
45    ldai 0
46    stobj v0, Obj.data
47    call.short foo, v0
48    return
49}
50
51#! CHECKER      Check monitors for inlined functions: lse is applied
52#! RUN          force_jit: true, options: "", entry: "_GLOBAL::main1"
53#! EVENT        /Inline,_GLOBAL::main1,_GLOBAL::foo,.*STATIC,SUCCESS/
54#! METHOD       "_GLOBAL::main1"
55#! PASS_AFTER   "Inline"
56#! INST         "CallStatic.Inlined"
57#! INST         "Monitor"
58#! INST         "LoadObject"
59#! INST         "Monitor"
60#! PASS_AFTER   "LICM"
61#! INST_NOT     "CallStatic.Inlined"
62#! INST_NOT     "Monitor"
63#! INST         "LoadObject"
64#! PASS_AFTER   "LSE"
65#! INST_NOT     "LoadObject"
66
67#   Inlined function removed on first BranchElimination, but the checker checks second BranchElimination, so LICM is used
68
69.function u1 main1() {
70    newobj v0, Obj
71    ldai 0
72    stobj v0, Obj.data
73    jeqz lable
74    call.short foo, v0
75    return
76lable:
77    ldobj v0, Obj.data
78    return
79}
80