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_INVOKE_CACHE_H 17 #define ECMASCRIPT_IC_INVOKE_CACHE_H 18 19 #include "ecmascript/ic/profile_type_info.h" 20 #include "ecmascript/js_tagged_value.h" 21 22 namespace panda::ecmascript { 23 class InvokeCache { 24 public: 25 static constexpr size_t MONO_CASE_NUM = 2; 26 static constexpr size_t POLY_CASE_NUM = 4; 27 28 static bool SetMonoConstuctCacheSlot(JSThread *thread, ProfileTypeInfo *profileTypeInfo, uint32_t slotId, 29 JSTaggedValue newTarget, JSTaggedValue initialHClass); 30 31 static bool SetPolyConstuctCacheSlot(JSThread *thread, ProfileTypeInfo *profileTypeInfo, uint32_t slotId, 32 uint8_t length, JSTaggedValue newTargetArray, 33 JSTaggedValue initialHClassArray); 34 35 static JSTaggedValue CheckPolyInvokeCache(JSTaggedValue cachedArray, JSTaggedValue func); 36 37 static JSTaggedValue Construct(JSThread *thread, JSTaggedValue firstValue, JSTaggedValue secondValue, 38 JSTaggedValue ctor, JSTaggedValue newTarget, uint16_t firstArgIdx, 39 uint16_t length); 40 41 static bool SetMonoInlineCallCacheSlot(JSThread *thread, ProfileTypeInfo *profileTypeInfo, uint32_t slotId, 42 JSTaggedValue callee); 43 44 static bool SetPolyInlineCallCacheSlot(JSThread *thread, ProfileTypeInfo *profileTypeInfo, uint32_t slotId, 45 uint8_t length, JSTaggedValue calleeArray); 46 47 static bool DecideCanBeInlined(Method *method); 48 }; 49 } // namespace panda::ecmascript 50 51 #endif // ECMASCRIPT_IC_INVOKE_CACHE_H 52