• 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 Matrix {
17    A;
18    m;
19    n;
20
21    constructor(A) {
22        this.A = null;
23        this.m = 0;
24        this.n = 0;
25        (() => {
26            this.m = A.length;
27            this.n = A[0].length;
28            this.A = A;
29        })();
30    }
31
32    timesEquals(s) {
33        for(let i = 0; i < this.m; i++) {
34            for(let j = 0; j < this.n; j++) {
35                // check this stobjbyvalue
36                this.A[i][j] = s * this.A[i][j];
37            };
38        };
39        return this;
40    }
41}
42
43let A;
44function test() {
45    let array = []
46    for (let i = 0; i < 10; i++) {
47        let arr = []
48        for (let j = 0; j < 10; j++) {
49            arr.push((Math.random() * 10).toFixed())
50        }
51        array.push(arr)
52    }
53    A = new Matrix(array);
54    A.timesEquals(2);
55}
56
57test()
58// expected poly state
59// slotid : 17, ickind: storeic
60print(ArkTools.getICState(A.timesEquals, 17, 3))
61
62
63{
64    function prototypeic() {
65        let a = [1, 2];
66        for (let i = 3; i < 10; ++i) {
67            // test prototype store ic handler
68            a[i] = 4;
69        }
70    }
71
72    prototypeic();
73
74    print(ArkTools.getICState(prototypeic, 2, 3));
75}
76
77{
78    function transwithprotohandler() {
79        for (let i = 0; i < 10; ++i) {
80            let a = [1, 2];
81            for (let j = 3; j < 10; ++j) {
82                // test transwithproto store ic handler when j is 3
83                a[j] = 4;
84            }
85        }
86    }
87
88    transwithprotohandler();
89
90    print(ArkTools.getICState(transwithprotohandler, 3, 3));
91}