• 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/js_tagged_value.h"
20 #include "ecmascript/property_attributes.h"
21 #include "profile_type_info.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     static inline JSTaggedValue StoreGlobalICByName(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
29                                                     JSTaggedValue globalValue, JSTaggedValue key,
30                                                     JSTaggedValue value, uint32_t slotId);
31     static inline JSTaggedValue LoadICByName(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
32                                              JSTaggedValue receiver, JSTaggedValue key, uint32_t slotId);
33     static inline JSTaggedValue TryLoadICByName(JSThread *thread, JSTaggedValue receiver,
34                                                 JSTaggedValue firstValue, JSTaggedValue secondValue);
35     static inline JSTaggedValue TryStoreICByName(JSThread *thread, JSTaggedValue receiver,
36                                                  JSTaggedValue firstValue, JSTaggedValue secondValue,
37                                                  JSTaggedValue value);
38     static inline JSTaggedValue StoreICByName(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
39                                               JSTaggedValue receiver, JSTaggedValue key,
40                                               JSTaggedValue value, uint32_t slotId);
41     static inline JSTaggedValue CheckPolyHClass(JSTaggedValue cachedValue, JSHClass* hclass);
42     static inline JSTaggedValue LoadICWithHandler(JSThread *thread, JSTaggedValue receiver, JSTaggedValue holder,
43                                                   JSTaggedValue handler);
44     static inline JSTaggedValue StoreICWithHandler(JSThread *thread, JSTaggedValue receiver, JSTaggedValue holder,
45                                                    JSTaggedValue value, JSTaggedValue handler);
46     static inline void StoreWithTransition(JSThread *thread, JSObject *receiver, JSTaggedValue value,
47                                            JSTaggedValue handler);
48     static inline JSTaggedValue StorePrototype(JSThread *thread, JSTaggedValue receiver,
49                                                JSTaggedValue value, JSTaggedValue handler);
50     static inline JSTaggedValue LoadFromField(JSObject *receiver, uint32_t handlerInfo);
51     static inline void StoreField(JSThread *thread, JSObject *receiver, JSTaggedValue value, uint32_t handler);
52     static inline JSTaggedValue LoadGlobal(JSTaggedValue handler);
53     static inline JSTaggedValue StoreGlobal(JSThread *thread, JSTaggedValue value, JSTaggedValue handler);
54     static inline JSTaggedValue LoadPrototype(JSThread *thread, JSTaggedValue receiver, JSTaggedValue handler);
55 
56     static inline JSTaggedValue TryLoadICByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key,
57                                                  JSTaggedValue firstValue, JSTaggedValue secondValue);
58     static inline JSTaggedValue LoadICByValue(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
59                                               JSTaggedValue receiver, JSTaggedValue key, uint32_t slotId);
60     static inline JSTaggedValue TryStoreICByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key,
61                                                   JSTaggedValue firstValue, JSTaggedValue secondValue,
62                                                   JSTaggedValue value);
63     static inline JSTaggedValue StoreICByValue(JSThread *thread, ProfileTypeInfo *profileTypeInfo,
64                                                JSTaggedValue receiver, JSTaggedValue key, JSTaggedValue value,
65                                                uint32_t slotId);
66     static inline JSTaggedValue LoadElement(JSObject *receiver, JSTaggedValue key);
67     static inline JSTaggedValue StoreElement(JSThread *thread, JSObject *receiver, JSTaggedValue key,
68                                              JSTaggedValue value, JSTaggedValue handlerInfo);
69     static inline int32_t TryToElementsIndex(JSTaggedValue key);
70     static inline JSTaggedValue LoadMiss(JSThread *thread, ProfileTypeInfo *profileTypeInfo, JSTaggedValue receiver,
71                                          JSTaggedValue key, uint32_t slotId, ICKind kind);
72     static inline JSTaggedValue StoreMiss(JSThread *thread, ProfileTypeInfo *profileTypeInfo, JSTaggedValue receiver,
73                                           JSTaggedValue key, JSTaggedValue value, uint32_t slotId, ICKind kind);
74 };
75 }  // namespace panda::ecmascript
76 
77 #endif  // ECMASCRIPT_IC_IC_RUNTIME_STUB_H_
78