• 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_ACCESS_OBJECT_STUB_BUILDER_H
16 #define ECMASCRIPT_COMPILER_ACCESS_OBJECT_STUB_BUILDER_H
17 
18 #include "ecmascript/compiler/interpreter_stub.h"
19 #include "ecmascript/compiler/profiler_operation.h"
20 #include "ecmascript/compiler/share_gate_meta_data.h"
21 #include "ecmascript/compiler/stub_builder.h"
22 
23 namespace panda::ecmascript::kungfu {
24 class AccessObjectStubBuilder : public StubBuilder {
25 public:
AccessObjectStubBuilder(StubBuilder * parent,GateRef globalEnv)26     AccessObjectStubBuilder(StubBuilder *parent, GateRef globalEnv) : StubBuilder(parent, globalEnv)
27     {
28         jsFunc_ = Circuit::NullGate();
29     }
AccessObjectStubBuilder(StubBuilder * parent,GateRef globalEnv,GateRef jsFunc)30     AccessObjectStubBuilder(StubBuilder *parent, GateRef globalEnv, GateRef jsFunc)
31         : StubBuilder(parent, globalEnv), jsFunc_(jsFunc) {}
32     ~AccessObjectStubBuilder() override = default;
33     NO_MOVE_SEMANTIC(AccessObjectStubBuilder);
34     NO_COPY_SEMANTIC(AccessObjectStubBuilder);
GenerateCircuit()35     void GenerateCircuit() override {}
36 
37     GateRef LoadObjByName(GateRef glue, GateRef receiver, GateRef prop, const StringIdInfo &info,
38                           GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback = ProfileOperation());
39     GateRef LoadObjByNameWithMega(GateRef glue, GateRef receiver, GateRef megaStubCache, GateRef propKey,
40                                   GateRef jsFunc, GateRef slotId, ProfileOperation callback = ProfileOperation());
41     GateRef DeprecatedLoadObjByName(GateRef glue, GateRef receiver, GateRef propKey);
42     GateRef StoreObjByName(GateRef glue, GateRef receiver, GateRef prop, const StringIdInfo &info, GateRef value,
43         GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback = ProfileOperation());
44     GateRef StOwnICByName(GateRef glue, GateRef receiver, GateRef prop, const StringIdInfo &info, GateRef value,
45         GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback = ProfileOperation());
46     GateRef StoreObjByNameWithMega(GateRef glue, GateRef receiver, GateRef value, GateRef megaStubCache,
47                                    GateRef propKey, GateRef jsFunc, GateRef slotId,
48                                    ProfileOperation callback = ProfileOperation());
49     GateRef LoadPrivatePropertyByName(GateRef glue, GateRef receiver, GateRef key, GateRef profileTypeInfo,
50                                       GateRef slotId, ProfileOperation callback);
51     GateRef StorePrivatePropertyByName(GateRef glue,
52                                        GateRef receiver,
53                                        GateRef key,
54                                        GateRef value,
55                                        GateRef profileTypeInfo,
56                                        GateRef slotId,
57                                        ProfileOperation callback = ProfileOperation());
58     GateRef LoadObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef profileTypeInfo, GateRef slotId,
59         ProfileOperation callback = ProfileOperation());
60     GateRef StoreObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef profileTypeInfo,
61                             GateRef slotId, ProfileOperation callback = ProfileOperation());
62     GateRef StoreOwnByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value, GateRef profileTypeInfo,
63                             GateRef slotId, ProfileOperation callback = ProfileOperation());
64     GateRef DeprecatedLoadObjByValue(GateRef glue, GateRef receiver, GateRef key);
65     GateRef TryLoadGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info,
66                                 GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
67     GateRef TryStoreGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info,
68                                  GateRef value, GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
69     GateRef LoadGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info,
70                           GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
71     GateRef StoreGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info,
72                            GateRef value, GateRef profileTypeInfo, GateRef slotId);
73     GateRef StOwnByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value);
74     GateRef StOwnByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value);
75     GateRef StOwnByName(GateRef glue, GateRef receiver, GateRef key, GateRef value);
76     GateRef StOwnByValueWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value);
77     GateRef StOwnByNameWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value);
78     GateRef StObjByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value);
79     GateRef LdObjByIndex(GateRef glue, GateRef receiver, GateRef index);
80 
81 private:
82     GateRef ResolvePropKey(GateRef glue, GateRef prop, const StringIdInfo &info);
83     GateRef jsFunc_ { Circuit::NullGate() };
84 };
85 }  // namespace panda::ecmascript::kungfu
86 #endif  // ECMASCRIPT_COMPILER_ACCESS_OBJECT_STUB_BUILDER_H
87