1 /* 2 * Copyright (c) 2021-2023 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 LoadICWithElementHandler(JSThread *thread, JSTaggedValue receiver, 46 JSTaggedValue handler, JSTaggedValue key); 47 static inline JSTaggedValue StoreICWithHandler(JSThread *thread, JSTaggedValue receiver, JSTaggedValue holder, 48 JSTaggedValue value, JSTaggedValue handler); 49 static inline void StoreWithTransition(JSThread *thread, JSObject *receiver, JSTaggedValue value, 50 JSTaggedValue handler, bool withPrototype = false); 51 static inline JSTaggedValue StoreTransWithProto(JSThread *thread, JSObject *receiver, 52 JSTaggedValue value, JSTaggedValue handler); 53 static inline JSTaggedValue StoreWithTS(JSThread *thread, JSTaggedValue receiver, 54 JSTaggedValue value, JSTaggedValue handler); 55 static inline JSTaggedValue StorePrototype(JSThread *thread, JSTaggedValue receiver, 56 JSTaggedValue value, JSTaggedValue handler); 57 static inline JSTaggedValue LoadFromField(JSObject *receiver, uint64_t handlerInfo); 58 static inline void StoreField(JSThread *thread, JSObject *receiver, JSTaggedValue value, uint64_t handler); 59 static inline JSTaggedValue LoadGlobal(JSTaggedValue handler); 60 static inline JSTaggedValue StoreGlobal(JSThread *thread, JSTaggedValue value, JSTaggedValue handler); 61 static inline JSTaggedValue LoadPrototype(JSThread *thread, JSTaggedValue receiver, JSTaggedValue handler); 62 63 static inline JSTaggedValue TryLoadICByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, 64 JSTaggedValue firstValue, JSTaggedValue secondValue); 65 static inline JSTaggedValue LoadICByValue(JSThread *thread, ProfileTypeInfo *profileTypeInfo, 66 JSTaggedValue receiver, JSTaggedValue key, uint32_t slotId); 67 static inline JSTaggedValue TryStoreICByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, 68 JSTaggedValue firstValue, JSTaggedValue secondValue, 69 JSTaggedValue value); 70 static inline JSTaggedValue StoreICByValue(JSThread *thread, ProfileTypeInfo *profileTypeInfo, 71 JSTaggedValue receiver, JSTaggedValue key, JSTaggedValue value, 72 uint32_t slotId); 73 static inline JSTaggedValue StoreOwnICByValue(JSThread *thread, ProfileTypeInfo *profileTypeInfo, 74 JSTaggedValue receiver, JSTaggedValue key, 75 JSTaggedValue value, uint32_t slotId); 76 static inline JSTaggedValue LoadElement(JSObject *receiver, JSTaggedValue key); 77 static inline JSTaggedValue LoadStringElement(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); 78 static inline JSTaggedValue LoadTypedArrayElement(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); 79 static inline JSTaggedValue StoreElement(JSThread *thread, JSObject *receiver, JSTaggedValue key, 80 JSTaggedValue value, JSTaggedValue handlerInfo); 81 static inline JSTaggedValue StoreTypedArrayElement(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, 82 JSTaggedValue value); 83 static inline int64_t TryToElementsIndex(JSTaggedValue key); 84 static inline JSTaggedValue LoadMiss(JSThread *thread, ProfileTypeInfo *profileTypeInfo, JSTaggedValue receiver, 85 JSTaggedValue key, uint32_t slotId, ICKind kind); 86 static inline JSTaggedValue LoadValueMiss(JSThread *thread, ProfileTypeInfo *profileTypeInfo, 87 JSTaggedValue receiver, JSTaggedValue key, uint32_t slotId, ICKind kind); 88 static inline JSTaggedValue StoreMiss(JSThread *thread, ProfileTypeInfo *profileTypeInfo, JSTaggedValue receiver, 89 JSTaggedValue key, JSTaggedValue value, uint32_t slotId, 90 ICKind kind, bool isOwn = false); 91 }; 92 } // namespace panda::ecmascript 93 94 #endif // ECMASCRIPT_IC_IC_RUNTIME_STUB_H 95