• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #ifndef ECMASCRIPT_COMPILER_IC_STUB_BUILDER_H
16 #define ECMASCRIPT_COMPILER_IC_STUB_BUILDER_H
17 #include "ecmascript/compiler/stub_builder.h"
18 
19 namespace panda::ecmascript::kungfu {
20 class ICStubBuilder : public StubBuilder {
21 public:
ICStubBuilder(StubBuilder * parent)22     explicit ICStubBuilder(StubBuilder *parent)
23         : StubBuilder(parent) {}
24     ~ICStubBuilder() override = default;
25     NO_MOVE_SEMANTIC(ICStubBuilder);
26     NO_COPY_SEMANTIC(ICStubBuilder);
GenerateCircuit()27     void GenerateCircuit() override {}
28 
29     void SetParameters(GateRef glue, GateRef receiver, GateRef profileTypeInfo,
30         GateRef value, GateRef slotId, ProfileOperation callback = ProfileOperation())
31     {
32         glue_ = glue;
33         receiver_ = receiver;
34         profileTypeInfo_ = profileTypeInfo;
35         value_ = value;
36         slotId_ = slotId;
37         callback_ = callback;
38     }
39 
40     void SetParameters(GateRef glue, GateRef receiver, GateRef profileTypeInfo,
41         GateRef value, GateRef slotId, GateRef propKey, ProfileOperation callback = ProfileOperation())
42     {
43         SetParameters(glue, receiver, profileTypeInfo, value, slotId, callback);
44         propKey_ = propKey;
45     }
46 
47     void LoadICByName(Variable* result, Label* tryFastPath, Label *slowPath, Label *success,
48         ProfileOperation callback);
49     void StoreICByName(Variable* result, Label* tryFastPath, Label *slowPath, Label *success);
50     void LoadICByValue(Variable* result, Label* tryFastPath, Label *slowPath, Label *success,
51         ProfileOperation callback);
52     void StoreICByValue(Variable* result, Label* tryFastPath, Label *slowPath, Label *success);
53     void TryLoadGlobalICByName(Variable* result, Label* tryFastPath, Label *slowPath, Label *success);
54     void TryStoreGlobalICByName(Variable* result, Label* tryFastPath, Label *slowPath, Label *success);
55 private:
56     void NamedICAccessor(Variable* cachedHandler, Label *tryICHandler);
57     void ValuedICAccessor(Variable* cachedHandler, Label *tryICHandler, Label* tryElementIC);
SetLabels(Label * tryFastPath,Label * slowPath,Label * success)58     void SetLabels(Label* tryFastPath, Label *slowPath, Label *success)
59     {
60         tryFastPath_ = tryFastPath;
61         slowPath_ = slowPath;
62         success_ = success;
63     }
64 
65     GateRef glue_ {Circuit::NullGate()};
66     GateRef receiver_ {0};
67     GateRef profileTypeInfo_ {0};
68     GateRef value_ {0};
69     GateRef slotId_ {0};
70     GateRef propKey_ {0};
71     ProfileOperation callback_;
72 
73     Label *tryFastPath_ {nullptr};
74     Label *slowPath_ {nullptr};
75     Label *success_ {nullptr};
76 };
77 }  // namespace panda::ecmascript::kungfu
78 #endif  // ECMASCRIPT_COMPILER_IC_STUB_BUILDER_H
79