1 /* 2 * Copyright (c) 2024 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_COMPILER_COMMON_STUB_CSIGNS_H 17 #define ECMASCRIPT_COMPILER_COMMON_STUB_CSIGNS_H 18 19 #include "ecmascript/compiler/call_signature.h" 20 21 namespace panda::ecmascript::kungfu { 22 #define COMMON_STUB_LIST(V) \ 23 V(Add) \ 24 V(Sub) \ 25 V(Mul) \ 26 V(Div) \ 27 V(Mod) \ 28 V(Equal) \ 29 V(NotEqual) \ 30 V(StrictEqual) \ 31 V(StrictNotEqual) \ 32 V(Less) \ 33 V(LessEq) \ 34 V(Greater) \ 35 V(GreaterEq) \ 36 V(Shl) \ 37 V(Shr) \ 38 V(Ashr) \ 39 V(And) \ 40 V(Or) \ 41 V(Xor) \ 42 V(IsIn) \ 43 V(Instanceof) \ 44 V(TypeOf) \ 45 V(Inc) \ 46 V(Dec) \ 47 V(Neg) \ 48 V(Not) \ 49 V(ToBooleanTrue) \ 50 V(ToBooleanFalse) \ 51 V(JSTaggedValueHasProperty) \ 52 V(GetPropertyByName) \ 53 V(SetPropertyByNameWithMega) \ 54 V(GetPropertyByNameWithMega) \ 55 V(DeprecatedGetPropertyByName) \ 56 V(SetPropertyByName) \ 57 V(DeprecatedSetPropertyByName) \ 58 V(SetPropertyByNameWithOwn) \ 59 V(GetPropertyByIndex) \ 60 V(SetPropertyByIndex) \ 61 V(SetPropertyByIndexWithOwn) \ 62 V(GetPropertyByValue) \ 63 V(DeprecatedGetPropertyByValue) \ 64 V(SetPropertyByValue) \ 65 V(DeprecatedSetPropertyByValue) \ 66 V(TryLdGlobalByName) \ 67 V(TryStGlobalByName) \ 68 V(LdGlobalVar) \ 69 V(LdObjByIndex) \ 70 V(StGlobalVar) \ 71 V(StObjByIndex) \ 72 V(StOwnByIndex) \ 73 V(StOwnByName) \ 74 V(StOwnByNameWithNameSet) \ 75 V(StOwnByValue) \ 76 V(StOwnByValueWithNameSet) \ 77 V(SetPropertyByValueWithOwn) \ 78 V(TryLoadICByName) \ 79 V(TryLoadICByValue) \ 80 V(TryStoreICByName) \ 81 V(TryStoreICByValue) \ 82 V(SetValueWithBarrier) \ 83 V(SetNonSValueWithBarrier) \ 84 V(SetSValueWithBarrier) \ 85 V(NewLexicalEnv) \ 86 V(CopyRestArgs) \ 87 V(GetUnmappedArgs) \ 88 V(GetCallSpreadArgs) \ 89 V(NewThisObjectChecked) \ 90 V(ConstructorCheck) \ 91 V(CreateEmptyArray) \ 92 V(CreateArrayWithBuffer) \ 93 V(CreateObjectHavingMethod) \ 94 V(NewJSObject) \ 95 V(JsBoundCallInternal) \ 96 V(CreateStringBySingleCharCode) \ 97 V(Getpropiterator) \ 98 V(Getnextpropname) \ 99 V(CreateJSSetIterator) \ 100 V(JSSetEntries) \ 101 V(CreateJSMapIterator) \ 102 V(JSMapKeys) \ 103 V(JSMapValues) \ 104 V(JSMapGet) \ 105 V(JSMapHas) \ 106 V(JSSetHas) \ 107 V(JSSetAdd) \ 108 V(CreateJSTypedArrayEntries) \ 109 V(CreateJSTypedArrayKeys) \ 110 V(CreateJSTypedArrayValues) \ 111 V(JSMapDelete) \ 112 V(JSSetDelete) \ 113 V(GetSingleCharCodeByIndex) \ 114 V(FastStringEqual) \ 115 V(FastStringAdd) \ 116 V(StringAdd) \ 117 V(Definefunc) \ 118 V(DefineField) \ 119 V(CallArg0Stub) \ 120 V(CallArg1Stub) \ 121 V(CallArg2Stub) \ 122 V(CallArg3Stub) \ 123 V(CallThis0Stub) \ 124 V(CallThis1Stub) \ 125 V(CallThis2Stub) \ 126 V(CallThis3Stub) \ 127 V(ConvertCharToInt32) \ 128 V(ConvertCharToDouble) \ 129 V(DeleteObjectProperty) \ 130 V(SameValue) \ 131 V(StringIteratorNext) \ 132 V(ArrayIteratorNext) \ 133 V(MapIteratorNext) \ 134 V(SetIteratorNext) \ 135 V(GetIterator) \ 136 V(GrowElementsCapacity) \ 137 V(BatchBarrier) \ 138 V(VerifyBarrier) \ 139 V(MoveBarrierInRegion) \ 140 V(MoveBarrierCrossRegion) \ 141 V(FindEntryFromNameDictionary) \ 142 V(ReverseBarrier) 143 144 #define COMMON_STUB_ID_LIST(V) \ 145 COMMON_STUB_LIST(V) 146 147 class CommonStubCSigns { 148 public: 149 enum ID { 150 #define DEF_STUB_ID(name) name, 151 COMMON_STUB_ID_LIST(DEF_STUB_ID) 152 #undef DEF_STUB_ID 153 NUM_OF_STUBS 154 }; 155 156 static void Initialize(); 157 158 static void GetCSigns(std::vector<const CallSignature*>& callSigns); 159 Get(size_t index)160 static const CallSignature *Get(size_t index) 161 { 162 ASSERT(index < NUM_OF_STUBS); 163 return &callSigns_[index]; 164 } 165 GetName(size_t index)166 static const std::string &GetName(size_t index) 167 { 168 ASSERT(index < NUM_OF_STUBS); 169 return callSigns_[index].GetName(); 170 } 171 172 private: 173 static CallSignature callSigns_[NUM_OF_STUBS]; 174 }; 175 } // namespace panda::ecmascript::kungfu 176 #endif // ECMASCRIPT_COMPILER_COMMON_STUB_CSIGNS_H 177