• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16class A {
17    constructor() {
18        this.x = 5
19    }
20    get getx() {
21        return this.x
22    }
23    get getz() {
24        return this.z
25    }
26}
27
28class B extends A {
29    constructor() {
30        super()
31    }
32}
33
34class C extends A {
35    constructor() {
36        super()
37    }
38}
39
40class D extends A {
41    constructor() {
42        super()
43        this.y = 3
44    }
45    get gety() {
46        return this.y
47    }
48}
49
50class E extends A {
51    constructor() {
52        super();
53        this.y = 4
54    }
55    get gety() {
56        return this.y
57    }
58}
59class F {
60    constructor() {
61        this.x = 1
62        this.y = 2
63        this.z = 3
64    }
65    get getx() {
66        return this.x
67    }
68    get gety() {
69        return this.y
70    }
71    get getz() {
72        return this.z
73    }
74}
75
76class G {
77    constructor() {
78        this.z = 4
79        this.y = 5
80        this.x = 6
81    }
82    get getz() {
83        return this.z
84    }
85    get gety() {
86        return this.y
87    }
88    get getx() {
89        return this.x
90    }
91}
92
93class H extends A {
94    constructor() {
95        super();
96        this.z = 2
97    }
98}
99
100class I extends H {
101}
102
103class J extends I {
104}
105
106let a = new A()
107let b = new B()
108let c = new C()
109let d = new D()
110let e = new E()
111let f = new F()
112let g = new G()
113let h = new H()
114let i = new I()
115let j = new J()
116
117function test1(obj) {
118    print(obj.y)
119}
120
121function test2(obj) {
122    print(obj.y)
123}
124
125function test3(obj) {
126    print(obj.x)
127}
128
129function test4(obj) {
130    print(obj.z)
131}
132
133function test5(obj) {
134    print(obj.x)
135}
136
137function testGet1(obj) {
138    print(obj.gety)
139}
140
141function testGet2(obj) {
142    print(obj.gety)
143}
144
145function testGet3(obj) {
146    print(obj.getx)
147}
148
149function testGet4(obj) {
150    print(obj.getz)
151}
152
153ArkTools.clearTypedOpProfiler();
154
155test1(f)
156test1(g)
157ArkTools.printTypedOpProfiler("OBJECT_TYPE_CHECK");
158ArkTools.clearTypedOpProfiler();
159
160test2(d)
161test2(e)
162ArkTools.printTypedOpProfiler("OBJECT_TYPE_CHECK");
163ArkTools.clearTypedOpProfiler();
164
165test3(b)
166test3(c)
167test3(d)
168ArkTools.printTypedOpProfiler("OBJECT_TYPE_CHECK");
169ArkTools.clearTypedOpProfiler();
170
171test4(i)
172test4(j)
173ArkTools.printTypedOpProfiler("OBJECT_TYPE_CHECK");
174ArkTools.clearTypedOpProfiler();
175
176//b and c can be merged but not MONO
177test5(b)
178test5(c)
179test5(g)
180ArkTools.printTypedOpProfiler("OBJECT_TYPE_CHECK");
181ArkTools.clearTypedOpProfiler();
182
183//optimization not allowed
184testGet1(f)
185testGet1(g)
186ArkTools.printTypedOpProfiler("OBJECT_TYPE_CHECK");
187ArkTools.clearTypedOpProfiler();
188
189
190//optimization not allowed
191testGet2(d)
192testGet2(e)
193ArkTools.printTypedOpProfiler("OBJECT_TYPE_CHECK");
194ArkTools.clearTypedOpProfiler();
195
196testGet3(b)
197testGet3(c)
198testGet3(d)
199ArkTools.printTypedOpProfiler("OBJECT_TYPE_CHECK");
200ArkTools.clearTypedOpProfiler();
201
202testGet4(i)
203testGet4(j)
204ArkTools.printTypedOpProfiler("OBJECT_TYPE_CHECK");
205ArkTools.clearTypedOpProfiler();