• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 
16 #ifndef ECMASCRIPT_IC_IC_RUNTIME_STUB_H_
17 #define ECMASCRIPT_IC_IC_RUNTIME_STUB_H_
18 
19 #include "ecmascript/ic/profile_type_info.h"
20 #include "ecmascript/js_tagged_value.h"
21 #include "ecmascript/property_attributes.h"
22 
23 namespace panda::ecmascript {
24 class ICRuntimeStub {
25 public:
26     static inline JSTaggedValue LoadGlobalICByName(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
27                                                    JSTaggedValue globalValue, JSTaggedValue key, uint32_t slotId,
28                                                    bool tryLoad);
29     static inline JSTaggedValue StoreGlobalICByName(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
30                                                     JSTaggedValue globalValue, JSTaggedValue key,
31                                                     JSTaggedValue value, uint32_t slotId, bool tryStore);
32     static inline JSTaggedValue LoadICByName(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
33                                              JSTaggedValue receiver, JSTaggedValue key, uint32_t slotId);
34     static inline JSTaggedValue TryLoadICByName(JSThread *thread, JSTaggedValue receiver,
35                                                 JSTaggedValue firstValue, JSTaggedValue secondValue);
36     static inline JSTaggedValue TryStoreICByName(JSThread *thread, JSTaggedValue receiver,
37                                                  JSTaggedValue firstValue, JSTaggedValue secondValue,
38                                                  JSTaggedValue value);
39     static inline JSTaggedValue StoreICByName(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
40                                               JSTaggedValue receiver, JSTaggedValue key,
41                                               JSTaggedValue value, uint32_t slotId);
42     static inline JSTaggedValue CheckPolyHClass(JSTaggedValue cachedValue, JSHClass* hclass);
43     static inline JSTaggedValue LoadICWithHandler(JSThread *thread, JSTaggedValue receiver, JSTaggedValue holder,
44                                                   JSTaggedValue handler);
45     static inline JSTaggedValue StoreICWithHandler(JSThread *thread, JSTaggedValue receiver, JSTaggedValue holder,
46                                                    JSTaggedValue value, JSTaggedValue handler);
47     static inline void StoreWithTransition(JSThread *thread, JSObject *receiver, JSTaggedValue value,
48                                            JSTaggedValue handler, bool withPrototype = false);
49     static inline JSTaggedValue StoreTransWithProto(JSThread *thread, JSObject *receiver,
50                                                     JSTaggedValue value, JSTaggedValue handler);
51     static inline JSTaggedValue StoreWithTS(JSThread *thread, JSTaggedValue receiver,
52                                             JSTaggedValue value, JSTaggedValue handler);
53     static inline JSTaggedValue StorePrototype(JSThread *thread, JSTaggedValue receiver,
54                                                JSTaggedValue value, JSTaggedValue handler);
55     static inline JSTaggedValue LoadFromField(JSObject *receiver, uint32_t handlerInfo);
56     static inline void StoreField(JSThread *thread, JSObject *receiver, JSTaggedValue value, uint32_t handler);
57     static inline JSTaggedValue LoadGlobal(JSTaggedValue handler);
58     static inline JSTaggedValue StoreGlobal(JSThread *thread, JSTaggedValue value, JSTaggedValue handler);
59     static inline JSTaggedValue LoadPrototype(JSThread *thread, JSTaggedValue receiver, JSTaggedValue handler);
60 
61     static inline JSTaggedValue TryLoadICByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key,
62                                                  JSTaggedValue firstValue, JSTaggedValue secondValue);
63     static inline JSTaggedValue LoadICByValue(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
64                                               JSTaggedValue receiver, JSTaggedValue key, uint32_t slotId);
65     static inline JSTaggedValue TryStoreICByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key,
66                                                   JSTaggedValue firstValue, JSTaggedValue secondValue,
67                                                   JSTaggedValue value);
68     static inline JSTaggedValue StoreICByValue(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
69                                                JSTaggedValue receiver, JSTaggedValue key, JSTaggedValue value,
70                                                uint32_t slotId);
71     static inline JSTaggedValue LoadElement(JSObject *receiver, JSTaggedValue key);
72     static inline JSTaggedValue StoreElement(JSThread *thread, JSObject *receiver, JSTaggedValue key,
73                                              JSTaggedValue value, JSTaggedValue handlerInfo);
74     static inline int32_t TryToElementsIndex(JSTaggedValue key);
75     static inline JSTaggedValue LoadMiss(JSThread *thread, ProfileTypeInfo *profileTypeInfo, JSTaggedValue receiver,
76                                          JSTaggedValue key, uint32_t slotId, ICKind kind);
77     static inline JSTaggedValue StoreMiss(JSThread *thread, ProfileTypeInfo *profileTypeInfo, JSTaggedValue receiver,
78                                           JSTaggedValue key, JSTaggedValue value, uint32_t slotId, ICKind kind);
79 };
80 }  // namespace panda::ecmascript
81 
82 #endif  // ECMASCRIPT_IC_IC_RUNTIME_STUB_H_
83