1 /* 2 * Copyright (c) 2022 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 #ifndef ECMASCRIPT_COMPILER_IC_STUB_BUILDER_H 16 #define ECMASCRIPT_COMPILER_IC_STUB_BUILDER_H 17 #include "ecmascript/compiler/stub_builder.h" 18 19 namespace panda::ecmascript::kungfu { 20 class ICStubBuilder : public StubBuilder { 21 public: ICStubBuilder(StubBuilder * parent)22 explicit ICStubBuilder(StubBuilder *parent) 23 : StubBuilder(parent) {} 24 ~ICStubBuilder() = default; 25 NO_MOVE_SEMANTIC(ICStubBuilder); 26 NO_COPY_SEMANTIC(ICStubBuilder); GenerateCircuit()27 void GenerateCircuit() override {} 28 SetParameters(GateRef glue,GateRef receiver,GateRef profileTypeInfo,GateRef value,GateRef slotId)29 void SetParameters(GateRef glue, GateRef receiver, GateRef profileTypeInfo, 30 GateRef value, GateRef slotId) 31 { 32 glue_ = glue; 33 receiver_ = receiver; 34 profileTypeInfo_ = profileTypeInfo; 35 value_ = value; 36 slotId_ = slotId; 37 } 38 SetParameters(GateRef glue,GateRef receiver,GateRef profileTypeInfo,GateRef value,GateRef slotId,GateRef propKey)39 void SetParameters(GateRef glue, GateRef receiver, GateRef profileTypeInfo, 40 GateRef value, GateRef slotId, GateRef propKey) 41 { 42 SetParameters(glue, receiver, profileTypeInfo, value, slotId); 43 propKey_ = propKey; 44 } 45 46 void LoadICByName(Variable* result, Label* tryFastPath, Label *slowPath, Label *success); 47 void StoreICByName(Variable* result, Label* tryFastPath, Label *slowPath, Label *success); 48 void LoadICByValue(Variable* result, Label* tryFastPath, Label *slowPath, Label *success); 49 void StoreICByValue(Variable* result, Label* tryFastPath, Label *slowPath, Label *success); 50 void TryLoadGlobalICByName(Variable* result, Label* tryFastPath, Label *slowPath, Label *success); 51 void TryStoreGlobalICByName(Variable* result, Label* tryFastPath, Label *slowPath, Label *success); 52 private: 53 void NamedICAccessor(Variable* cachedHandler, Label *tryICHandler); 54 void ValuedICAccessor(Variable* cachedHandler, Label *tryICHandler, Label* tryElementIC); SetLabels(Label * tryFastPath,Label * slowPath,Label * success)55 void SetLabels(Label* tryFastPath, Label *slowPath, Label *success) 56 { 57 tryFastPath_ = tryFastPath; 58 slowPath_ = slowPath; 59 success_ = success; 60 } 61 62 GateRef glue_ {Circuit::NullGate()}; 63 GateRef receiver_ {0}; 64 GateRef profileTypeInfo_ {0}; 65 GateRef value_ {0}; 66 GateRef slotId_ {0}; 67 GateRef propKey_ {0}; 68 69 Label *tryFastPath_ {nullptr}; 70 Label *slowPath_ {nullptr}; 71 Label *success_ {nullptr}; 72 }; 73 } // namespace panda::ecmascript::kungfu 74 #endif // ECMASCRIPT_COMPILER_IC_STUB_BUILDER_H