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_RUNTIME_STUBS_H 17 #define ECMASCRIPT_RUNTIME_STUBS_H 18 19 #include "ecmascript/compiler/call_signature.h" 20 #include "ecmascript/frames.h" 21 #include "ecmascript/stubs/test_runtime_stubs.h" 22 #include "ecmascript/ecma_macros.h" 23 #include "ecmascript/js_tagged_value.h" 24 #include "ecmascript/method.h" 25 #include "ecmascript/mem/region.h" 26 27 namespace panda::ecmascript { 28 using kungfu::CallSignature; 29 class EcmaVM; 30 class GlobalEnv; 31 class JSThread; 32 class JSFunction; 33 class ObjectFactory; 34 class JSBoundFunction; 35 class JSProxy; 36 37 class GeneratorContext; 38 struct EcmaRuntimeCallInfo; 39 40 using JSFunctionEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, const JSTaggedType argV[], 41 uintptr_t prevFp, bool needPushUndefined); 42 using FastCallAotEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, const JSTaggedType argV[], 43 uintptr_t prevFp); 44 45 #define RUNTIME_ASM_STUB_LIST(V) \ 46 JS_CALL_TRAMPOLINE_LIST(V) \ 47 FAST_CALL_TRAMPOLINE_LIST(V) \ 48 ASM_INTERPRETER_TRAMPOLINE_LIST(V) 49 50 #define ASM_INTERPRETER_TRAMPOLINE_LIST(V) \ 51 V(AsmInterpreterEntry) \ 52 V(GeneratorReEnterAsmInterp) \ 53 V(PushCallArgsAndDispatchNative) \ 54 V(PushCallArg0AndDispatch) \ 55 V(PushCallArg1AndDispatch) \ 56 V(PushCallArgs2AndDispatch) \ 57 V(PushCallArgs3AndDispatch) \ 58 V(PushCallThisArg0AndDispatch) \ 59 V(PushCallThisArg1AndDispatch) \ 60 V(PushCallThisArgs2AndDispatch) \ 61 V(PushCallThisArgs3AndDispatch) \ 62 V(PushCallRangeAndDispatch) \ 63 V(PushCallNewAndDispatch) \ 64 V(PushCallNewAndDispatchNative) \ 65 V(PushCallRangeAndDispatchNative) \ 66 V(PushCallThisRangeAndDispatch) \ 67 V(ResumeRspAndDispatch) \ 68 V(ResumeRspAndReturn) \ 69 V(ResumeCaughtFrameAndDispatch) \ 70 V(ResumeUncaughtFrameAndReturn) \ 71 V(CallSetter) \ 72 V(CallGetter) \ 73 V(CallContainersArgs3) \ 74 V(CallReturnWithArgv) 75 76 #define JS_CALL_TRAMPOLINE_LIST(V) \ 77 V(CallRuntime) \ 78 V(CallRuntimeWithArgv) \ 79 V(JSFunctionEntry) \ 80 V(JSCall) \ 81 V(JSCallWithArgV) \ 82 V(JSCallWithArgVAndPushUndefined) \ 83 V(JSProxyCallInternalWithArgV) \ 84 V(OptimizedCallAndPushUndefined) \ 85 V(DeoptHandlerAsm) \ 86 V(JSCallNew) \ 87 V(CallOptimized) 88 89 #define FAST_CALL_TRAMPOLINE_LIST(V) \ 90 V(OptimizedFastCallEntry) \ 91 V(OptimizedFastCallAndPushUndefined) \ 92 V(JSFastCallWithArgV) \ 93 V(JSFastCallWithArgVAndPushUndefined) 94 95 96 #define RUNTIME_STUB_WITHOUT_GC_LIST(V) \ 97 V(DebugPrint) \ 98 V(DebugPrintInstruction) \ 99 V(ProfileCall) \ 100 V(ProfileDefineClass) \ 101 V(ProfileCreateObject) \ 102 V(ProfileOpType) \ 103 V(ProfileObjLayout) \ 104 V(Comment) \ 105 V(FatalPrint) \ 106 V(GetActualArgvNoGC) \ 107 V(InsertOldToNewRSet) \ 108 V(MarkingBarrier) \ 109 V(StoreBarrier) \ 110 V(DoubleToInt) \ 111 V(FloatMod) \ 112 V(FloatSqrt) \ 113 V(FloatCos) \ 114 V(FloatSin) \ 115 V(FloatACos) \ 116 V(FloatATan) \ 117 V(FloatFloor) \ 118 V(FindElementWithCache) \ 119 V(CreateArrayFromList) \ 120 V(StringsAreEquals) \ 121 V(BigIntEquals) \ 122 V(TimeClip) \ 123 V(SetDateValues) \ 124 V(StartCallTimer) \ 125 V(EndCallTimer) 126 127 #define RUNTIME_STUB_WITH_GC_LIST(V) \ 128 V(AddElementInternal) \ 129 V(AllocateInYoung) \ 130 V(CallInternalGetter) \ 131 V(CallInternalSetter) \ 132 V(CallGetPrototype) \ 133 V(ThrowTypeError) \ 134 V(Dump) \ 135 V(GetHash32) \ 136 V(ComputeHashcode) \ 137 V(GetTaggedArrayPtrTest) \ 138 V(NewInternalString) \ 139 V(NewTaggedArray) \ 140 V(CopyArray) \ 141 V(NameDictPutIfAbsent) \ 142 V(PropertiesSetValue) \ 143 V(TaggedArraySetValue) \ 144 V(CheckAndCopyArray) \ 145 V(NewEcmaHClass) \ 146 V(UpdateLayOutAndAddTransition) \ 147 V(CopyAndUpdateObjLayout) \ 148 V(UpdateHClassForElementsKind) \ 149 V(NoticeThroughChainAndRefreshUser) \ 150 V(JumpToCInterpreter) \ 151 V(StGlobalRecord) \ 152 V(SetFunctionNameNoPrefix) \ 153 V(StOwnByValueWithNameSet) \ 154 V(StOwnByName) \ 155 V(StOwnByNameWithNameSet) \ 156 V(SuspendGenerator) \ 157 V(UpFrame) \ 158 V(Neg) \ 159 V(Not) \ 160 V(Inc) \ 161 V(Dec) \ 162 V(Shl2) \ 163 V(Shr2) \ 164 V(Ashr2) \ 165 V(Or2) \ 166 V(Xor2) \ 167 V(And2) \ 168 V(Exp) \ 169 V(IsIn) \ 170 V(InstanceOf) \ 171 V(CreateGeneratorObj) \ 172 V(ThrowConstAssignment) \ 173 V(GetTemplateObject) \ 174 V(GetNextPropName) \ 175 V(ThrowIfNotObject) \ 176 V(IterNext) \ 177 V(CloseIterator) \ 178 V(SuperCallSpread) \ 179 V(OptSuperCallSpread) \ 180 V(DelObjProp) \ 181 V(NewObjApply) \ 182 V(CreateIterResultObj) \ 183 V(AsyncFunctionAwaitUncaught) \ 184 V(AsyncFunctionResolveOrReject) \ 185 V(ThrowUndefinedIfHole) \ 186 V(CopyDataProperties) \ 187 V(StArraySpread) \ 188 V(GetIteratorNext) \ 189 V(SetObjectWithProto) \ 190 V(LoadICByValue) \ 191 V(StoreICByValue) \ 192 V(StOwnByValue) \ 193 V(LdSuperByValue) \ 194 V(StSuperByValue) \ 195 V(LdObjByIndex) \ 196 V(StObjByIndex) \ 197 V(StOwnByIndex) \ 198 V(CreateClassWithBuffer) \ 199 V(SetClassConstructorLength) \ 200 V(LoadICByName) \ 201 V(StoreICByName) \ 202 V(UpdateHotnessCounter) \ 203 V(CheckSafePoint) \ 204 V(UpdateHotnessCounterWithProf) \ 205 V(GetModuleNamespaceByIndex) \ 206 V(GetModuleNamespaceByIndexOnJSFunc) \ 207 V(GetModuleNamespace) \ 208 V(StModuleVarByIndex) \ 209 V(StModuleVarByIndexOnJSFunc) \ 210 V(StModuleVar) \ 211 V(LdLocalModuleVarByIndex) \ 212 V(LdExternalModuleVarByIndex) \ 213 V(LdLocalModuleVarByIndexOnJSFunc) \ 214 V(LdExternalModuleVarByIndexOnJSFunc) \ 215 V(LdModuleVar) \ 216 V(Throw) \ 217 V(GetPropIterator) \ 218 V(AsyncFunctionEnter) \ 219 V(GetIterator) \ 220 V(GetAsyncIterator) \ 221 V(SetGeneratorState) \ 222 V(ThrowThrowNotExists) \ 223 V(ThrowPatternNonCoercible) \ 224 V(ThrowDeleteSuperProperty) \ 225 V(Eq) \ 226 V(TryLdGlobalICByName) \ 227 V(LoadMiss) \ 228 V(StoreMiss) \ 229 V(TryUpdateGlobalRecord) \ 230 V(ThrowReferenceError) \ 231 V(StGlobalVar) \ 232 V(LdGlobalICVar) \ 233 V(ToNumber) \ 234 V(ToBoolean) \ 235 V(NotEq) \ 236 V(Less) \ 237 V(LessEq) \ 238 V(Greater) \ 239 V(GreaterEq) \ 240 V(Add2) \ 241 V(Sub2) \ 242 V(Mul2) \ 243 V(Div2) \ 244 V(Mod2) \ 245 V(CreateEmptyObject) \ 246 V(CreateEmptyArray) \ 247 V(GetSymbolFunction) \ 248 V(GetUnmapedArgs) \ 249 V(CopyRestArgs) \ 250 V(CreateArrayWithBuffer) \ 251 V(CreateObjectWithBuffer) \ 252 V(NewThisObject) \ 253 V(NewObjRange) \ 254 V(DefineFunc) \ 255 V(CreateRegExpWithLiteral) \ 256 V(ThrowIfSuperNotCorrectCall) \ 257 V(CreateObjectHavingMethod) \ 258 V(CreateObjectWithExcludedKeys) \ 259 V(DefineMethod) \ 260 V(ThrowSetterIsUndefinedException) \ 261 V(ThrowNotCallableException) \ 262 V(ThrowCallConstructorException) \ 263 V(ThrowNonConstructorException) \ 264 V(ThrowStackOverflowException) \ 265 V(ThrowDerivedMustReturnException) \ 266 V(CallSpread) \ 267 V(DefineGetterSetterByValue) \ 268 V(SuperCall) \ 269 V(OptSuperCall) \ 270 V(LdBigInt) \ 271 V(ToNumeric) \ 272 V(DynamicImport) \ 273 V(CreateAsyncGeneratorObj) \ 274 V(AsyncGeneratorResolve) \ 275 V(AsyncGeneratorReject) \ 276 V(NewLexicalEnvWithName) \ 277 V(OptGetUnmapedArgs) \ 278 V(OptCopyRestArgs) \ 279 V(NotifyBytecodePcChanged) \ 280 V(NotifyDebuggerStatement) \ 281 V(OptNewLexicalEnvWithName) \ 282 V(OptSuspendGenerator) \ 283 V(OptAsyncGeneratorResolve) \ 284 V(OptCreateObjectWithExcludedKeys) \ 285 V(OptNewObjRange) \ 286 V(GetTypeArrayPropertyByIndex) \ 287 V(SetTypeArrayPropertyByIndex) \ 288 V(FastCopyElementToArray) \ 289 V(JSObjectGetMethod) \ 290 V(DebugAOTPrint) \ 291 V(ProfileOptimizedCode) \ 292 V(VerifyVTableLoading) \ 293 V(VerifyVTableStoring) \ 294 V(GetMethodFromCache) \ 295 V(GetArrayLiteralFromCache) \ 296 V(GetObjectLiteralFromCache) \ 297 V(GetStringFromCache) \ 298 V(OptLdSuperByValue) \ 299 V(OptStSuperByValue) \ 300 V(BigIntEqual) \ 301 V(StringEqual) \ 302 V(LdPatchVar) \ 303 V(StPatchVar) \ 304 V(DeoptHandler) \ 305 V(ContainerRBTreeForEach) \ 306 V(SlowFlattenString) \ 307 V(NotifyConcurrentResult) \ 308 V(OtherToNumber) \ 309 V(AotInlineTrace) \ 310 V(LocaleCompare) 311 312 #define RUNTIME_STUB_LIST(V) \ 313 RUNTIME_ASM_STUB_LIST(V) \ 314 RUNTIME_STUB_WITHOUT_GC_LIST(V) \ 315 RUNTIME_STUB_WITH_GC_LIST(V) \ 316 TEST_RUNTIME_STUB_GC_LIST(V) 317 318 class RuntimeStubs { 319 public: 320 static void Initialize(JSThread *thread); 321 322 #define DECLARE_RUNTIME_STUBS(name) \ 323 static JSTaggedType name(uintptr_t argGlue, uint32_t argc, uintptr_t argv); 324 RUNTIME_STUB_WITH_GC_LIST(DECLARE_RUNTIME_STUBS) TEST_RUNTIME_STUB_GC_LIST(DECLARE_RUNTIME_STUBS)325 TEST_RUNTIME_STUB_GC_LIST(DECLARE_RUNTIME_STUBS) 326 #undef DECLARE_RUNTIME_STUBS 327 328 inline static JSTaggedType GetTArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index) 329 { 330 ASSERT(index < argc); 331 return *(reinterpret_cast<JSTaggedType *>(argv) + (index)); 332 } 333 GetArg(uintptr_t argv,uint32_t argc,uint32_t index)334 inline static JSTaggedValue GetArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index) 335 { 336 ASSERT(index < argc); 337 return JSTaggedValue(*(reinterpret_cast<JSTaggedType *>(argv) + (index))); 338 } 339 340 template<typename T> GetHArg(uintptr_t argv,uint32_t argc,uint32_t index)341 inline static JSHandle<T> GetHArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index) 342 { 343 ASSERT(index < argc); 344 return JSHandle<T>(&(reinterpret_cast<JSTaggedType *>(argv)[index])); 345 } 346 347 template<typename T> GetPtrArg(uintptr_t argv,uint32_t argc,uint32_t index)348 inline static T *GetPtrArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index) 349 { 350 ASSERT(index < argc); 351 return reinterpret_cast<T*>(*(reinterpret_cast<JSTaggedType *>(argv) + (index))); 352 } 353 354 static void DebugPrint(int fmtMessageId, ...); 355 static void DebugPrintInstruction([[maybe_unused]] uintptr_t argGlue, const uint8_t *pc); 356 static void Comment(uintptr_t argStr); 357 static void ProfileCall(uintptr_t argGlue, uintptr_t func, uintptr_t target, int32_t pcOffset, uint32_t incCount); 358 static void ProfileDefineClass(uintptr_t argGlue, uintptr_t func, int32_t offset, uintptr_t ctor); 359 static void ProfileCreateObject( 360 uintptr_t argGlue, JSTaggedType func, int32_t offset, JSTaggedType newObj, int32_t traceId); 361 static void ProfileOpType(uintptr_t argGlue, uintptr_t func, int32_t offset, int32_t type); 362 static void ProfileObjLayout(uintptr_t argGlue, uintptr_t func, int32_t offset, uintptr_t object, int32_t store); 363 static void FatalPrint(int fmtMessageId, ...); 364 static void MarkingBarrier([[maybe_unused]] uintptr_t argGlue, 365 uintptr_t object, size_t offset, TaggedObject *value); 366 static void StoreBarrier([[maybe_unused]] uintptr_t argGlue, 367 uintptr_t object, size_t offset, TaggedObject *value); 368 static JSTaggedType CreateArrayFromList([[maybe_unused]] uintptr_t argGlue, int32_t argc, JSTaggedValue *argvPtr); 369 static JSTaggedType GetActualArgvNoGC(uintptr_t argGlue); 370 static void InsertOldToNewRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset); 371 static int32_t DoubleToInt(double x); 372 static double FloatMod(double x, double y); 373 static JSTaggedType FloatSqrt(double x); 374 static JSTaggedType FloatCos(double x); 375 static JSTaggedType FloatSin(double x); 376 static JSTaggedType FloatACos(double x); 377 static JSTaggedType FloatATan(double x); 378 static JSTaggedType FloatFloor(double x); 379 static int32_t FindElementWithCache(uintptr_t argGlue, JSTaggedType hclass, 380 JSTaggedType key, int32_t num); 381 static bool StringsAreEquals(EcmaString *str1, EcmaString *str2); 382 static bool BigIntEquals(JSTaggedType left, JSTaggedType right); 383 static double TimeClip(double time); 384 static double SetDateValues(double year, double month, double day); 385 static void StartCallTimer(uintptr_t argGlue, JSTaggedType func, bool isAot); 386 static void EndCallTimer(uintptr_t argGlue, JSTaggedType func); 387 388 static JSTaggedValue CallBoundFunction(EcmaRuntimeCallInfo *info); 389 private: 390 static void PrintHeapReginInfo(uintptr_t argGlue); 391 392 static inline JSTaggedValue RuntimeInc(JSThread *thread, const JSHandle<JSTaggedValue> &value); 393 static inline JSTaggedValue RuntimeDec(JSThread *thread, const JSHandle<JSTaggedValue> &value); 394 static inline JSTaggedValue RuntimeExp(JSThread *thread, JSTaggedValue base, JSTaggedValue exponent); 395 static inline JSTaggedValue RuntimeIsIn(JSThread *thread, const JSHandle<JSTaggedValue> &prop, 396 const JSHandle<JSTaggedValue> &obj); 397 static inline JSTaggedValue RuntimeInstanceof(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 398 const JSHandle<JSTaggedValue> &target); 399 static inline JSTaggedValue RuntimeInstanceofByHandler(JSThread *thread, JSHandle<JSTaggedValue> target, 400 JSHandle<JSTaggedValue> object, 401 JSHandle<JSTaggedValue> instOfHandler); 402 static inline JSTaggedValue RuntimeCreateGeneratorObj(JSThread *thread, const JSHandle<JSTaggedValue> &genFunc); 403 404 static inline JSTaggedValue RuntimeCreateAsyncGeneratorObj(JSThread *thread, 405 const JSHandle<JSTaggedValue> &genFunc); 406 407 static inline JSTaggedValue RuntimeAsyncGeneratorResolve(JSThread *thread, JSHandle<JSTaggedValue> asyncFuncObj, 408 JSHandle<JSTaggedValue> value, JSTaggedValue flag); 409 static inline JSTaggedValue RuntimeAsyncGeneratorReject(JSThread *thread, JSHandle<JSTaggedValue> asyncFuncObj, 410 JSHandle<JSTaggedValue> value); 411 static inline JSTaggedValue RuntimeGetTemplateObject(JSThread *thread, const JSHandle<JSTaggedValue> &literal); 412 static inline JSTaggedValue RuntimeGetNextPropName(JSThread *thread, const JSHandle<JSTaggedValue> &iter); 413 static inline JSTaggedValue RuntimeIterNext(JSThread *thread, const JSHandle<JSTaggedValue> &iter); 414 static inline JSTaggedValue RuntimeCloseIterator(JSThread *thread, const JSHandle<JSTaggedValue> &iter); 415 static inline JSTaggedValue RuntimeSuperCallSpread(JSThread *thread, const JSHandle<JSTaggedValue> &func, 416 const JSHandle<JSTaggedValue> &newTarget, 417 const JSHandle<JSTaggedValue> &array); 418 static inline JSTaggedValue RuntimeDelObjProp(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 419 const JSHandle<JSTaggedValue> &prop); 420 static inline JSTaggedValue RuntimeNewObjApply(JSThread *thread, const JSHandle<JSTaggedValue> &func, 421 const JSHandle<JSTaggedValue> &array); 422 static inline JSTaggedValue RuntimeCreateIterResultObj(JSThread *thread, const JSHandle<JSTaggedValue> &value, 423 JSTaggedValue flag); 424 static inline JSTaggedValue RuntimeAsyncFunctionAwaitUncaught(JSThread *thread, 425 const JSHandle<JSTaggedValue> &asyncFuncObj, 426 const JSHandle<JSTaggedValue> &value); 427 static inline JSTaggedValue RuntimeAsyncFunctionResolveOrReject(JSThread *thread, 428 const JSHandle<JSTaggedValue> &asyncFuncObj, 429 const JSHandle<JSTaggedValue> &value, 430 bool is_resolve); 431 static inline JSTaggedValue RuntimeCopyDataProperties(JSThread *thread, const JSHandle<JSTaggedValue> &dst, 432 const JSHandle<JSTaggedValue> &src); 433 static inline JSTaggedValue RuntimeStArraySpread(JSThread *thread, const JSHandle<JSTaggedValue> &dst, 434 JSTaggedValue index, const JSHandle<JSTaggedValue> &src); 435 static inline JSTaggedValue RuntimeSetObjectWithProto(JSThread *thread, const JSHandle<JSTaggedValue> &proto, 436 const JSHandle<JSObject> &obj); 437 static inline JSTaggedValue RuntimeGetIteratorNext(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 438 const JSHandle<JSTaggedValue> &method); 439 static inline JSTaggedValue RuntimeLdObjByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 440 const JSHandle<JSTaggedValue> &prop, bool callGetter, 441 JSTaggedValue receiver); 442 static inline JSTaggedValue RuntimeStObjByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 443 const JSHandle<JSTaggedValue> &prop, 444 const JSHandle<JSTaggedValue> &value); 445 static inline JSTaggedValue RuntimeStOwnByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 446 const JSHandle<JSTaggedValue> &key, 447 const JSHandle<JSTaggedValue> &value); 448 static inline JSTaggedValue RuntimeLdSuperByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 449 const JSHandle<JSTaggedValue> &key, JSTaggedValue thisFunc); 450 static inline JSTaggedValue RuntimeStSuperByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 451 const JSHandle<JSTaggedValue> &key, 452 const JSHandle<JSTaggedValue> &value, JSTaggedValue thisFunc); 453 static inline JSTaggedValue RuntimeLdObjByIndex(JSThread *thread, const JSHandle<JSTaggedValue> &obj, uint32_t idx, 454 bool callGetter, JSTaggedValue receiver); 455 static inline JSTaggedValue RuntimeStObjByIndex(JSThread *thread, const JSHandle<JSTaggedValue> &obj, uint32_t idx, 456 const JSHandle<JSTaggedValue> &value); 457 static inline JSTaggedValue RuntimeStOwnByIndex(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 458 const JSHandle<JSTaggedValue> &idx, 459 const JSHandle<JSTaggedValue> &value); 460 static inline JSTaggedValue RuntimeStGlobalRecord(JSThread *thread, const JSHandle<JSTaggedValue> &prop, 461 const JSHandle<JSTaggedValue> &value, bool isConst); 462 static inline JSTaggedValue RuntimeNeg(JSThread *thread, const JSHandle<JSTaggedValue> &value); 463 static inline JSTaggedValue RuntimeNot(JSThread *thread, const JSHandle<JSTaggedValue> &value); 464 static inline JSTaggedValue RuntimeResolveClass(JSThread *thread, const JSHandle<JSFunction> &ctor, 465 const JSHandle<TaggedArray> &literal, 466 const JSHandle<JSTaggedValue> &base, 467 const JSHandle<JSTaggedValue> &lexenv); 468 static inline JSTaggedValue RuntimeCloneClassFromTemplate(JSThread *thread, const JSHandle<JSFunction> &ctor, 469 const JSHandle<JSTaggedValue> &base, 470 const JSHandle<JSTaggedValue> &lexenv); 471 static inline JSTaggedValue RuntimeCreateClassWithBuffer(JSThread *thread, 472 const JSHandle<JSTaggedValue> &base, 473 const JSHandle<JSTaggedValue> &lexenv, 474 const JSHandle<JSTaggedValue> &constpool, 475 uint16_t methodId, uint16_t literalId, 476 const JSHandle<JSTaggedValue> &module); 477 static inline JSTaggedValue RuntimeSetClassInheritanceRelationship(JSThread *thread, 478 const JSHandle<JSTaggedValue> &ctor, 479 const JSHandle<JSTaggedValue> &base); 480 static inline JSTaggedValue RuntimeSetClassConstructorLength(JSThread *thread, JSTaggedValue ctor, 481 JSTaggedValue length); 482 static inline JSTaggedValue RuntimeNotifyInlineCache(JSThread *thread, const JSHandle<Method> &method, 483 uint32_t icSlotSize); 484 static inline JSTaggedValue RuntimeStOwnByValueWithNameSet(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 485 const JSHandle<JSTaggedValue> &key, 486 const JSHandle<JSTaggedValue> &value); 487 static inline JSTaggedValue RuntimeStOwnByName(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 488 const JSHandle<JSTaggedValue> &prop, 489 const JSHandle<JSTaggedValue> &value); 490 static inline JSTaggedValue RuntimeSuspendGenerator(JSThread *thread, const JSHandle<JSTaggedValue> &genObj, 491 const JSHandle<JSTaggedValue> &value); 492 static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, int32_t index); 493 static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, int32_t index, 494 JSTaggedValue jsFunc); 495 static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, JSTaggedValue localName); 496 static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, JSTaggedValue localName, 497 JSTaggedValue jsFunc); 498 static inline void RuntimeStModuleVar(JSThread *thread, int32_t index, JSTaggedValue value); 499 static inline void RuntimeStModuleVar(JSThread *thread, int32_t index, JSTaggedValue value, 500 JSTaggedValue jsFunc); 501 static inline void RuntimeStModuleVar(JSThread *thread, JSTaggedValue key, JSTaggedValue value); 502 static inline void RuntimeStModuleVar(JSThread *thread, JSTaggedValue key, JSTaggedValue value, 503 JSTaggedValue jsFunc); 504 static inline JSTaggedValue RuntimeLdLocalModuleVar(JSThread *thread, int32_t index); 505 static inline JSTaggedValue RuntimeLdLocalModuleVar(JSThread *thread, int32_t index, 506 JSTaggedValue jsFunc); 507 static inline JSTaggedValue RuntimeLdExternalModuleVar(JSThread *thread, int32_t index); 508 static inline JSTaggedValue RuntimeLdExternalModuleVar(JSThread *thread, int32_t index, 509 JSTaggedValue jsFunc); 510 static inline JSTaggedValue RuntimeLdModuleVar(JSThread *thread, JSTaggedValue key, bool inner); 511 static inline JSTaggedValue RuntimeLdModuleVar(JSThread *thread, JSTaggedValue key, bool inner, 512 JSTaggedValue jsFunc); 513 static inline JSTaggedValue RuntimeGetPropIterator(JSThread *thread, const JSHandle<JSTaggedValue> &value); 514 static inline JSTaggedValue RuntimeAsyncFunctionEnter(JSThread *thread); 515 static inline JSTaggedValue RuntimeGetIterator(JSThread *thread, const JSHandle<JSTaggedValue> &obj); 516 static inline JSTaggedValue RuntimeGetAsyncIterator(JSThread *thread, const JSHandle<JSTaggedValue> &obj); 517 static inline void RuntimeSetGeneratorState(JSThread *thread, const JSHandle<JSTaggedValue> &genObj, 518 const int32_t index); 519 static inline void RuntimeThrow(JSThread *thread, JSTaggedValue value); 520 static inline void RuntimeThrowThrowNotExists(JSThread *thread); 521 static inline void RuntimeThrowPatternNonCoercible(JSThread *thread); 522 static inline void RuntimeThrowDeleteSuperProperty(JSThread *thread); 523 static inline void RuntimeThrowUndefinedIfHole(JSThread *thread, const JSHandle<EcmaString> &obj); 524 static inline void RuntimeThrowIfNotObject(JSThread *thread); 525 static inline void RuntimeThrowConstAssignment(JSThread *thread, const JSHandle<EcmaString> &value); 526 static inline JSTaggedValue RuntimeLdGlobalRecord(JSThread *thread, JSTaggedValue key); 527 static inline JSTaggedValue RuntimeTryLdGlobalByName(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 528 const JSHandle<JSTaggedValue> &prop); 529 static inline JSTaggedValue RuntimeTryUpdateGlobalRecord(JSThread *thread, JSTaggedValue prop, JSTaggedValue value); 530 static inline JSTaggedValue RuntimeThrowReferenceError(JSThread *thread, const JSHandle<JSTaggedValue> &prop, 531 const char *desc); 532 static inline JSTaggedValue RuntimeLdGlobalVarFromProto(JSThread *thread, const JSHandle<JSTaggedValue> &globalObj, 533 const JSHandle<JSTaggedValue> &prop); 534 static inline JSTaggedValue RuntimeStGlobalVar(JSThread *thread, const JSHandle<JSTaggedValue> &prop, 535 const JSHandle<JSTaggedValue> &value); 536 static inline JSTaggedValue RuntimeToNumber(JSThread *thread, const JSHandle<JSTaggedValue> &value); 537 static inline JSTaggedValue RuntimeDynamicImport(JSThread *thread, const JSHandle<JSTaggedValue> &specifier, 538 const JSHandle<JSTaggedValue> &func); 539 static inline JSTaggedValue RuntimeToNumeric(JSThread *thread, const JSHandle<JSTaggedValue> &value); 540 static inline JSTaggedValue RuntimeEq(JSThread *thread, const JSHandle<JSTaggedValue> &left, 541 const JSHandle<JSTaggedValue> &right); 542 static inline JSTaggedValue RuntimeLdObjByName(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop, 543 bool callGetter, JSTaggedValue receiver); 544 static inline JSTaggedValue RuntimeNotEq(JSThread *thread, const JSHandle<JSTaggedValue> &left, 545 const JSHandle<JSTaggedValue> &right); 546 static inline JSTaggedValue RuntimeLess(JSThread *thread, const JSHandle<JSTaggedValue> &left, 547 const JSHandle<JSTaggedValue> &right); 548 static inline JSTaggedValue RuntimeLessEq(JSThread *thread, const JSHandle<JSTaggedValue> &left, 549 const JSHandle<JSTaggedValue> &right); 550 static inline JSTaggedValue RuntimeGreater(JSThread *thread, const JSHandle<JSTaggedValue> &left, 551 const JSHandle<JSTaggedValue> &right); 552 static inline JSTaggedValue RuntimeGreaterEq(JSThread *thread, const JSHandle<JSTaggedValue> &left, 553 const JSHandle<JSTaggedValue> &right); 554 static inline JSTaggedValue RuntimeAdd2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 555 const JSHandle<JSTaggedValue> &right); 556 static inline JSTaggedValue RuntimeShl2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 557 const JSHandle<JSTaggedValue> &right); 558 static inline JSTaggedValue RuntimeShr2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 559 const JSHandle<JSTaggedValue> &right); 560 static inline JSTaggedValue RuntimeSub2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 561 const JSHandle<JSTaggedValue> &right); 562 static inline JSTaggedValue RuntimeMul2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 563 const JSHandle<JSTaggedValue> &right); 564 static inline JSTaggedValue RuntimeDiv2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 565 const JSHandle<JSTaggedValue> &right); 566 static inline JSTaggedValue RuntimeMod2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 567 const JSHandle<JSTaggedValue> &right); 568 static inline JSTaggedValue RuntimeAshr2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 569 const JSHandle<JSTaggedValue> &right); 570 static inline JSTaggedValue RuntimeAnd2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 571 const JSHandle<JSTaggedValue> &right); 572 static inline JSTaggedValue RuntimeOr2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 573 const JSHandle<JSTaggedValue> &right); 574 static inline JSTaggedValue RuntimeXor2(JSThread *thread, const JSHandle<JSTaggedValue> &left, 575 const JSHandle<JSTaggedValue> &right); 576 static inline JSTaggedValue RuntimeStOwnByNameWithNameSet(JSThread *thread, 577 const JSHandle<JSTaggedValue> &obj, 578 const JSHandle<JSTaggedValue> &prop, 579 const JSHandle<JSTaggedValue> &value); 580 static inline JSTaggedValue RuntimeStObjByName(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 581 const JSHandle<JSTaggedValue> &prop, 582 const JSHandle<JSTaggedValue> &value); 583 static inline JSTaggedValue RuntimeToJSTaggedValueWithInt32(JSThread *thread, 584 const JSHandle<JSTaggedValue> &value); 585 static inline JSTaggedValue RuntimeToJSTaggedValueWithUint32(JSThread *thread, 586 const JSHandle<JSTaggedValue> &value); 587 static inline JSTaggedValue RuntimeCreateEmptyObject(JSThread *thread, ObjectFactory *factory, 588 JSHandle<GlobalEnv> globalEnv); 589 static inline JSTaggedValue RuntimeCreateEmptyArray(JSThread *thread, ObjectFactory *factory, 590 JSHandle<GlobalEnv> globalEnv); 591 static inline JSTaggedValue RuntimeGetUnmapedArgs(JSThread *thread, JSTaggedType *sp, uint32_t actualNumArgs, 592 uint32_t startIdx); 593 static inline JSTaggedValue RuntimeCopyRestArgs(JSThread *thread, JSTaggedType *sp, uint32_t restNumArgs, 594 uint32_t startIdx); 595 static inline JSTaggedValue RuntimeCreateArrayWithBuffer(JSThread *thread, ObjectFactory *factory, 596 const JSHandle<JSTaggedValue> &literal); 597 static inline JSTaggedValue RuntimeCreateObjectWithBuffer(JSThread *thread, ObjectFactory *factory, 598 const JSHandle<JSObject> &literal); 599 static inline JSTaggedValue RuntimeNewLexicalEnv(JSThread *thread, uint16_t numVars); 600 static inline JSTaggedValue RuntimeNewObjRange(JSThread *thread, const JSHandle<JSTaggedValue> &func, 601 const JSHandle<JSTaggedValue> &newTarget, uint16_t firstArgIdx, 602 uint16_t length); 603 static inline JSTaggedValue RuntimeDefinefunc(JSThread *thread, const JSHandle<Method> &methodHandle); 604 static inline JSTaggedValue RuntimeCreateRegExpWithLiteral(JSThread *thread, const JSHandle<JSTaggedValue> &pattern, 605 uint8_t flags); 606 static inline JSTaggedValue RuntimeThrowIfSuperNotCorrectCall(JSThread *thread, uint16_t index, 607 JSTaggedValue thisValue); 608 static inline JSTaggedValue RuntimeCreateObjectHavingMethod(JSThread *thread, ObjectFactory *factory, 609 const JSHandle<JSObject> &literal, 610 const JSHandle<JSTaggedValue> &env); 611 static inline JSTaggedValue RuntimeCreateObjectWithExcludedKeys(JSThread *thread, uint16_t numKeys, 612 const JSHandle<JSTaggedValue> &objVal, 613 uint16_t firstArgRegIdx); 614 static inline JSTaggedValue RuntimeDefineMethod(JSThread *thread, const JSHandle<Method> &methodHandle, 615 const JSHandle<JSTaggedValue> &homeObject); 616 static inline JSTaggedValue RuntimeCallSpread(JSThread *thread, const JSHandle<JSTaggedValue> &func, 617 const JSHandle<JSTaggedValue> &obj, 618 const JSHandle<JSTaggedValue> &array); 619 static inline JSTaggedValue RuntimeDefineGetterSetterByValue(JSThread *thread, const JSHandle<JSObject> &obj, 620 const JSHandle<JSTaggedValue> &prop, 621 const JSHandle<JSTaggedValue> &getter, 622 const JSHandle<JSTaggedValue> &setter, bool flag); 623 static inline JSTaggedValue RuntimeSuperCall(JSThread *thread, const JSHandle<JSTaggedValue> &func, 624 const JSHandle<JSTaggedValue> &newTarget, uint16_t firstVRegIdx, 625 uint16_t length); 626 static inline JSTaggedValue RuntimeOptSuperCall(JSThread *thread, uintptr_t argv, uint32_t argc); 627 static inline JSTaggedValue RuntimeThrowTypeError(JSThread *thread, const char *message); 628 static inline JSTaggedValue RuntimeGetCallSpreadArgs(JSThread *thread, const JSHandle<JSTaggedValue> &array); 629 static inline JSTaggedValue RuntimeThrowReferenceError(JSThread *thread, JSTaggedValue prop, const char *desc); 630 static inline JSTaggedValue RuntimeThrowSyntaxError(JSThread *thread, const char *message); 631 static inline JSTaggedValue RuntimeLdBigInt(JSThread *thread, const JSHandle<JSTaggedValue> &numberBigInt); 632 static inline JSTaggedValue RuntimeNewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId); 633 static inline JSTaggedValue RuntimeOptGetUnmapedArgs(JSThread *thread, uint32_t actualNumArgs); 634 static inline JSTaggedValue RuntimeGetUnmapedJSArgumentObj(JSThread *thread, 635 const JSHandle<TaggedArray> &argumentsList); 636 static inline JSTaggedValue RuntimeOptNewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId, 637 JSHandle<JSTaggedValue> ¤tLexEnv, 638 JSHandle<JSTaggedValue> &func); 639 static inline JSTaggedValue RuntimeOptCopyRestArgs(JSThread *thread, uint32_t actualArgc, uint32_t restIndex); 640 static inline JSTaggedValue RuntimeOptSuspendGenerator(JSThread *thread, const JSHandle<JSTaggedValue> &genObj, 641 const JSHandle<JSTaggedValue> &value); 642 static inline JSTaggedValue RuntimeOptAsyncGeneratorResolve(JSThread *thread, JSHandle<JSTaggedValue> asyncFuncObj, 643 JSHandle<JSTaggedValue> value, JSTaggedValue flag); 644 static inline JSTaggedValue CommonCreateObjectWithExcludedKeys(JSThread *thread, 645 const JSHandle<JSTaggedValue> &objVal, 646 uint32_t numExcludedKeys, 647 JSHandle<TaggedArray> excludedKeys); 648 static inline JSTaggedValue RuntimeOptCreateObjectWithExcludedKeys(JSThread *thread, uint16_t numKeys, 649 const JSHandle<JSTaggedValue> &objVal, 650 uint16_t firstArgRegIdx, 651 uintptr_t argv, uint32_t argc); 652 static inline JSTaggedValue RuntimeOptNewObjRange(JSThread *thread, uintptr_t argv, uint32_t argc); 653 static inline JSTaggedValue RuntimeOptConstruct(JSThread *thread, JSHandle<JSTaggedValue> ctor, 654 JSHandle<JSTaggedValue> newTarget, JSHandle<JSTaggedValue> preArgs, 655 JSHandle<TaggedArray> args); 656 static inline JSTaggedValue RuntimeOptConstructProxy(JSThread *thread, JSHandle<JSProxy> ctor, 657 JSHandle<JSTaggedValue> newTgt, 658 JSHandle<JSTaggedValue> preArgs, JSHandle<TaggedArray> args); 659 static inline JSTaggedValue RuntimeOptConstructBoundFunction(JSThread *thread, JSHandle<JSBoundFunction> ctor, 660 JSHandle<JSTaggedValue> newTgt, 661 JSHandle<JSTaggedValue> preArgs, 662 JSHandle<TaggedArray> args); 663 static inline JSTaggedValue RuntimeOptConstructGeneric(JSThread *thread, JSHandle<JSFunction> ctor, 664 JSHandle<JSTaggedValue> newTgt, 665 JSHandle<JSTaggedValue> preArgs, JSHandle<TaggedArray> args); 666 static inline JSTaggedValue RuntimeOptGenerateScopeInfo(JSThread *thread, uint16_t scopeId, JSTaggedValue func); 667 static inline JSTaggedType *GetActualArgv(JSThread *thread); 668 static inline JSTaggedType *GetActualArgvFromStub(JSThread *thread); 669 static inline OptimizedJSFunctionFrame *GetOptimizedJSFunctionFrame(JSThread *thread); 670 static inline OptimizedJSFunctionFrame *GetOptimizedJSFunctionFrameNoGC(JSThread *thread); 671 672 static JSTaggedValue NewObject(EcmaRuntimeCallInfo *info); 673 static void SaveFrameToContext(JSThread *thread, JSHandle<GeneratorContext> context); 674 675 static inline JSTaggedValue RuntimeLdPatchVar(JSThread *thread, uint32_t index); 676 static inline JSTaggedValue RuntimeStPatchVar(JSThread *thread, uint32_t index, 677 const JSHandle<JSTaggedValue> &value); 678 static inline JSTaggedValue RuntimeNotifyConcurrentResult(JSThread *thread, JSTaggedValue result, 679 JSTaggedValue hint); 680 static inline JSTaggedValue RuntimeNotifyDebuggerStatement(JSThread *thread); 681 friend class SlowRuntimeStub; 682 }; 683 } // namespace panda::ecmascript 684 #endif 685