1 /* 2 * Copyright (c) 2021 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_FASTSTUB_DEFINE_H 17 #define ECMASCRIPT_COMPILER_FASTSTUB_DEFINE_H 18 19 #include "ecmascript/base/config.h" 20 #include "interpreter_stub_define.h" 21 22 namespace panda::ecmascript::kungfu { 23 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 24 #define EXTERNAL_RUNTIMESTUB_LIST(V, I) \ 25 V(AddElementInternal, 5) \ 26 V(CallSetter, 5) \ 27 V(CallSetter2, 4) \ 28 V(CallGetter, 3) \ 29 V(CallGetter2, 4) \ 30 V(CallInternalGetter, 3) \ 31 V(ThrowTypeError, 2) \ 32 V(JSProxySetProperty, 6) \ 33 V(GetHash32, 2) \ 34 V(FindElementWithCache, 4) \ 35 V(StringGetHashCode, 1) \ 36 V(FloatMod, 2) \ 37 V(GetTaggedArrayPtrTest, 1) \ 38 V(NewInternalString, 2) \ 39 V(NewTaggedArray, 2) \ 40 V(CopyArray, 3) \ 41 V(NameDictPutIfAbsent, 7) \ 42 V(PropertiesSetValue, 6) \ 43 V(TaggedArraySetValue, 6) \ 44 V(NewEcmaDynClass, 4) \ 45 V(UpdateLayOutAndAddTransition, 5) \ 46 V(NoticeThroughChainAndRefreshUser, 3) \ 47 I(DebugPrint, 1) \ 48 V(InsertOldToNewRememberedSet, 3) \ 49 V(MarkingBarrier, 5) \ 50 V(JumpToCInterpreter, 7) \ 51 V(StGlobalRecord, 4) \ 52 V(SetFunctionNameNoPrefix, 3) \ 53 V(StOwnByValueWithNameSet, 4) \ 54 V(StOwnByName, 4) \ 55 V(StOwnByNameWithNameSet, 7) \ 56 V(SuspendGenerator, 7) \ 57 V(UpFrame, 1) \ 58 V(NegDyn, 2) \ 59 V(NotDyn, 2) \ 60 V(IncDyn, 2) \ 61 V(DecDyn, 2) \ 62 V(ChangeUintAndIntShrToJSTaggedValue, 3) \ 63 V(ChangeUintAndIntShlToJSTaggedValue, 3) \ 64 V(ChangeTwoInt32AndToJSTaggedValue, 3) \ 65 V(ChangeTwoInt32XorToJSTaggedValue, 3) \ 66 V(ChangeTwoInt32OrToJSTaggedValue, 3) \ 67 V(ChangeTwoUint32AndToJSTaggedValue, 3) \ 68 V(ExpDyn, 3) \ 69 V(IsInDyn, 3) \ 70 V(InstanceOfDyn, 3) \ 71 V(FastStrictEqual, 2) \ 72 V(FastStrictNotEqual, 2) \ 73 V(CreateGeneratorObj, 2) \ 74 V(ThrowConstAssignment, 2) \ 75 V(GetTemplateObject, 2) \ 76 V(GetNextPropName, 2) \ 77 V(ThrowIfNotObject, 1) \ 78 V(IterNext, 2) \ 79 V(CloseIterator, 2) \ 80 V(CopyModule, 2) \ 81 V(SuperCallSpread, 4) \ 82 V(DelObjProp, 3) \ 83 V(NewObjSpreadDyn, 4) \ 84 V(CreateIterResultObj, 3) \ 85 V(AsyncFunctionAwaitUncaught, 3) \ 86 V(AsyncFunctionResolveOrReject, 4) \ 87 V(ThrowUndefinedIfHole, 2) \ 88 V(CopyDataProperties, 3) \ 89 V(StArraySpread, 4) \ 90 V(GetIteratorNext, 3) \ 91 V(SetObjectWithProto, 3) \ 92 V(LoadICByValue, 5) \ 93 V(StoreICByValue, 6) \ 94 V(StOwnByValue, 4) \ 95 V(LdSuperByValue, 4) \ 96 V(StSuperByValue, 5) \ 97 V(LdObjByIndex, 5) \ 98 V(StObjByIndex, 4) \ 99 V(StOwnByIndex, 4) \ 100 V(ResolveClass, 6) \ 101 V(CloneClassFromTemplate, 5) \ 102 V(SetClassConstructorLength, 3) \ 103 V(LoadICByName, 5) \ 104 V(StoreICByName, 6) \ 105 V(UpdateHotnessCounter, 2) \ 106 V(ImportModule, 2) \ 107 V(StModuleVar, 3) \ 108 V(LdModvarByName, 3) \ 109 V(ThrowDyn, 2) \ 110 V(GetPropIterator, 2) \ 111 V(AsyncFunctionEnter, 1) \ 112 V(GetIterator, 2) \ 113 V(ThrowThrowNotExists, 1) \ 114 V(ThrowPatternNonCoercible, 1) \ 115 V(ThrowDeleteSuperProperty, 1) \ 116 V(EqDyn, 3) \ 117 V(LdGlobalRecord, 2) \ 118 V(GetGlobalOwnProperty, 2) \ 119 V(TryLdGlobalByName, 2) \ 120 V(LoadMiss, 6) \ 121 V(StoreMiss, 7) \ 122 V(TryUpdateGlobalRecord, 3) \ 123 V(ThrowReferenceError, 2) \ 124 V(StGlobalVar, 3) \ 125 V(LdGlobalVar, 3) \ 126 V(ToNumber, 2) \ 127 V(ToBoolean, 1) \ 128 V(NotEqDyn, 3) \ 129 V(LessDyn, 3) \ 130 V(LessEqDyn, 3) \ 131 V(GreaterDyn, 3) \ 132 V(GreaterEqDyn, 3) \ 133 V(Add2Dyn, 3) \ 134 V(Sub2Dyn, 3) \ 135 V(Mul2Dyn, 3) \ 136 V(Div2Dyn, 3) \ 137 V(Mod2Dyn, 3) \ 138 I(CallRuntimeTrampoline, 4) 139 140 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 141 142 #define FAST_STUB_LIST(V) \ 143 V(FastAdd, 2) \ 144 V(FastSub, 2) \ 145 V(FastMul, 2) \ 146 V(FastDiv, 2) \ 147 V(FastMod, 3) \ 148 V(FastEqual, 2) \ 149 V(FastTypeOf, 2) \ 150 V(GetPropertyByName, 3) \ 151 V(SetPropertyByName, 4) \ 152 V(SetPropertyByNameWithOwn, 4) \ 153 V(GetPropertyByIndex, 3) \ 154 V(SetPropertyByIndex, 4) \ 155 V(GetPropertyByValue, 3) \ 156 V(SetPropertyByValue, 4) \ 157 V(TryLoadICByName, 4) \ 158 V(TryLoadICByValue, 5) \ 159 V(TryStoreICByName, 5) \ 160 V(TryStoreICByValue, 6) 161 162 #if ECMASCRIPT_COMPILE_INTERPRETER_ASM 163 #define FAST_RUNTIME_STUB_LIST(V) \ 164 FAST_STUB_LIST(V) \ 165 INTERPRETER_STUB_HELPER_LIST(V) 166 #else 167 #define FAST_RUNTIME_STUB_LIST(V) \ 168 FAST_STUB_LIST(V) 169 #endif 170 171 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 172 #define TEST_FUNC_LIST(V) \ 173 V(PhiGateTest, 1) \ 174 V(FastMulGCTest, 3) \ 175 V(LoopTest, 1) \ 176 V(LoopTest1, 1) \ 177 V(TestAbsoluteAddressRelocation, 2) 178 179 #define CALL_STUB_LIST(V) \ 180 FAST_RUNTIME_STUB_LIST(V) \ 181 EXTERNAL_RUNTIMESTUB_LIST(V, V) \ 182 V(BytecodeHandler, 7) 183 184 enum FastStubId { 185 #define DEF_STUB(name, counter) name##Id, 186 FAST_RUNTIME_STUB_LIST(DEF_STUB) FAST_STUB_MAXCOUNT, 187 #undef DEF_STUB 188 }; 189 190 enum ExternalRuntimeStubId { 191 #define DEF_STUB(name, counter) name##Id, 192 EXTERNAL_RUNTIMESTUB_LIST(DEF_STUB, DEF_STUB) EXTERNAL_RUNTIME_STUB_MAXCOUNT, 193 #undef DEF_STUB 194 }; 195 196 #ifndef NDEBUG 197 enum TestFuncStubId { 198 #define DEF_STUB(name, counter) name##Id, 199 TEST_FUNC_LIST(DEF_STUB) TEST_FUNC_MAXCOUNT, 200 #undef DEF_STUB 201 }; 202 #endif 203 204 enum CallStubId { 205 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 206 #define DEF_STUB(name, counter) NAME_##name, 207 CALL_STUB_LIST(DEF_STUB) 208 #undef DEF_STUB 209 #ifndef NDEBUG 210 TEST_FUNC_OFFSET, 211 TEST_FUNC_BEGIN = TEST_FUNC_OFFSET - 1, 212 #define DEF_STUB(name, counter) NAME_##name, 213 TEST_FUNC_LIST(DEF_STUB) 214 #undef DEF_STUB 215 #endif 216 CALL_STUB_MAXCOUNT, 217 }; 218 219 enum StubId { 220 #define DEF_STUB(name, counter) STUB_##name, 221 FAST_RUNTIME_STUB_LIST(DEF_STUB) 222 #if ECMASCRIPT_COMPILE_INTERPRETER_ASM 223 INTERPRETER_STUB_LIST(DEF_STUB) 224 #endif 225 #undef DEF_STUB 226 ALL_STUB_MAXCOUNT 227 }; 228 229 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 230 #define TEST_STUB_ID(name) panda::ecmascript::kungfu::TestFuncStubId::name##Id 231 #define FAST_STUB_ID(name) panda::ecmascript::kungfu::CallStubId::NAME_##name 232 #define STUB_ID(name) panda::ecmascript::kungfu::StubId::STUB_##name 233 } // namespace panda::ecmascript::kungfu 234 #endif // ECMASCRIPT_COMPILER_FASTSTUB_DEFINE_H 235