• 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)26     explicit AccessObjectStubBuilder(StubBuilder *parent) : StubBuilder(parent)
27     {
28         jsFunc_ = Circuit::NullGate();
29     }
AccessObjectStubBuilder(StubBuilder * parent,GateRef jsFunc)30     explicit AccessObjectStubBuilder(StubBuilder *parent, GateRef jsFunc)
31         : StubBuilder(parent), 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 StoreObjByNameWithMega(GateRef glue, GateRef receiver, GateRef value, GateRef megaStubCache,
45                                    GateRef propKey, GateRef jsFunc, GateRef slotId,
46                                    ProfileOperation callback = ProfileOperation());
47     GateRef LoadPrivatePropertyByName(GateRef glue, GateRef receiver, GateRef key, GateRef profileTypeInfo,
48                                       GateRef slotId, ProfileOperation callback);
49     GateRef StorePrivatePropertyByName(GateRef glue,
50                                        GateRef receiver,
51                                        GateRef key,
52                                        GateRef value,
53                                        GateRef profileTypeInfo,
54                                        GateRef slotId,
55                                        ProfileOperation callback = ProfileOperation());
56     GateRef LoadObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef profileTypeInfo, GateRef slotId,
57         ProfileOperation callback = ProfileOperation());
58     GateRef StoreObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef profileTypeInfo,
59                             GateRef slotId, ProfileOperation callback = ProfileOperation());
60     GateRef StoreOwnByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value, GateRef profileTypeInfo,
61                             GateRef slotId, ProfileOperation callback = ProfileOperation());
62     GateRef DeprecatedLoadObjByValue(GateRef glue, GateRef receiver, GateRef key);
63     GateRef TryLoadGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info,
64                                 GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
65     GateRef TryStoreGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info,
66                                  GateRef value, GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
67     GateRef LoadGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info,
68                           GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
69     GateRef StoreGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info,
70                            GateRef value, GateRef profileTypeInfo, GateRef slotId);
71     GateRef StOwnByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value);
72     GateRef StOwnByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value);
73     GateRef StOwnByName(GateRef glue, GateRef receiver, GateRef key, GateRef value);
74     GateRef StOwnByValueWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value);
75     GateRef StOwnByNameWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value);
76     GateRef StObjByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value);
77     GateRef LdObjByIndex(GateRef glue, GateRef receiver, GateRef index);
78 
79 private:
80     GateRef ResolvePropKey(GateRef glue, GateRef prop, const StringIdInfo &info);
81     GateRef jsFunc_ { Circuit::NullGate() };
82 };
83 }  // namespace panda::ecmascript::kungfu
84 #endif  // ECMASCRIPT_COMPILER_ACCESS_OBJECT_STUB_BUILDER_H
85