14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_IC_IC_RUNTIME_H 174514f5e3Sopenharmony_ci#define ECMASCRIPT_IC_IC_RUNTIME_H 184514f5e3Sopenharmony_ci 194514f5e3Sopenharmony_ci#include "ecmascript/ic/profile_type_info.h" 204514f5e3Sopenharmony_ci#include "ecmascript/accessor_data.h" 214514f5e3Sopenharmony_ci#include "ecmascript/ecma_vm.h" 224514f5e3Sopenharmony_ci#include "ecmascript/js_tagged_value.h" 234514f5e3Sopenharmony_ci#include "ecmascript/js_handle.h" 244514f5e3Sopenharmony_ci#include "ecmascript/object_operator.h" 254514f5e3Sopenharmony_ci 264514f5e3Sopenharmony_cinamespace panda::ecmascript { 274514f5e3Sopenharmony_ciclass ProfileTypeInfo; 284514f5e3Sopenharmony_ciclass JSThread; 294514f5e3Sopenharmony_ciclass ObjectOperator; 304514f5e3Sopenharmony_ci 314514f5e3Sopenharmony_ciclass ICRuntime { 324514f5e3Sopenharmony_cipublic: 334514f5e3Sopenharmony_ci ICRuntime(JSThread *thread, JSHandle<ProfileTypeInfo> profileTypeInfo, uint32_t slotId, ICKind kind) 344514f5e3Sopenharmony_ci : thread_(thread), icAccessor_(thread, profileTypeInfo, slotId, kind) 354514f5e3Sopenharmony_ci { 364514f5e3Sopenharmony_ci } 374514f5e3Sopenharmony_ci 384514f5e3Sopenharmony_ci ~ICRuntime() = default; 394514f5e3Sopenharmony_ci 404514f5e3Sopenharmony_ci void UpdateLoadHandler(const ObjectOperator &op, JSHandle<JSTaggedValue> key, JSHandle<JSTaggedValue> receiver); 414514f5e3Sopenharmony_ci void UpdateLoadStringHandler(JSHandle<JSTaggedValue> receiver); 424514f5e3Sopenharmony_ci void UpdateTypedArrayHandler(JSHandle<JSTaggedValue> receiver); 434514f5e3Sopenharmony_ci void UpdateStoreHandler(const ObjectOperator &op, JSHandle<JSTaggedValue> key, JSHandle<JSTaggedValue> receiver); 444514f5e3Sopenharmony_ci 454514f5e3Sopenharmony_ci JSThread *GetThread() const 464514f5e3Sopenharmony_ci { 474514f5e3Sopenharmony_ci return thread_; 484514f5e3Sopenharmony_ci } 494514f5e3Sopenharmony_ci 504514f5e3Sopenharmony_ci void UpdateReceiverHClass(JSHandle<JSTaggedValue> receiverHClass) 514514f5e3Sopenharmony_ci { 524514f5e3Sopenharmony_ci receiverHClass_ = receiverHClass; 534514f5e3Sopenharmony_ci } 544514f5e3Sopenharmony_ci 554514f5e3Sopenharmony_ci ICKind GetICKind() const 564514f5e3Sopenharmony_ci { 574514f5e3Sopenharmony_ci return icAccessor_.GetKind(); 584514f5e3Sopenharmony_ci } 594514f5e3Sopenharmony_ci 604514f5e3Sopenharmony_ci void TraceIC(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key) const; 614514f5e3Sopenharmony_ci 624514f5e3Sopenharmony_ciprotected: 634514f5e3Sopenharmony_ci JSThread *thread_; 644514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> receiverHClass_{}; 654514f5e3Sopenharmony_ci ProfileTypeAccessor icAccessor_; 664514f5e3Sopenharmony_ci}; 674514f5e3Sopenharmony_ci 684514f5e3Sopenharmony_ciclass LoadICRuntime : public ICRuntime { 694514f5e3Sopenharmony_cipublic: 704514f5e3Sopenharmony_ci LoadICRuntime(JSThread *thread, JSHandle<ProfileTypeInfo> profileTypeInfo, uint32_t slotId, ICKind kind) 714514f5e3Sopenharmony_ci : ICRuntime(thread, profileTypeInfo, slotId, kind) 724514f5e3Sopenharmony_ci { 734514f5e3Sopenharmony_ci } 744514f5e3Sopenharmony_ci 754514f5e3Sopenharmony_ci ~LoadICRuntime() = default; 764514f5e3Sopenharmony_ci 774514f5e3Sopenharmony_ci JSTaggedValue LoadMiss(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key); 784514f5e3Sopenharmony_ci JSTaggedValue LoadValueMiss(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key); 794514f5e3Sopenharmony_ci JSTaggedValue LoadTypedArrayValueMiss(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key); 804514f5e3Sopenharmony_ciprivate: 814514f5e3Sopenharmony_ci JSTaggedValue LoadOrdinaryGet(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key); 824514f5e3Sopenharmony_ci inline JSTaggedValue CallPrivateGetter(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key); 834514f5e3Sopenharmony_ci}; 844514f5e3Sopenharmony_ci 854514f5e3Sopenharmony_ciclass StoreICRuntime : public ICRuntime { 864514f5e3Sopenharmony_cipublic: 874514f5e3Sopenharmony_ci StoreICRuntime(JSThread *thread, JSHandle<ProfileTypeInfo> profileTypeInfo, uint32_t slotId, ICKind kind) 884514f5e3Sopenharmony_ci : ICRuntime(thread, profileTypeInfo, slotId, kind) 894514f5e3Sopenharmony_ci { 904514f5e3Sopenharmony_ci } 914514f5e3Sopenharmony_ci 924514f5e3Sopenharmony_ci ~StoreICRuntime() = default; 934514f5e3Sopenharmony_ci 944514f5e3Sopenharmony_ci JSTaggedValue StoreMiss(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key, 954514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value, bool isOwn = false); 964514f5e3Sopenharmony_ci 974514f5e3Sopenharmony_ci JSTaggedValue StoreTypedArrayValueMiss(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key, 984514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value); 994514f5e3Sopenharmony_ciprivate: 1004514f5e3Sopenharmony_ci inline JSTaggedValue CallPrivateSetter(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key, 1014514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value); 1024514f5e3Sopenharmony_ci}; 1034514f5e3Sopenharmony_ci} // namespace panda::ecmascript 1044514f5e3Sopenharmony_ci 1054514f5e3Sopenharmony_ci#endif // ECMASCRIPT_IC_IC_RUNTIME_H 106