Lines Matching refs:vm

158 Local<PrimitiveRef> JSValueRef::Undefined(const EcmaVM *vm)
161 vm->GetJSThread()->GlobalConstants()->GetHandledUndefined());
164 Local<PrimitiveRef> JSValueRef::Null(const EcmaVM *vm)
167 vm->GetJSThread()->GlobalConstants()->GetHandledNull());
170 Local<PrimitiveRef> JSValueRef::Hole(const EcmaVM *vm)
173 vm->GetJSThread()->GlobalConstants()->GetHandledHole());
176 Local<PrimitiveRef> JSValueRef::True(const EcmaVM *vm)
179 vm->GetJSThread()->GlobalConstants()->GetHandledTrue());
182 Local<PrimitiveRef> JSValueRef::False(const EcmaVM *vm)
185 vm->GetJSThread()->GlobalConstants()->GetHandledFalse());
188 Local<ObjectRef> JSValueRef::ToObject(const EcmaVM *vm)
190 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
192 return Undefined(vm);
194 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
197 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
201 Local<ObjectRef> JSValueRef::ToEcmaObject(const EcmaVM *vm)
203 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
204 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
208 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
212 return Undefined(vm);
215 Local<StringRef> JSValueRef::ToString(const EcmaVM *vm)
217 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
218 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
223 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
228 Local<NativePointerRef> JSValueRef::ToNativePointer(const EcmaVM *vm)
230 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
231 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
238 bool JSValueRef::BooleaValue(const EcmaVM *vm)
240 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
244 int64_t JSValueRef::IntegerValue(const EcmaVM *vm)
246 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
247 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
262 uint32_t JSValueRef::Uint32Value(const EcmaVM *vm)
264 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
265 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
278 int32_t JSValueRef::Int32Value(const EcmaVM *vm)
280 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
281 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
364 Local<BooleanRef> JSValueRef::ToBoolean(const EcmaVM *vm)
366 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
367 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
374 Local<BigIntRef> JSValueRef::ToBigInt(const EcmaVM *vm)
376 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
377 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
381 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
385 Local<NumberRef> JSValueRef::ToNumber(const EcmaVM *vm)
387 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
388 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
392 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
396 bool JSValueRef::IsStrictEquals(const EcmaVM *vm, Local<JSValueRef> value)
398 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
399 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
406 Local<StringRef> JSValueRef::Typeof(const EcmaVM *vm)
408 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
409 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
414 bool JSValueRef::InstanceOf(const EcmaVM *vm, Local<JSValueRef> value)
416 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
417 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
456 bool JSValueRef::IsBigInt(const EcmaVM *vm)
458 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
477 bool JSValueRef::IsString(const EcmaVM *vm)
479 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
483 bool JSValueRef::IsSymbol(const EcmaVM *vm)
485 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
489 bool JSValueRef::IsObject(const EcmaVM *vm)
491 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
495 bool JSValueRef::IsArray(const EcmaVM *vm)
497 CROSS_THREAD_CHECK(vm);
498 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
502 bool JSValueRef::IsJSArray(const EcmaVM *vm)
504 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
508 bool JSValueRef::IsConstructor(const EcmaVM *vm)
510 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
515 bool JSValueRef::IsFunction(const EcmaVM *vm)
517 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
522 bool JSValueRef::IsJSFunction(const EcmaVM *vm)
524 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
529 bool JSValueRef::IsProxy(const EcmaVM *vm)
531 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
535 bool JSValueRef::IsPromise(const EcmaVM *vm)
537 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
541 bool JSValueRef::IsDataView(const EcmaVM *vm)
543 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
547 bool JSValueRef::IsTypedArray(const EcmaVM *vm)
549 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
553 bool JSValueRef::IsNativePointer(const EcmaVM *vm)
555 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
559 bool JSValueRef::IsDate(const EcmaVM *vm)
561 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
565 bool JSValueRef::IsError(const EcmaVM *vm)
567 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
571 bool JSValueRef::IsMap(const EcmaVM *vm)
573 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
577 bool JSValueRef::IsSet(const EcmaVM *vm)
579 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
583 bool JSValueRef::IsWeakRef(const EcmaVM *vm)
585 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
589 bool JSValueRef::IsWeakMap(const EcmaVM *vm)
591 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
595 bool JSValueRef::IsWeakSet(const EcmaVM *vm)
597 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
601 bool JSValueRef::IsRegExp(const EcmaVM *vm)
603 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
607 bool JSValueRef::IsArrayIterator(const EcmaVM *vm)
609 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
613 bool JSValueRef::IsStringIterator(const EcmaVM *vm)
615 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
619 bool JSValueRef::IsSetIterator(const EcmaVM *vm)
621 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
625 bool JSValueRef::IsMapIterator(const EcmaVM *vm)
627 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
631 bool JSValueRef::IsArrayBuffer(const EcmaVM *vm)
633 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
637 bool JSValueRef::IsBuffer(const EcmaVM *vm)
639 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
643 bool JSValueRef::IsUint8Array(const EcmaVM *vm)
645 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
649 bool JSValueRef::IsInt8Array(const EcmaVM *vm)
651 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
655 bool JSValueRef::IsUint8ClampedArray(const EcmaVM *vm)
657 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
661 bool JSValueRef::IsInt16Array(const EcmaVM *vm)
663 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
667 bool JSValueRef::IsUint16Array(const EcmaVM *vm)
669 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
673 bool JSValueRef::IsInt32Array(const EcmaVM *vm)
675 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
679 bool JSValueRef::IsUint32Array(const EcmaVM *vm)
681 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
685 bool JSValueRef::IsFloat32Array(const EcmaVM *vm)
687 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
691 bool JSValueRef::IsFloat64Array(const EcmaVM *vm)
693 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
697 bool JSValueRef::IsBigInt64Array(const EcmaVM *vm)
699 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
703 bool JSValueRef::IsBigUint64Array(const EcmaVM *vm)
705 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
709 bool JSValueRef::IsJSSharedInt8Array(const EcmaVM *vm)
711 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
715 bool JSValueRef::IsJSSharedUint8Array([[maybe_unused]]const EcmaVM *vm)
717 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
721 bool JSValueRef::IsJSSharedUint8ClampedArray([[maybe_unused]]const EcmaVM *vm)
723 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
727 bool JSValueRef::IsJSSharedInt16Array(const EcmaVM *vm)
729 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
733 bool JSValueRef::IsJSSharedUint16Array(const EcmaVM *vm)
735 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
739 bool JSValueRef::IsJSSharedInt32Array(const EcmaVM *vm)
741 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
745 bool JSValueRef::IsJSSharedFloat32Array(const EcmaVM *vm)
747 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
751 bool JSValueRef::IsJSSharedUint32Array(const EcmaVM *vm)
753 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
757 bool JSValueRef::IsJSPrimitiveRef(const EcmaVM *vm)
759 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
763 bool JSValueRef::IsJSPrimitiveNumber(const EcmaVM *vm)
765 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
768 return IsJSPrimitiveRef(vm) ? JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsNumber() : false;
771 bool JSValueRef::IsJSPrimitiveInt(const EcmaVM *vm)
773 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
776 return IsJSPrimitiveRef(vm) ? JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsInt() : false;
779 bool JSValueRef::IsJSPrimitiveBoolean(const EcmaVM *vm)
781 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
784 return IsJSPrimitiveRef(vm) ? JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsBoolean() : false;
787 bool JSValueRef::IsJSPrimitiveString(const EcmaVM *vm)
789 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
792 return IsJSPrimitiveRef(vm) ? JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsString() : false;
795 bool JSValueRef::IsJSPrimitiveSymbol(const EcmaVM *vm)
797 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
800 return IsJSPrimitiveRef(vm) ? JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsSymbol() : false;
803 bool JSValueRef::IsGeneratorObject(const EcmaVM *vm)
805 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
809 bool JSValueRef::IsModuleNamespaceObject(const EcmaVM *vm)
811 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
815 bool JSValueRef::IsNativeModuleFailureInfoObject(const EcmaVM *vm)
817 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
821 bool JSValueRef::IsSharedArrayBuffer(const EcmaVM *vm)
823 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
827 bool JSValueRef::IsSendableArrayBuffer(const EcmaVM *vm)
829 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
833 bool JSValueRef::IsJSLocale(const EcmaVM *vm)
835 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
839 bool JSValueRef::IsJSDateTimeFormat(const EcmaVM *vm)
841 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
845 bool JSValueRef::IsJSRelativeTimeFormat(const EcmaVM *vm)
847 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
851 bool JSValueRef::IsJSIntl(const EcmaVM *vm)
853 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
857 bool JSValueRef::IsJSNumberFormat(const EcmaVM *vm)
859 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
863 bool JSValueRef::IsJSCollator(const EcmaVM *vm)
865 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
869 bool JSValueRef::IsJSPluralRules(const EcmaVM *vm)
871 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
875 bool JSValueRef::IsJSListFormat(const EcmaVM *vm)
877 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
881 bool JSValueRef::IsAsyncGeneratorObject(const EcmaVM *vm)
883 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
887 bool JSValueRef::IsAsyncFunction(const EcmaVM *vm)
889 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
893 bool JSValueRef::IsConcurrentFunction(const EcmaVM *vm)
895 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
901 bool JSValueRef::IsArgumentsObject(const EcmaVM *vm)
903 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
907 bool JSValueRef::IsGeneratorFunction(const EcmaVM *vm)
909 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
913 bool JSValueRef::IsAsyncGeneratorFunction(const EcmaVM *vm)
915 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
919 bool JSValueRef::IsArrayList(const EcmaVM *vm)
921 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
925 bool JSValueRef::IsDeque(const EcmaVM *vm)
927 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
931 bool JSValueRef::IsHashMap(const EcmaVM *vm)
933 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
937 bool JSValueRef::IsHashSet(const EcmaVM *vm)
939 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
943 bool JSValueRef::IsLightWeightMap(const EcmaVM *vm)
945 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
949 bool JSValueRef::IsLightWeightSet(const EcmaVM *vm)
951 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
955 bool JSValueRef::IsLinkedList(const EcmaVM *vm)
957 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
961 bool JSValueRef::IsLinkedListIterator(const EcmaVM *vm)
963 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
967 bool JSValueRef::IsList(const EcmaVM *vm)
969 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
973 bool JSValueRef::IsPlainArray(const EcmaVM *vm)
975 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
979 bool JSValueRef::IsQueue(const EcmaVM *vm)
981 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
985 bool JSValueRef::IsStack(const EcmaVM *vm)
987 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
991 bool JSValueRef::IsTreeMap(const EcmaVM *vm)
993 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
997 bool JSValueRef::IsTreeSet(const EcmaVM *vm)
999 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1003 bool JSValueRef::IsVector(const EcmaVM *vm)
1005 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1009 bool JSValueRef::IsSendableObject(const EcmaVM *vm)
1011 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1012 return IsJSShared(vm) && IsObject(vm);
1015 bool JSValueRef::IsJSShared(const EcmaVM *vm)
1017 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1021 bool JSValueRef::IsSharedArray(const EcmaVM *vm)
1023 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1027 bool JSValueRef::IsSharedTypedArray(const EcmaVM *vm)
1029 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1033 bool JSValueRef::IsSharedSet(const EcmaVM *vm)
1035 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1039 bool JSValueRef::IsSharedMap(const EcmaVM *vm)
1041 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1045 bool JSValueRef::IsSharedMapIterator(const EcmaVM *vm)
1047 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1056 void *JSValueRef::GetNativePointerValue(const EcmaVM* vm, bool &isNativePointer)
1058 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1059 if (IsJSShared(vm)) {
1060 return GetNativePointerValueImpl(vm, isNativePointer);
1062 return GetNativePointerValueImpl(vm, isNativePointer);
1067 void *JSValueRef::GetNativePointerValueImpl(const EcmaVM* vm, bool &isNativePointer)
1069 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1070 if (!IsNativePointer(vm)) {
1075 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, nullptr);
1080 bool JSValueRef::IsDetachedArraybuffer(const EcmaVM *vm, bool &isArrayBuffer)
1082 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1084 if (!IsArrayBuffer(vm)) {
1093 void JSValueRef::DetachedArraybuffer(const EcmaVM *vm, bool &isArrayBuffer)
1095 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1096 if (IsArrayBuffer(vm)) {
1101 arrayBuffer->Detach(vm->GetJSThread());
1103 } else if (IsSendableArrayBuffer(vm)) {
1108 arrayBuffer->Detach(vm->GetJSThread());
1115 void JSValueRef::GetDataViewInfo(const EcmaVM *vm,
1122 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1123 if (!IsDataView(vm)) {
1134 JSThread* thread = vm->GetJSThread();
1152 void JSValueRef::TryGetArrayLength(const EcmaVM *vm, bool *isArrayOrSharedArray, uint32_t *arrayLength)
1154 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1169 const EcmaVM *vm, Local<ArrayBufferRef> arrayBuffer, uint32_t byteOffset, uint32_t byteLength)
1171 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1172 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1173 ObjectFactory *factory = vm->GetFactory();
1177 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
1195 Local<ArrayBufferRef> DataViewRef::GetArrayBuffer(const EcmaVM *vm)
1197 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1198 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1207 Local<JSValueRef> PrimitiveRef::GetValue(const EcmaVM *vm)
1209 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1210 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1222 Local<NumberRef> NumberRef::New(const EcmaVM *vm, double input)
1226 CROSS_THREAD_CHECK(vm);
1234 Local<NumberRef> NumberRef::New(const EcmaVM *vm, int32_t input)
1238 CROSS_THREAD_CHECK(vm);
1243 Local<NumberRef> NumberRef::New(const EcmaVM *vm, uint32_t input)
1247 CROSS_THREAD_CHECK(vm);
1252 Local<NumberRef> NumberRef::New(const EcmaVM *vm, int64_t input)
1256 CROSS_THREAD_CHECK(vm);
1269 Local<JSValueRef> MapRef::Get(const EcmaVM *vm, Local<JSValueRef> key)
1271 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1272 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1278 Local<JSValueRef> MapRef::Get(const EcmaVM *vm, const char *utf8)
1280 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1281 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1283 ObjectFactory *factory = vm->GetFactory();
1289 void MapRef::Set(const EcmaVM *vm, Local<JSValueRef> key, Local<JSValueRef> value)
1291 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
1292 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1297 void MapRef::Set(const EcmaVM *vm, const char *utf8, Local<JSValueRef> value)
1299 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
1300 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1302 ObjectFactory *factory = vm->GetFactory();
1307 bool MapRef::Has(const EcmaVM *vm, Local<JSValueRef> key)
1309 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
1310 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1316 bool MapRef::Has(const EcmaVM *vm, const char *utf8)
1318 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
1319 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1321 ObjectFactory *factory = vm->GetFactory();
1327 void MapRef::Delete(const EcmaVM *vm, Local<JSValueRef> key)
1329 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
1330 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1335 void MapRef::Clear(const EcmaVM *vm)
1337 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
1338 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1343 Local<MapRef> MapRef::New(const EcmaVM *vm)
1345 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1346 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1358 int32_t MapRef::GetSize(const EcmaVM *vm)
1361 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1366 int32_t MapRef::GetTotalElements(const EcmaVM *vm)
1369 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1375 Local<JSValueRef> MapRef::GetKey(const EcmaVM *vm, int entry)
1377 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1378 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1384 Local<JSValueRef> MapRef::GetValue(const EcmaVM *vm, int entry)
1386 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1387 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1393 Local<MapIteratorRef> MapRef::GetEntries(const EcmaVM *vm)
1395 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1396 DCHECK_SPECIAL_VALUE_WITH_RETURN(this, JSValueRef::Undefined(vm));
1397 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1404 Local<MapIteratorRef> MapRef::GetKeys(const EcmaVM *vm)
1406 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1407 DCHECK_SPECIAL_VALUE_WITH_RETURN(this, JSValueRef::Undefined(vm));
1408 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1414 Local<MapIteratorRef> MapRef::GetValues(const EcmaVM *vm)
1416 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1417 DCHECK_SPECIAL_VALUE_WITH_RETURN(this, JSValueRef::Undefined(vm));
1418 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1425 Local<SendableMapRef> SendableMapRef::New(const EcmaVM *vm)
1427 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1429 ObjectFactory *factory = vm->GetFactory();
1430 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
1443 Local<JSValueRef> SendableMapRef::Get(const EcmaVM *vm, Local<JSValueRef> key)
1445 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1452 Local<JSValueRef> SendableMapRef::Get(const EcmaVM *vm, const char *utf8)
1454 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1457 ObjectFactory *factory = vm->GetFactory();
1463 void SendableMapRef::Set(const EcmaVM *vm, Local<JSValueRef> key, Local<JSValueRef> value)
1465 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
1471 void SendableMapRef::Set(const EcmaVM *vm, const char *utf8, Local<JSValueRef> value)
1473 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
1476 ObjectFactory *factory = vm->GetFactory();
1481 bool SendableMapRef::Has(const EcmaVM *vm, Local<JSValueRef> key)
1483 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
1490 bool SendableMapRef::Has(const EcmaVM *vm, const char *utf8)
1492 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
1495 ObjectFactory *factory = vm->GetFactory();
1501 void SendableMapRef::Delete(const EcmaVM *vm, Local<JSValueRef> key)
1503 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
1509 void SendableMapRef::Clear(const EcmaVM *vm)
1511 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
1517 uint32_t SendableMapRef::GetSize(const EcmaVM *vm)
1519 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
1521 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1526 uint32_t SendableMapRef::GetTotalElements(const EcmaVM *vm)
1528 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
1530 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1536 Local<JSValueRef> SendableMapRef::GetKey(const EcmaVM *vm, int entry)
1538 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1539 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1546 Local<JSValueRef> SendableMapRef::GetValue(const EcmaVM *vm, int entry)
1548 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1549 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1556 Local<SendableMapIteratorRef> SendableMapRef::GetEntries(const EcmaVM *vm)
1558 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1559 DCHECK_SPECIAL_VALUE_WITH_RETURN(this, JSValueRef::Undefined(vm));
1560 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1567 Local<SendableMapIteratorRef> SendableMapRef::GetKeys(const EcmaVM *vm)
1569 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1570 DCHECK_SPECIAL_VALUE_WITH_RETURN(this, JSValueRef::Undefined(vm));
1571 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1578 Local<SendableMapIteratorRef> SendableMapRef::GetValues(const EcmaVM *vm)
1580 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1581 DCHECK_SPECIAL_VALUE_WITH_RETURN(this, JSValueRef::Undefined(vm));
1582 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1590 Local<SendableSetRef> SendableSetRef::New(const EcmaVM *vm)
1592 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1594 ObjectFactory *factory = vm->GetFactory();
1595 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
1608 uint32_t SendableSetRef::GetSize(const EcmaVM *vm)
1610 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
1612 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1617 uint32_t SendableSetRef::GetTotalElements(const EcmaVM *vm)
1619 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
1621 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1627 Local<JSValueRef> SendableSetRef::GetValue(const EcmaVM *vm, int entry)
1629 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1630 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1637 void SendableSetRef::Add(const EcmaVM *vm, Local<JSValueRef> value)
1639 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
1654 Local<JSValueRef> MapIteratorRef::GetKind(const EcmaVM *vm)
1656 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1657 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1679 Local<MapIteratorRef> MapIteratorRef::New(const EcmaVM *vm, Local<MapRef> map)
1681 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1686 JSMapIterator::CreateMapIterator(vm->GetJSThread(), JSHandle<JSTaggedValue>::Cast(jsMap), iterKind);
1687 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
1691 ecmascript::EcmaRuntimeCallInfo *MapIteratorRef::GetEcmaRuntimeCallInfo(const EcmaVM *vm)
1693 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, nullptr);
1694 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1696 JSHandle<LinkedHashMap> linkedHashMap(vm->GetJSThread(), jsMapIter->GetIteratedMap());
1698 return ecmascript::EcmaInterpreter::NewRuntimeCallInfo(vm->GetJSThread(),
1699 JSHandle<JSTaggedValue>(vm->GetJSThread(), JSTaggedValue::Undefined()),
1700 JSHandle<JSTaggedValue>(vm->GetJSThread(), jsMapIter.GetTaggedValue()),
1701 JSHandle<JSTaggedValue>(vm->GetJSThread(), JSTaggedValue::Undefined()), size);
1704 Local<ArrayRef> MapIteratorRef::Next(const EcmaVM *vm, ecmascript::EcmaRuntimeCallInfo *ecmaRuntimeCallInfo)
1706 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1708 JSHandle<JSTaggedValue> nextTagValResult(vm->GetJSThread(), JSMapIterator::Next(ecmaRuntimeCallInfo));
1709 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
1710 JSHandle<JSTaggedValue> iteratorVal(vm->GetJSThread(),
1711 JSIterator::IteratorValue(vm->GetJSThread(), nextTagValResult).GetTaggedValue());
1715 Local<JSValueRef> MapIteratorRef::Next(const EcmaVM *vm)
1717 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1725 Local<JSValueRef> SendableMapIteratorRef::Next(const EcmaVM *vm)
1727 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1742 Local<JSValueRef> SetIteratorRef::GetKind(const EcmaVM *vm)
1744 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1745 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1767 Local<SetIteratorRef> SetIteratorRef::New(const EcmaVM *vm, Local<SetRef> set)
1769 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1770 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1774 JSSetIterator::CreateSetIterator(vm->GetJSThread(), JSHandle<JSTaggedValue>::Cast(jsSet), iterKind);
1775 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
1779 ecmascript::EcmaRuntimeCallInfo *SetIteratorRef::GetEcmaRuntimeCallInfo(const EcmaVM *vm)
1781 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, nullptr);
1782 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1784 JSHandle<LinkedHashSet> linkedHashSet(vm->GetJSThread(), jsSetIter->GetIteratedSet());
1786 return ecmascript::EcmaInterpreter::NewRuntimeCallInfo(vm->GetJSThread(),
1787 JSHandle<JSTaggedValue>(vm->GetJSThread(), JSTaggedValue::Undefined()),
1788 JSHandle<JSTaggedValue>(vm->GetJSThread(), jsSetIter.GetTaggedValue()),
1789 JSHandle<JSTaggedValue>(vm->GetJSThread(), JSTaggedValue::Undefined()), size);
1792 Local<ArrayRef> SetIteratorRef::Next(const EcmaVM *vm, ecmascript::EcmaRuntimeCallInfo *ecmaRuntimeCallInfo)
1794 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1795 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1796 JSHandle<JSTaggedValue> nextTagValResult(vm->GetJSThread(), JSSetIterator::Next(ecmaRuntimeCallInfo));
1797 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
1798 JSHandle<JSTaggedValue> iteratorVal(vm->GetJSThread(),
1799 JSIterator::IteratorValue(vm->GetJSThread(), nextTagValResult).GetTaggedValue());
1804 Local<BufferRef> BufferRef::New(const EcmaVM *vm, int32_t length)
1806 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1807 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1808 ObjectFactory *factory = vm->GetFactory();
1810 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
1813 Local<StringRef> key = StringRef::NewFromUtf8(vm, "toString");
1818 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
1826 const EcmaVM *vm, void *buffer, int32_t length, const NativePointerCallback &deleter, void *data)
1828 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1829 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1830 ObjectFactory *factory = vm->GetFactory();
1833 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
1836 Local<StringRef> key = StringRef::NewFromUtf8(vm, "toString");
1841 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
1848 int32_t BufferRef::ByteLength(const EcmaVM *vm)
1851 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1856 void *BufferRef::GetBuffer(const EcmaVM *vm)
1859 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1904 Local<PromiseCapabilityRef> PromiseCapabilityRef::New(const EcmaVM *vm)
1906 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1907 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1908 JSHandle<GlobalEnv> globalEnv = vm->GetGlobalEnv();
1911 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
1915 Local<PromiseRef> PromiseCapabilityRef::GetPromise(const EcmaVM *vm)
1917 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
1924 bool PromiseCapabilityRef::Resolve(const EcmaVM *vm, uintptr_t value)
1926 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
1927 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1951 bool PromiseCapabilityRef::Resolve(const EcmaVM *vm, Local<JSValueRef> value)
1953 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
1954 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
1978 bool PromiseCapabilityRef::Reject(const EcmaVM *vm, uintptr_t reason)
1980 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
1981 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2006 bool PromiseCapabilityRef::Reject(const EcmaVM *vm, Local<JSValueRef> reason)
2008 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2009 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2035 Local<SymbolRef> SymbolRef::New(const EcmaVM *vm, Local<StringRef> description)
2039 CROSS_THREAD_CHECK(vm);
2040 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2041 ObjectFactory *factory = vm->GetFactory();
2050 Local<StringRef> SymbolRef::GetDescription(const EcmaVM *vm)
2052 CROSS_THREAD_CHECK(vm);
2053 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2065 Local<BooleanRef> BooleanRef::New(const EcmaVM *vm, bool value)
2069 CROSS_THREAD_CHECK(vm);
2070 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2083 Local<StringRef> StringRef::NewFromUtf8(const EcmaVM *vm, const char *utf8, int length)
2087 CROSS_THREAD_CHECK(vm);
2088 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2089 ObjectFactory *factory = vm->GetFactory();
2098 Local<StringRef> StringRef::NewFromUtf8WithoutStringTable(const EcmaVM *vm, const char *utf8, int length)
2101 CROSS_THREAD_CHECK(vm);
2102 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2103 ObjectFactory *factory = vm->GetFactory();
2113 Local<StringRef> StringRef::NewFromUtf16WithoutStringTable(const EcmaVM *vm, const char16_t *utf16, int length)
2117 CROSS_THREAD_CHECK(vm);
2118 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2119 ObjectFactory *factory = vm->GetFactory();
2129 Local<StringRef> StringRef::NewFromUtf16(const EcmaVM *vm, const char16_t *utf16, int length)
2133 CROSS_THREAD_CHECK(vm);
2134 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2135 ObjectFactory *factory = vm->GetFactory();
2144 std::string StringRef::ToString(const EcmaVM *vm)
2147 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2151 std::string StringRef::DebuggerToString(const EcmaVM *vm)
2154 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2158 uint32_t StringRef::Length(const EcmaVM *vm)
2161 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2165 size_t StringRef::Utf8Length(const EcmaVM *vm, bool isGetBufferSize)
2168 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2169 JSHandle<EcmaString> strHandle(vm->GetJSThread(), EcmaString::Cast(JSNApiHelper::ToJSTaggedValue(this)));
2170 return EcmaStringAccessor(EcmaStringAccessor::Flatten(vm, strHandle)).GetUtf8Length(isGetBufferSize);
2173 uint32_t StringRef::WriteUtf8(const EcmaVM *vm, char *buffer, uint32_t length, bool isWriteBuffer)
2176 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2181 uint32_t StringRef::WriteUtf16(const EcmaVM *vm, char16_t *buffer, uint32_t length)
2184 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2189 uint32_t StringRef::WriteLatin1(const EcmaVM *vm, char *buffer, uint32_t length)
2192 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2197 Local<StringRef> StringRef::GetNapiWrapperString(const EcmaVM *vm)
2201 CROSS_THREAD_CHECK(vm);
2202 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2207 Local<TypedArrayRef> StringRef::EncodeIntoUint8Array(const EcmaVM *vm)
2209 CROSS_THREAD_CHECK(vm);
2210 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2212 uint32_t length = this->Utf8Length(vm, true);
2215 return Undefined(vm);
2257 Local<BigIntRef> BigIntRef::New(const EcmaVM *vm, uint64_t input)
2261 CROSS_THREAD_CHECK(vm);
2262 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2268 Local<BigIntRef> BigIntRef::New(const EcmaVM *vm, int64_t input)
2272 CROSS_THREAD_CHECK(vm);
2273 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2279 Local<JSValueRef> BigIntRef::CreateBigWords(const EcmaVM *vm, bool sign, uint32_t size, const uint64_t* words)
2283 CROSS_THREAD_CHECK(vm);
2284 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2290 void BigIntRef::BigIntToInt64(const EcmaVM *vm, int64_t *value, bool *lossless)
2294 CROSS_THREAD_CHECK(vm);
2295 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2301 void BigIntRef::BigIntToUint64(const EcmaVM *vm, uint64_t *value, bool *lossless)
2305 CROSS_THREAD_CHECK(vm);
2306 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2312 void BigIntRef::GetWordsArray(const EcmaVM *vm, bool* signBit, size_t wordCount, uint64_t* words)
2315 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2334 uint32_t BigIntRef::GetWordsArraySize(const EcmaVM *vm)
2337 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2344 LocalScope::LocalScope(const EcmaVM *vm) : thread_(vm->GetJSThread())
2361 LocalScope::LocalScope(const EcmaVM *vm, JSTaggedType value) : thread_(vm->GetJSThread())
2403 EscapeLocalScope::EscapeLocalScope(const EcmaVM *vm) : LocalScope(vm, JSTaggedValue::Undefined().GetRawData())
2405 auto thread = vm->GetJSThread();
2411 Local<IntegerRef> IntegerRef::New(const EcmaVM *vm, int input)
2415 CROSS_THREAD_CHECK(vm);
2421 Local<IntegerRef> IntegerRef::NewFromUnsigned(const EcmaVM *vm, unsigned int input)
2425 CROSS_THREAD_CHECK(vm);
2439 Local<ObjectRef> ObjectRef::New(const EcmaVM *vm)
2441 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2442 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2443 ObjectFactory *factory = vm->GetFactory();
2444 JSHandle<GlobalEnv> globalEnv = vm->GetGlobalEnv();
2450 uintptr_t ObjectRef::NewObject(const EcmaVM *vm)
2452 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm,
2453 (vm->GetJSThread()->GlobalConstants()->GetHandledUndefined()).GetAddress());
2454 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2455 ObjectFactory *factory = vm->GetFactory();
2456 JSHandle<GlobalEnv> globalEnv = vm->GetGlobalEnv();
2462 Local<ObjectRef> ObjectRef::NewS(const EcmaVM *vm)
2464 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2465 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2466 ObjectFactory *factory = vm->GetFactory();
2467 JSHandle<GlobalEnv> globalEnv = vm->GetGlobalEnv();
2473 Local<ObjectRef> ObjectRef::NewWithProperties(const EcmaVM *vm, size_t propertyCount,
2477 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2478 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2479 EscapeLocalScope scope(vm);
2481 auto CreateObjImpl = [vm, propertyCount, keys, attributes] (uintptr_t head) -> JSHandle<JSTaggedValue> {
2482 JSThread *thread = vm->GetJSThread();
2487 JSNApiHelper::ToJSHandle(attr.GetValue(vm)),
2492 ObjectFactory *factory = vm->GetFactory();
2503 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2507 Local<ObjectRef> ObjectRef::NewSWithProperties(const EcmaVM *vm, SendablePropertiesInfo &info)
2509 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2510 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2511 EscapeLocalScope scope(vm);
2512 ObjectFactory *factory = vm->GetFactory();
2516 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2520 Local<ObjectRef> ObjectRef::NewWithNamedProperties(const EcmaVM *vm, size_t propertyCount,
2523 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2524 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2525 EscapeLocalScope scope(vm);
2526 ObjectFactory *factory = vm->GetFactory();
2528 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2532 Local<ObjectRef> ObjectRef::CreateNativeModuleFailureInfo(const EcmaVM *vm, const std::string &failureInfo)
2534 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2535 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2538 NativeModuleFailureInfo::CreateNativeModuleFailureInfo(vm, failureInfo);
2541 return JSValueRef::Undefined(vm);
2544 Local<ObjectRef> ObjectRef::CreateAccessorData(const EcmaVM *vm,
2547 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2548 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2557 Local<ObjectRef> ObjectRef::CreateSendableAccessorData(const EcmaVM *vm,
2561 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2571 bool ObjectRef::ConvertToNativeBindingObject(const EcmaVM *vm, Local<NativePointerRef> value)
2573 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2574 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2575 [[maybe_unused]] LocalScope scope(vm);
2578 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
2581 bool result = JSTaggedValue::SetProperty(vm->GetJSThread(), object, keyValue, valueValue);
2587 bool ObjectRef::Set(const EcmaVM *vm, Local<JSValueRef> key, Local<JSValueRef> value)
2589 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2590 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2591 [[maybe_unused]] LocalScope scope(vm);
2604 bool ObjectRef::Set(const EcmaVM *vm, const char *utf8, Local<JSValueRef> value)
2606 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2607 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2608 [[maybe_unused]] LocalScope scope(vm);
2611 ObjectFactory *factory = vm->GetFactory();
2639 bool ObjectRef::Set(const EcmaVM *vm, uint32_t key, Local<JSValueRef> value)
2641 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2642 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2643 [[maybe_unused]] LocalScope scope(vm);
2654 bool ObjectRef::SetAccessorProperty(const EcmaVM *vm, Local<JSValueRef> key, Local<FunctionRef> getter,
2657 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2658 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2659 [[maybe_unused]] LocalScope scope(vm);
2663 desc.SetValue(JSNApiHelper::ToJSHandle(attribute.GetValue(vm)));
2672 Local<JSValueRef> ObjectRef::Get(const EcmaVM *vm, Local<JSValueRef> key)
2674 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2675 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2678 LocalScope scope(vm);
2684 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2689 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2696 Local<JSValueRef> ObjectRef::Get(const EcmaVM *vm, const char *utf8)
2698 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2699 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2702 LocalScope scope(vm);
2705 ObjectFactory *factory = vm->GetFactory();
2709 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2714 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2721 Local<JSValueRef> ObjectRef::Get(const EcmaVM *vm, int32_t key)
2723 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2724 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2727 LocalScope scope(vm);
2732 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2736 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2743 bool ObjectRef::GetOwnProperty(const EcmaVM *vm, Local<JSValueRef> key, PropertyAttribute &property)
2745 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2746 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2775 Local<ArrayRef> ObjectRef::GetOwnPropertyNames(const EcmaVM *vm)
2777 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2778 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2782 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2787 Local<ArrayRef> ObjectRef::GetAllPropertyNames(const EcmaVM *vm, uint32_t filter)
2791 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2792 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2796 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2801 Local<ArrayRef> ObjectRef::GetOwnEnumerablePropertyNames(const EcmaVM *vm)
2803 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2804 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2808 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2813 Local<JSValueRef> ObjectRef::GetPrototype(const EcmaVM *vm)
2815 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2816 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2820 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
2824 bool ObjectRef::SetPrototype(const EcmaVM *vm, Local<ObjectRef> prototype)
2826 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2827 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2833 bool ObjectRef::DefineProperty(const EcmaVM *vm, Local<JSValueRef> key, PropertyAttribute attribute)
2835 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2836 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2841 desc.SetValue(JSNApiHelper::ToJSHandle(attribute.GetValue(vm)));
2845 bool ObjectRef::Has(const EcmaVM *vm, Local<JSValueRef> key)
2847 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2848 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2855 bool ObjectRef::Has(const EcmaVM *vm, uint32_t key)
2857 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2858 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2864 bool ObjectRef::HasOwnProperty(const EcmaVM *vm, Local<JSValueRef> key)
2866 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2867 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2874 bool ObjectRef::Delete(const EcmaVM *vm, Local<JSValueRef> key)
2876 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2877 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2884 bool ObjectRef::Delete(const EcmaVM *vm, uint32_t key)
2886 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
2887 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2894 Local<JSValueRef> ObjectRef::Freeze(const EcmaVM *vm)
2896 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2897 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2898 EscapeLocalScope scope(vm);
2903 if (JSNApi::HasPendingException(vm)) {
2909 Local<StringRef> message = StringRef::NewFromUtf8(vm, "Freeze: freeze failed");
2910 Local<JSValueRef> error = Exception::Error(vm, message);
2911 JSNApi::ThrowException(vm, error);
2919 Local<JSValueRef> ObjectRef::Seal(const EcmaVM *vm)
2921 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
2922 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2923 EscapeLocalScope scope(vm);
2928 if (JSNApi::HasPendingException(vm)) {
2934 Local<StringRef> message = StringRef::NewFromUtf8(vm, "Freeze: freeze failed");
2935 Local<JSValueRef> error = Exception::Error(vm, message);
2936 JSNApi::ThrowException(vm, error);
2944 void ObjectRef::SetNativePointerFieldCount(const EcmaVM *vm, int32_t count)
2946 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
2947 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2955 int32_t ObjectRef::GetNativePointerFieldCount(const EcmaVM *vm)
2960 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2965 void *ObjectRef::GetNativePointerField(const EcmaVM *vm, int32_t index)
2970 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2975 void ObjectRef::SetNativePointerField(const EcmaVM *vm, int32_t index, void *nativePointer,
2978 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
2979 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
2987 void ObjectRef::SetConcurrentNativePointerField(const EcmaVM *vm, int32_t index, void *nativePointer,
2990 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
2991 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3000 Local<NativePointerRef> NativePointerRef::New(const EcmaVM *vm, void *nativePointer, size_t nativeBindingsize)
3002 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3003 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3004 ObjectFactory *factory = vm->GetFactory();
3011 const EcmaVM *vm, void *nativePointer, NativePointerCallback callBack, void *data, size_t nativeBindingsize)
3013 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3014 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3015 ObjectFactory *factory = vm->GetFactory();
3022 const EcmaVM *vm, void *nativePointer, NativePointerCallback callBack, void *data, size_t nativeBindingsize)
3024 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3026 ObjectFactory *factory = vm->GetFactory();
3033 const EcmaVM *vm, void *nativePointer, NativePointerCallback callBack, void *data, size_t nativeBindingsize)
3035 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3036 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3037 ObjectFactory *factory = vm->GetFactory();
3051 Local<ArrayBufferRef> ArrayBufferRef::New(const EcmaVM *vm, int32_t length)
3053 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3054 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3055 ObjectFactory *factory = vm->GetFactory();
3061 const EcmaVM *vm, void *buffer, int32_t length, const NativePointerCallback &deleter, void *data)
3063 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3064 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3065 ObjectFactory *factory = vm->GetFactory();
3070 int32_t ArrayBufferRef::ByteLength(const EcmaVM *vm)
3072 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3073 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3079 void *ArrayBufferRef::GetBuffer(const EcmaVM *vm)
3082 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3091 void ArrayBufferRef::Detach(const EcmaVM *vm)
3093 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
3094 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3100 bool ArrayBufferRef::IsDetach(const EcmaVM *vm)
3103 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3108 Local<SendableArrayBufferRef> SendableArrayBufferRef::New(const EcmaVM *vm, int32_t length)
3110 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3111 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3112 ObjectFactory *factory = vm->GetFactory();
3118 const EcmaVM *vm, void *buffer, int32_t length, const NativePointerCallback &deleter, void *data)
3120 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3121 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3122 ObjectFactory *factory = vm->GetFactory();
3128 int32_t SendableArrayBufferRef::ByteLength(const EcmaVM *vm)
3130 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3131 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3137 void SendableArrayBufferRef::Detach(const EcmaVM *vm)
3139 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
3140 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3145 bool SendableArrayBufferRef::IsDetach(const EcmaVM *vm)
3148 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3153 void *SendableArrayBufferRef::GetBuffer(const EcmaVM *vm)
3156 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3166 Local<DateRef> DateRef::New(const EcmaVM *vm, double time)
3168 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3169 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3170 ObjectFactory *factory = vm->GetFactory();
3171 JSHandle<GlobalEnv> globalEnv = vm->GetGlobalEnv();
3178 Local<StringRef> DateRef::ToString(const EcmaVM *vm)
3180 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3181 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3193 double DateRef::GetTime(const EcmaVM *vm)
3196 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3205 uint32_t TypedArrayRef::ByteLength(const EcmaVM *vm)
3207 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3208 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3214 uint32_t TypedArrayRef::ByteOffset(const EcmaVM *vm)
3216 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3217 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3223 uint32_t TypedArrayRef::ArrayLength(const EcmaVM *vm)
3225 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3226 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3232 Local<ArrayBufferRef> TypedArrayRef::GetArrayBuffer(const EcmaVM *vm)
3234 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3242 uint32_t SendableTypedArrayRef::ByteLength(const EcmaVM *vm)
3244 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3245 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3251 uint32_t SendableTypedArrayRef::ByteOffset(const EcmaVM *vm)
3253 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3254 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3260 uint32_t SendableTypedArrayRef::ArrayLength(const EcmaVM *vm)
3262 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3263 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3269 Local<SendableArrayBufferRef> SendableTypedArrayRef::GetArrayBuffer(const EcmaVM *vm)
3271 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3281 Local<FunctionRef> FunctionRef::New(EcmaVM *vm, FunctionCallback nativeFunc,
3284 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3285 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3286 ObjectFactory *factory = vm->GetFactory();
3287 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3294 Local<FunctionRef> FunctionRef::NewConcurrent(EcmaVM *vm, FunctionCallback nativeFunc,
3297 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3299 ObjectFactory *factory = vm->GetFactory();
3300 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3308 Local<FunctionRef> FunctionRef::New(EcmaVM *vm, InternalFunctionCallback nativeFunc,
3311 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3312 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3313 ObjectFactory *factory = vm->GetFactory();
3314 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3321 Local<FunctionRef> FunctionRef::NewSendable(EcmaVM *vm,
3328 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3330 ObjectFactory *factory = vm->GetFactory();
3331 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3338 Local<FunctionRef> FunctionRef::NewConcurrent(EcmaVM *vm, InternalFunctionCallback nativeFunc,
3341 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3343 ObjectFactory *factory = vm->GetFactory();
3344 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3351 static void InitClassFunction(EcmaVM *vm, JSHandle<JSFunction> &func, bool callNapi)
3353 CROSS_THREAD_CHECK(vm);
3354 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3355 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3372 Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, FunctionCallback nativeFunc,
3375 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3376 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3377 EscapeLocalScope scope(vm);
3378 ObjectFactory *factory = vm->GetFactory();
3379 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3384 InitClassFunction(vm, current, callNapi);
3390 Local<FunctionRef> FunctionRef::NewConcurrentClassFunction(EcmaVM *vm, InternalFunctionCallback nativeFunc,
3393 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3394 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3395 EscapeLocalScope scope(vm);
3396 ObjectFactory *factory = vm->GetFactory();
3397 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3402 InitClassFunction(vm, current, callNapi);
3408 Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, InternalFunctionCallback nativeFunc,
3411 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3412 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3413 EscapeLocalScope scope(vm);
3414 ObjectFactory *factory = vm->GetFactory();
3415 JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3420 InitClassFunction(vm, current, callNapi);
3426 Local<FunctionRef> FunctionRef::NewSendableClassFunction(const EcmaVM *vm,
3436 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3438 EscapeLocalScope scope(vm);
3439 ObjectFactory *factory = vm->GetFactory();
3454 auto parentPrototype = parent->GetFunctionPrototype(vm);
3480 Local<JSValueRef> FunctionRef::Call(const EcmaVM *vm, Local<JSValueRef> thisObj,
3484 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3485 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3486 EscapeLocalScope scope(vm);
3487 FunctionCallScope callScope(EcmaVM::ConstCast(vm));
3488 if (!IsFunction(vm)) {
3489 return JSValueRef::Undefined(vm);
3491 vm->GetJsDebuggerManager()->ClearSingleStepper();
3498 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
3513 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
3517 vm->GetJsDebuggerManager()->NotifyReturnNative();
3521 JSValueRef* FunctionRef::CallForNapi(const EcmaVM *vm, JSValueRef *thisObj,
3525 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, *JSValueRef::Hole(vm));
3528 FunctionCallScope callScope(EcmaVM::ConstCast(vm));
3529 ASSERT(IsFunction(vm)); // IsFunction check has been done in napi.
3531 LocalScope scope(vm);
3532 ecmascript::tooling::JsDebuggerManager *dm = vm->GetJsDebuggerManager();
3545 RETURN_VALUE_IF_ABRUPT(thread, *JSValueRef::Hole(vm));
3556 STACK_LIMIT_CHECK(thread, reinterpret_cast<JSValueRef *>(*JSValueRef::Hole(vm)));
3561 reinterpret_cast<JSValueRef *>(*JSValueRef::Hole(vm)));
3570 RETURN_VALUE_IF_ABRUPT(thread, *JSValueRef::Hole(vm));
3582 Local<JSValueRef> FunctionRef::Constructor(const EcmaVM *vm,
3586 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3587 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3588 FunctionCallScope callScope(EcmaVM::ConstCast(vm));
3589 if (!IsFunction(vm)) {
3590 return JSValueRef::Undefined(vm);
3598 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
3610 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
3615 JSValueRef* FunctionRef::ConstructorOptimize(const EcmaVM *vm,
3619 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, *JSValueRef::Undefined(vm));
3620 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3622 FunctionCallScope callScope(EcmaVM::ConstCast(vm));
3623 ASSERT(IsFunction(vm)); // IsFunction check has been done in napi.
3625 LocalScope scope(vm);
3631 RETURN_VALUE_IF_ABRUPT(thread, *JSValueRef::Undefined(vm));
3641 RETURN_VALUE_IF_ABRUPT(thread, *JSValueRef::Undefined(vm));
3650 Local<JSValueRef> FunctionRef::GetFunctionPrototype(const EcmaVM *vm)
3652 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3653 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3660 bool FunctionRef::Inherit(const EcmaVM *vm, Local<FunctionRef> parent)
3662 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
3663 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3664 [[maybe_unused]] LocalScope scope(vm);
3680 void FunctionRef::SetName(const EcmaVM *vm, Local<StringRef> name)
3682 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
3683 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3684 [[maybe_unused]] LocalScope scope(vm);
3690 Local<StringRef> FunctionRef::GetName(const EcmaVM *vm)
3692 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3693 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3694 EscapeLocalScope scope(vm);
3697 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
3701 Local<StringRef> FunctionRef::GetSourceCode(const EcmaVM *vm, int lineNumber)
3703 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3704 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3705 EscapeLocalScope scope(vm);
3738 bool FunctionRef::IsNative(const EcmaVM *vm)
3740 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
3741 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3747 void FunctionRef::SetData(const EcmaVM *vm, void *data, NativePointerCallback deleter, [[maybe_unused]] bool callNapi)
3749 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
3750 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3760 void* FunctionRef::GetData(const EcmaVM *vm)
3762 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, nullptr);
3763 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3775 Local<ArrayRef> ArrayRef::New(const EcmaVM *vm, uint32_t length)
3777 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3778 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3781 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
3785 uint32_t ArrayRef::Length(const EcmaVM *vm)
3787 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3791 Local<JSValueRef> ArrayRef::GetValueAt(const EcmaVM *vm, Local<JSValueRef> obj, uint32_t index)
3793 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3794 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3800 bool ArrayRef::SetValueAt(const EcmaVM *vm, Local<JSValueRef> obj, uint32_t index, Local<JSValueRef> value)
3802 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
3803 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3810 Local<SendableArrayRef> SendableArrayRef::New(const EcmaVM *vm, uint32_t length)
3812 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3813 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3823 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
3827 uint32_t SendableArrayRef::Length(const EcmaVM *vm)
3829 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, 0);
3830 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3834 Local<JSValueRef> SendableArrayRef::GetValueAt(const EcmaVM *vm, Local<JSValueRef> obj, uint32_t index)
3836 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
3837 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3843 bool SendableArrayRef::SetProperty(const EcmaVM *vm, Local<JSValueRef> obj, uint32_t index, Local<JSValueRef> value)
3845 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
3846 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3856 Local<JSValueRef> Exception::name(const EcmaVM *vm, Local<StringRef> message) \
3858 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm)); \
3859 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread()); \
3860 ObjectFactory *factory = vm->GetFactory(); \
3874 FunctionCallScope::FunctionCallScope(EcmaVM *vm) : vm_(vm)
3890 JSExecutionScope::JSExecutionScope([[maybe_unused]] const EcmaVM *vm)
3902 JsiNativeScope::JsiNativeScope(const EcmaVM *vm)
3904 thread_ = vm->GetAssociatedJSThread();
3906 if (vm->IsCollectingScopeLockStats()) {
3907 const_cast<EcmaVM*>(vm)->IncreaseEnterJsiNativeScopeCount();
3908 const_cast<EcmaVM*>(vm)->IncreaseUpdateThreadStateTransCount();
3922 JsiFastNativeScope::JsiFastNativeScope(const EcmaVM *vm)
3924 thread_ = vm->GetAssociatedJSThread();
3926 if (vm->IsCollectingScopeLockStats()) {
3927 const_cast<EcmaVM*>(vm)->IncreaseEnterFastNativeScopeCount();
3928 const_cast<EcmaVM*>(vm)->IncreaseUpdateThreadStateTransCount();
3969 PatchErrorCode JSNApi::LoadPatch(EcmaVM *vm, const std::string &patchFileName, const std::string &baseFileName)
3971 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, PatchErrorCode::INTERNAL_ERROR);
3972 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3973 ecmascript::QuickFixManager *quickFixManager = vm->GetQuickFixManager();
3977 PatchErrorCode JSNApi::LoadPatch(EcmaVM *vm,
3981 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, PatchErrorCode::INTERNAL_ERROR);
3982 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3983 ecmascript::QuickFixManager *quickFixManager = vm->GetQuickFixManager();
3988 PatchErrorCode JSNApi::UnloadPatch(EcmaVM *vm, const std::string &patchFileName)
3990 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, PatchErrorCode::INTERNAL_ERROR);
3991 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
3992 ecmascript::QuickFixManager *quickFixManager = vm->GetQuickFixManager();
3999 bool JSNApi::IsQuickFixCausedException(EcmaVM *vm, Local<ObjectRef> exception, const std::string &patchFileName)
4004 CROSS_THREAD_CHECK(vm);
4006 ecmascript::QuickFixManager *quickFixManager = vm->GetQuickFixManager();
4014 void JSNApi::RegisterQuickFixQueryFunc(EcmaVM *vm, std::function<bool(std::string baseFileName,
4019 CROSS_THREAD_CHECK(vm);
4020 ecmascript::QuickFixManager *quickFixManager = vm->GetQuickFixManager();
4024 bool JSNApi::IsBundle(EcmaVM *vm)
4026 return vm->IsBundlePack();
4029 void JSNApi::SetBundle(EcmaVM *vm, bool value)
4031 vm->SetIsBundlePack(value);
4034 bool JSNApi::IsNormalizedOhmUrlPack(EcmaVM *vm)
4036 return vm->IsNormalizedOhmUrlPack();
4044 void JSNApi::SetModuleInfo(EcmaVM *vm, const std::string &assetPath, const std::string &entryPoint)
4046 SetAssetPath(vm, assetPath);
4049 SetBundleName(vm, entryPoint.substr(0, pos));
4052 SetModuleName(vm, moduleName.c_str());
4058 Local<StringRef> message = StringRef::NewFromUtf8(vm, errmsg.c_str());
4059 Local<JSValueRef> error = Exception::Error(vm, message);
4060 JSNApi::ThrowException(vm, error);
4064 void JSNApi::SetAssetPath(EcmaVM *vm, const std::string &assetPath)
4073 vm->SetAssetPath(path);
4076 void JSNApi::SetLoop(EcmaVM *vm, void *loop)
4078 vm->SetLoop(loop);
4081 void JSNApi::SetWeakFinalizeTaskCallback(EcmaVM *vm, const WeakFinalizeTaskCallback &callback)
4083 vm->GetAssociatedJSThread()->SetWeakFinalizeTaskCallback(callback);
4086 void JSNApi::SetAsyncCleanTaskCallback(EcmaVM *vm, const NativePointerTaskCallback &callback)
4088 vm->GetAssociatedJSThread()->SetAsyncCleanTaskCallback(callback);
4091 void JSNApi::SetTriggerGCTaskCallback(EcmaVM *vm, const TriggerGCTaskCallback& callback)
4093 vm->GetHeap()->GetIdleGCTrigger()->SetTriggerGCTaskCallback(callback);
4096 std::string JSNApi::GetAssetPath(EcmaVM *vm)
4098 return vm->GetAssetPath().c_str();
4101 void JSNApi::SetMockModuleList(EcmaVM *vm, const std::map<std::string, std::string> &list)
4103 vm->SetMockModuleList(list);
4106 void JSNApi::SetHmsModuleList(EcmaVM *vm, const std::vector<panda::HmsMap> &list)
4108 vm->SetHmsModuleList(list);
4111 void JSNApi::SetPkgAliasList(EcmaVM *vm, const std::map<std::string, std::string> &list)
4117 vm->SetPkgAliasList(pkgAliasList);
4120 void JSNApi::SetPkgNameList(EcmaVM *vm, const std::map<std::string, std::string> &list)
4126 vm->SetPkgNameList(pkgNameList);
4128 std::string JSNApi::GetPkgName(EcmaVM *vm, const std::string &moduleName)
4130 return vm->GetPkgName(moduleName.c_str()).c_str();
4133 void JSNApi::SetpkgContextInfoList(EcmaVM *vm, const std::map<std::string,
4151 vm->SetpkgContextInfoList(pkgContextInfoList);
4155 void JSNApi::SetExecuteBufferMode(const EcmaVM *vm)
4158 vm->GetAssociatedJSThread()->GetCurrentEcmaContext()->GetModuleManager();
4162 bool JSNApi::InitForConcurrentThread(EcmaVM *vm, ConcurrentCallback cb, void *data)
4164 vm->SetConcurrentCallback(cb, data);
4169 bool JSNApi::InitForConcurrentFunction(EcmaVM *vm, Local<JSValueRef> function, void *taskInfo)
4171 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
4172 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
4173 [[maybe_unused]] LocalScope scope(vm);
4186 void* JSNApi::GetCurrentTaskInfo(const EcmaVM *vm)
4188 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, nullptr);
4192 void JSNApi::ClearCurrentTaskInfo(const EcmaVM *vm)
4194 JSThread *thread = vm->GetJSThread();
4199 void JSNApi::SetBundleName(EcmaVM *vm, const std::string &bundleName)
4202 vm->SetBundleName(name);
4205 std::string JSNApi::GetBundleName(EcmaVM *vm)
4207 return vm->GetBundleName().c_str();
4210 void JSNApi::SetModuleName(EcmaVM *vm, const std::string &moduleName)
4214 vm->SetModuleName(name);
4217 std::string JSNApi::GetModuleName(EcmaVM *vm)
4219 return vm->GetModuleName().c_str();
4222 std::pair<std::string, std::string> JSNApi::GetCurrentModuleInfo(EcmaVM *vm, bool needRecordName)
4224 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
4225 return vm->GetCurrentModuleInfo(needRecordName);
4234 void JSNApi::AllowCrossThreadExecution(EcmaVM *vm)
4237 vm->GetAssociatedJSThread()->EnableCrossThreadExecution();
4240 void* JSNApi::GetEnv(EcmaVM *vm)
4242 JSThread *thread = vm->GetJSThread();
4246 void JSNApi::SetEnv(EcmaVM *vm, void *env)
4248 JSThread *thread = vm->GetJSThread();
4252 void JSNApi::SynchronizVMInfo(EcmaVM *vm, const EcmaVM *hostVM)
4255 vm->SetBundleName(hostVM->GetBundleName());
4256 vm->SetModuleName(hostVM->GetModuleName());
4257 vm->SetAssetPath(hostVM->GetAssetPath());
4258 vm->SetIsBundlePack(hostVM->IsBundlePack());
4259 vm->SetPkgNameList(hostVM->GetPkgNameList());
4260 vm->SetPkgAliasList(hostVM->GetPkgAliasList());
4261 vm->SetpkgContextInfoList(hostVM->GetPkgContextInfoLit());
4264 vm->GetAssociatedJSThread()->GetCurrentEcmaContext()->GetModuleManager();
4268 vm->SetResolveBufferCallback(hostVM->GetResolveBufferCallback());
4271 bool JSNApi::IsProfiling(EcmaVM *vm)
4273 return vm->GetProfilerState();
4276 void JSNApi::SetProfilerState(const EcmaVM *vm, bool value)
4278 const_cast<EcmaVM*>(vm)->SetProfilerState(value);
4281 void JSNApi::SetSourceMapTranslateCallback(EcmaVM *vm, SourceMapTranslateCallback callback)
4283 vm->SetSourceMapTranslateCallback(callback);
4286 void JSNApi::SetSourceMapCallback(EcmaVM *vm, SourceMapCallback callback)
4288 vm->SetSourceMapCallback(callback);
4291 void JSNApi::GetStackBeforeCallNapiSuccess([[maybe_unused]] EcmaVM *vm,
4295 JSThread *thread = vm->GetJSThread();
4298 getStackBeforeCallNapiSuccess = vm->GetProfiler()->GetStackBeforeCallNapi(thread);
4303 void JSNApi::GetStackAfterCallNapi([[maybe_unused]] EcmaVM *vm)
4306 JSThread *thread = vm->GetJSThread();
4309 vm->GetProfiler()->GetStackAfterCallNapi(thread);
4345 EcmaContext *JSNApi::CreateJSContext(EcmaVM *vm)
4347 JSThread *thread = vm->GetJSThread();
4352 void JSNApi::SwitchCurrentContext(EcmaVM *vm, EcmaContext *context)
4354 JSThread *thread = vm->GetJSThread();
4359 void JSNApi::DestroyJSContext(EcmaVM *vm, EcmaContext *context)
4361 JSThread *thread = vm->GetJSThread();
4385 void JSNApi::TriggerGC(const EcmaVM *vm, TRIGGER_GC_TYPE gcType)
4387 TriggerGC(vm, ecmascript::GCReason::EXTERNAL_TRIGGER, gcType);
4390 void JSNApi::TriggerGC(const EcmaVM *vm, ecmascript::GCReason reason, TRIGGER_GC_TYPE gcType)
4392 CROSS_THREAD_CHECK(vm);
4393 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
4394 if (thread != nullptr && vm->IsInitialized()) {
4406 vm->CollectGarbage(vm->GetHeap()->SelectGCType(), reason);
4409 vm->CollectGarbage(ecmascript::TriggerGCType::OLD_GC, reason);
4412 vm->CollectGarbage(ecmascript::TriggerGCType::FULL_GC, reason);
4428 void JSNApi::HintGC(const EcmaVM *vm, MemoryReduceDegree degree, ecmascript::GCReason reason)
4430 CROSS_THREAD_CHECK(vm);
4431 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
4432 if (thread != nullptr && vm->IsInitialized()) {
4433 const_cast<ecmascript::Heap *>(vm->GetHeap())->CheckAndTriggerHintGC(degree, reason);
4437 void JSNApi::TriggerIdleGC(const EcmaVM *vm, TRIGGER_IDLE_GC_TYPE gcType)
4439 CROSS_THREAD_CHECK(vm);
4440 if (thread != nullptr && vm->IsInitialized()) {
4441 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
4442 vm->GetHeap()->GetIdleGCTrigger()->TryTriggerIdleGC(gcType);
4456 void JSNApi::ThrowException(const EcmaVM *vm, Local<JSValueRef> error)
4458 auto thread = vm->GetJSThread();
4467 void JSNApi::PrintExceptionInfo(const EcmaVM *vm)
4469 JSThread* thread = vm->GetJSThread();
4473 if (!HasPendingException(vm)) {
4476 Local<ObjectRef> exception = GetAndClearUncaughtException(vm);
4479 vm->PrintJSErrorInfo(exceptionHandle);
4480 ThrowException(vm, exception);
4486 ThrowException(vm, exception);
4490 bool JSNApi::StartDebuggerCheckParameters(EcmaVM *vm, const DebugOption &option, int32_t instanceId,
4493 if (vm == nullptr) {
4494 LOG_ECMA(ERROR) << "[StartDebugger] vm is nullptr";
4502 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
4503 const auto &handler = vm->GetJsDebuggerManager()->GetDebugLibraryHandle();
4525 vm->GetJsDebuggerManager()->SetDebugMode(option.isDebugMode);
4526 vm->GetJsDebuggerManager()->SetIsDebugApp(true);
4527 vm->GetJsDebuggerManager()->SetDebugLibraryHandle(std::move(handle.Value()));
4529 "PandaDebugger", vm, option.isDebugMode, instanceId, debuggerPostTask, option.port);
4532 vm->GetJsDebuggerManager()->SetDebugMode(false);
4534 vm->GetJsDebuggerManager()->SetDebugLibraryHandle(std::move(libraryHandle));
4541 bool JSNApi::StartDebugger([[maybe_unused]] EcmaVM *vm, [[maybe_unused]] const DebugOption &option,
4549 return StartDebuggerCheckParameters(vm, option, instanceId, debuggerPostTask);
4551 if (vm == nullptr) {
4554 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
4555 vm->GetJsDebuggerManager()->SetDebugMode(option.isDebugMode);
4557 DEBUGGER_NAME, vm, option.isDebugMode, instanceId, debuggerPostTask, option.port);
4560 vm->GetJsDebuggerManager()->SetDebugMode(false);
4572 bool JSNApi::StartDebuggerForOldProcess([[maybe_unused]] EcmaVM *vm, [[maybe_unused]] const DebugOption &option,
4580 if (vm == nullptr) {
4581 LOG_ECMA(ERROR) << "[StartDebuggerForOldProcess] vm is nullptr";
4584 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
4585 const auto &handle = vm->GetJsDebuggerManager()->GetDebugLibraryHandle();
4601 "PandaDebugger", vm, option.isDebugMode, instanceId, debuggerPostTask, option.port);
4604 vm->GetJsDebuggerManager()->SetDebugMode(false);
4606 vm->GetJsDebuggerManager()->SetDebugLibraryHandle(std::move(libraryHandle));
4610 if (vm == nullptr) {
4611 LOG_ECMA(ERROR) << "[StartDebuggerForOldProcess] vm is nullptr";
4614 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
4615 vm->GetJsDebuggerManager()->SetDebugMode(option.isDebugMode);
4617 DEBUGGER_NAME, vm, option.isDebugMode, instanceId, debuggerPostTask, option.port);
4620 vm->GetJsDebuggerManager()->SetDebugMode(false);
4676 [[maybe_unused]] EcmaVM *vm,
4685 if (vm == nullptr) {
4686 LOG_ECMA(ERROR) << "[NotifyDebugMode] vm is nullptr";
4689 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
4700 JsDebuggerManager *jsDebuggerManager = vm->GetJsDebuggerManager();
4711 ret = StartDebuggerForOldProcess(vm, option, instanceId, debuggerPostTask);
4725 reinterpret_cast<StoreDebuggerInfo>(symOfStoreDebuggerInfo.Value())(tid, vm, debuggerPostTask);
4737 if (!reinterpret_cast<InitializeDebuggerForSocketpair>(sym.Value())(vm)) {
4752 reinterpret_cast<WaitForDebugger>(symOfWaitForDebugger.Value())(vm);
4767 [[maybe_unused]] EcmaVM *vm,
4774 if (vm == nullptr) {
4775 LOG_ECMA(ERROR) << "[StoreDebugInfo] vm is nullptr";
4779 JsDebuggerManager *jsDebuggerManager = vm->GetJsDebuggerManager();
4808 reinterpret_cast<StoreDebuggerInfo>(symOfStoreDebuggerInfo.Value())(tid, vm, debuggerPostTask);
4816 ret = reinterpret_cast<InitializeDebuggerForSocketpair>(sym.Value())(vm);
4819 vm->GetJsDebuggerManager()->SetDebugMode(false);
4829 bool JSNApi::StopDebugger([[maybe_unused]] EcmaVM *vm)
4834 if (vm == nullptr) {
4835 LOG_ECMA(ERROR) << "[StopDebugger] vm is nullptr";
4838 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
4840 const auto &handle = vm->GetJsDebuggerManager()->GetDebugLibraryHandle();
4850 reinterpret_cast<StopDebug>(sym.Value())(vm);
4852 vm->GetJsDebuggerManager()->SetDebugMode(false);
4853 uint32_t tid = vm->GetTid();
4857 if (vm == nullptr) {
4858 LOG_ECMA(ERROR) << "[StopDebugger] vm is nullptr";
4861 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
4863 OHOS::ArkCompiler::Toolchain::StopDebug(vm);
4864 vm->GetJsDebuggerManager()->SetDebugMode(false);
4902 bool JSNApi::IsMixedDebugEnabled([[maybe_unused]] const EcmaVM *vm)
4905 return vm->GetJsDebuggerManager()->IsMixedDebugEnabled();
4911 bool JSNApi::IsDebugModeEnabled([[maybe_unused]] const EcmaVM *vm)
4914 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
4915 if (vm != nullptr && vm->GetJsDebuggerManager() != nullptr) {
4916 return vm->GetJsDebuggerManager()->IsDebugMode();
4925 void JSNApi::NotifyNativeCalling([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] const void *nativeAddress)
4928 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
4929 vm->GetJsDebuggerManager()->GetNotificationManager()->NativeCallingEvent(nativeAddress);
4935 void JSNApi::NotifyNativeReturn([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] const void *nativeAddress)
4938 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
4939 vm->GetJsDebuggerManager()->GetNotificationManager()->NativeReturnEvent(nativeAddress);
4945 void JSNApi::NotifyLoadModule([[maybe_unused]] const EcmaVM *vm)
4948 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
4950 vm->GetJsDebuggerManager()->ClearSingleStepper();
4956 void JSNApi::NotifyUIIdle(const EcmaVM *vm, [[maybe_unused]] int idleTime)
4958 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
4959 vm->GetHeap()->GetIdleGCTrigger()->NotifyVsyncIdleStart();
4962 void JSNApi::NotifyLooperIdleStart(const EcmaVM *vm, int64_t timestamp, int idleTime)
4964 if (vm->IsPostForked()) {
4965 vm->GetHeap()->GetIdleGCTrigger()->NotifyLooperIdleStart(timestamp, idleTime);
4969 void JSNApi::NotifyLooperIdleEnd(const EcmaVM *vm, int64_t timestamp)
4971 if (vm->IsPostForked()) {
4972 vm->GetHeap()->GetIdleGCTrigger()->NotifyLooperIdleEnd(timestamp);
4976 bool JSNApi::IsJSMainThreadOfEcmaVM(const EcmaVM *vm)
4978 return vm->GetJSThread()->IsMainThreadFast();
4981 void JSNApi::SetDeviceDisconnectCallback(EcmaVM *vm, DeviceDisconnectCallback cb)
4983 vm->SetDeviceDisconnectCallback(cb);
4999 bool JSNApi::IsSerializationTimeoutCheckEnabled(const EcmaVM *vm)
5001 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5003 if (const_cast<EcmaVM *>(vm)->GetJSOptions().EnableSerializationTimeoutCheck()) {
5008 auto jsDebuggerManager = vm->GetJsDebuggerManager();
5017 void JSNApi::GenerateTimeoutTraceIfNeeded(const EcmaVM *vm, std::chrono::system_clock::time_point &start,
5020 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
5024 (std::chrono::milliseconds(vm->GetJsDebuggerManager()->GetSerializationCheckThreshold())).count();
5038 void JSNApi::LoadAotFileInternal(EcmaVM *vm, const std::string &moduleName, std::string &aotFileName)
5040 if (vm->GetJSOptions().WasAOTOutputFileSet()) {
5041 aotFileName = vm->GetJSOptions().GetAOTOutputFile();
5044 else if (vm->GetJSOptions().GetEnableAOT())
5052 ecmascript::SearchHapPathCallBack callback = vm->GetSearchHapPathCallBack();
5069 void JSNApi::LoadAotFile(EcmaVM *vm, const std::string &moduleName)
5071 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
5075 LoadAotFileInternal(vm, moduleName, aotFileName);
5078 vm->DisablePGOProfilerWithAOTFile(aotFileName);
5084 void JSNApi::LoadAotFile(EcmaVM *vm, [[maybe_unused]] const std::string &bundleName, const std::string &moduleName,
5087 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
5091 LoadAotFileInternal(vm, moduleName, aotFileName);
5096 bool JSNApi::ExecuteInContext(EcmaVM *vm, const std::string &fileName, const std::string &entry, bool needUpdate)
5098 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5116 bool JSNApi::ExecuteForAbsolutePath(const EcmaVM *vm, const std::string &fileName, const std::string &entry,
5119 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5135 bool JSNApi::Execute(const EcmaVM *vm, const std::string &fileName, const std::string &entry,
5138 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5155 bool JSNApi::Execute(EcmaVM *vm, const uint8_t *data, int32_t size, const std::string &entry,
5158 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5173 int JSNApi::ExecuteWithSingletonPatternFlag(EcmaVM *vm, const std::string &bundleName,
5176 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, ecmascript::JSPandaFileExecutor::ROUTE_INTERNAL_ERROR);
5191 bool JSNApi::IsExecuteModuleInAbcFile(EcmaVM *vm, const std::string &bundleName,
5194 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5202 bool JSNApi::ExecuteModuleBuffer(EcmaVM *vm, const uint8_t *data, int32_t size, const std::string &filename,
5205 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5226 bool JSNApi::ExecuteSecureWithOhmUrl(EcmaVM *vm, uint8_t *data, int32_t size, const std::string &srcFilename,
5229 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5259 bool JSNApi::ExecuteSecure(EcmaVM *vm, uint8_t *data, int32_t size, const std::string &entry,
5262 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5278 bool JSNApi::ExecuteModuleBufferSecure(EcmaVM *vm, uint8_t* data, int32_t size, const std::string &filename,
5281 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5296 void JSNApi::PreFork(EcmaVM *vm)
5298 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5299 vm->PreFork();
5317 void JSNApi::PostFork(EcmaVM *vm, const RuntimeOption &option)
5320 JSRuntimeOptions &jsOption = vm->GetJSOptions();
5350 vm->PostFork();
5369 Local<ObjectRef> JSNApi::GetUncaughtException(const EcmaVM *vm)
5371 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
5372 return JSNApiHelper::ToLocal<ObjectRef>(vm->GetEcmaUncaughtException());
5375 Local<ObjectRef> JSNApi::GetAndClearUncaughtException(const EcmaVM *vm)
5377 if (!HasPendingException(vm)) {
5380 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
5381 return JSNApiHelper::ToLocal<ObjectRef>(vm->GetAndClearEcmaUncaughtException());
5384 bool JSNApi::HasPendingException(const EcmaVM *vm)
5386 return vm->GetJSThread()->HasPendingException();
5389 bool JSNApi::IsExecutingPendingJob(const EcmaVM *vm)
5391 return vm->GetAssociatedJSThread()->GetCurrentEcmaContext()->IsExecutingPendingJob();
5394 bool JSNApi::HasPendingJob(const EcmaVM *vm)
5396 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
5397 return vm->GetAssociatedJSThread()->GetCurrentEcmaContext()->HasPendingJob();
5400 void JSNApi::EnableUserUncaughtErrorHandler(EcmaVM *vm)
5402 return vm->GetJSThread()->GetCurrentEcmaContext()->EnableUserUncaughtErrorHandler();
5405 Local<ObjectRef> JSNApi::GetGlobalObject(const EcmaVM *vm)
5407 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5408 JSHandle<GlobalEnv> globalEnv = vm->GetGlobalEnv();
5409 JSHandle<JSTaggedValue> global(vm->GetJSThread(), globalEnv->GetGlobalObject());
5413 void JSNApi::ExecutePendingJob(const EcmaVM *vm)
5415 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
5416 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
5417 EcmaVM::ConstCast(vm)->GetJSThread()->GetCurrentEcmaContext()->ExecutePromisePendingJob();
5420 uintptr_t JSNApi::GetHandleAddr(const EcmaVM *vm, uintptr_t localAddress)
5425 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5426 CROSS_THREAD_CHECK(vm);
5431 uintptr_t JSNApi::GetGlobalHandleAddr(const EcmaVM *vm, uintptr_t localAddress)
5436 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5437 CROSS_THREAD_CHECK(vm);
5442 int JSNApi::GetStartRealTime(const EcmaVM *vm)
5444 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5445 return vm->GetProcessStartRealtime();
5448 void JSNApi::NotifyTaskBegin(const EcmaVM *vm)
5450 const_cast<ecmascript::Heap *>(vm->GetHeap())->NotifyRecordMemorySize();
5453 void JSNApi::NotifyTaskFinished(const EcmaVM *vm)
5455 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5456 const_cast<ecmascript::Heap *>(vm->GetHeap())->CheckAndTriggerTaskFinishedGC();
5459 bool JSNApi::IsMultiThreadCheckEnabled(const EcmaVM *vm)
5461 return vm->GetThreadCheckStatus();
5469 uintptr_t JSNApi::SetWeak(const EcmaVM *vm, uintptr_t localAddress)
5474 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5475 CROSS_THREAD_CHECK(vm);
5479 uintptr_t JSNApi::SetWeakCallback(const EcmaVM *vm, uintptr_t localAddress, void *ref,
5485 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5486 CROSS_THREAD_CHECK(vm);
5490 uintptr_t JSNApi::ClearWeak(const EcmaVM *vm, uintptr_t localAddress)
5495 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5501 CROSS_THREAD_CHECK(vm);
5505 bool JSNApi::IsWeak(const EcmaVM *vm, uintptr_t localAddress)
5510 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5511 CROSS_THREAD_CHECK(vm);
5515 void JSNApi::DisposeGlobalHandleAddr(const EcmaVM *vm, uintptr_t addr)
5521 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5522 CROSS_THREAD_CHECK(vm);
5526 void *JSNApi::SerializeValue(const EcmaVM *vm, Local<JSValueRef> value, Local<JSValueRef> transfer,
5529 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, nullptr);
5530 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5534 bool serializationTimeoutCheckEnabled = IsSerializationTimeoutCheckEnabled(vm);
5547 GenerateTimeoutTraceIfNeeded(vm, startTime, endTime, true);
5556 Local<JSValueRef> JSNApi::DeserializeValue(const EcmaVM *vm, void *recoder, void *hint)
5558 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5559 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5562 bool serializationTimeoutCheckEnabled = IsSerializationTimeoutCheckEnabled(vm);
5571 GenerateTimeoutTraceIfNeeded(vm, startTime, endTime, false);
5583 void HostPromiseRejectionTracker(const EcmaVM *vm,
5589 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
5600 void JSNApi::SetHostPromiseRejectionTracker(EcmaVM *vm, void *cb, void* data)
5602 CROSS_THREAD_CHECK(vm);
5609 void JSNApi::SetHostResolveBufferTracker(EcmaVM *vm,
5612 vm->SetResolveBufferCallback(cb);
5615 void JSNApi::SetSearchHapPathTracker(EcmaVM *vm,
5618 vm->SetSearchHapPathCallBack(cb);
5631 void JSNApi::SetRequestAotCallback([[maybe_unused]] EcmaVM *vm, const std::function<int32_t
5637 void JSNApi::SetUnloadNativeModuleCallback(EcmaVM *vm, const std::function<bool(const std::string &moduleKey)> &cb)
5639 vm->SetUnloadNativeModuleCallback(cb);
5642 void JSNApi::SetNativePtrGetter(EcmaVM *vm, void* cb)
5644 vm->SetNativePtrGetter(reinterpret_cast<ecmascript::NativePtrGetter>(cb));
5647 void JSNApi::SetHostEnqueueJob(const EcmaVM *vm, Local<JSValueRef> cb, QueueType queueType)
5649 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
5650 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5652 JSHandle<TaggedArray> array = vm->GetFactory()->EmptyArray();
5657 bool JSNApi::ExecuteModuleFromBuffer(EcmaVM *vm, const void *data, int32_t size, const std::string &file)
5659 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
5660 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5672 Local<JSValueRef> JSNApi::NapiHasProperty(const EcmaVM *vm, uintptr_t nativeObj, uintptr_t key)
5674 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5675 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
5676 EscapeLocalScope scope(vm);
5689 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5696 Local<JSValueRef> JSNApi::NapiHasOwnProperty(const EcmaVM *vm, uintptr_t nativeObj, uintptr_t key)
5698 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5699 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
5700 EscapeLocalScope scope(vm);
5713 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5720 Local<JSValueRef> JSNApi::NapiGetProperty(const EcmaVM *vm, uintptr_t nativeObj, uintptr_t key)
5722 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5723 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
5724 EscapeLocalScope scope(vm);
5736 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5743 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5749 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5753 Local<JSValueRef> JSNApi::NapiDeleteProperty(const EcmaVM *vm, uintptr_t nativeObj, uintptr_t key)
5755 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5756 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
5757 EscapeLocalScope scope(vm);
5777 Local<JSValueRef> JSNApi::NapiGetNamedProperty(const EcmaVM *vm, uintptr_t nativeObj, const char* utf8Key)
5779 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5780 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
5781 EscapeLocalScope scope(vm);
5790 ObjectFactory *factory = vm->GetFactory();
5794 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5802 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5809 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5812 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5816 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5820 Local<JSValueRef> JSNApi::CreateLocal(const EcmaVM *vm, panda::JSValueRef src)
5822 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5823 JSHandle<JSTaggedValue> handle(vm->GetJSThread(), JSNApiHelper::ToJSTaggedValue(&src));
5827 Local<ObjectRef> JSNApi::GetExportObject(EcmaVM *vm, const std::string &file, const std::string &key)
5829 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5830 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5832 ecmascript::CString name = vm->GetAssetPath();
5833 if (!vm->IsBundlePack()) {
5834 ModulePathHelper::ParseAbcPathAndOhmUrl(vm, entry, name, entry);
5848 int index = ecmascript::ModuleManager::GetExportObjectIndex(vm, ecmaModule, key.c_str());
5853 ObjectFactory *factory = vm->GetFactory();
5861 Local<ObjectRef> JSNApi::GetExportObjectFromBuffer(EcmaVM *vm, const std::string &file,
5864 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5865 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5869 int index = ecmascript::ModuleManager::GetExportObjectIndex(vm, ecmaModule, key.c_str());
5875 ObjectFactory *factory = vm->GetFactory();
5882 Local<ObjectRef> JSNApi::GetExportObjectFromOhmUrl(EcmaVM *vm, const std::string &ohmUrl, const std::string &key)
5884 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5885 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5890 return JSValueRef::Undefined(vm);
5894 int index = ecmascript::ModuleManager::GetExportObjectIndex(vm, ecmaModule, key.c_str());
5900 Local<ObjectRef> JSNApi::ExecuteNativeModule(EcmaVM *vm, const std::string &key)
5902 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5903 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5909 Local<ObjectRef> JSNApi::GetModuleNameSpaceFromFile(EcmaVM *vm, const std::string &file, const std::string &module_path)
5911 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5921 std::pair<std::string, std::string> moduleInfo = vm->GetCurrentModuleInfo(false);
5924 return JSValueRef::Undefined(vm);
5926 std::string path = std::string(vm->GetBundleName().c_str()) + PathHelper::SLASH_TAG +
5938 Local<ObjectRef> JSNApi::GetModuleNameSpaceWithModuleInfo(EcmaVM *vm, const std::string &file,
5941 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5948 return GetModuleNameSpaceFromFile(vm, fileName, module_path);
5952 JSHandle<JSTaggedValue> nameSp = ecmascript::NapiModuleLoader::LoadModuleNameSpaceWithModuleInfo(vm,
5958 Local<PromiseRef> PromiseRef::Catch(const EcmaVM *vm, Local<FunctionRef> handler)
5960 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5961 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5971 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5980 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
5984 Local<PromiseRef> PromiseRef::Finally(const EcmaVM *vm, Local<FunctionRef> handler)
5986 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
5987 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
5997 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
6007 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
6011 Local<PromiseRef> PromiseRef::Then(const EcmaVM *vm, Local<FunctionRef> handler)
6013 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6014 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
6024 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
6034 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
6038 Local<PromiseRef> PromiseRef::Then(const EcmaVM *vm, Local<FunctionRef> onFulfilled, Local<FunctionRef> onRejected)
6040 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6041 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
6052 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
6062 RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Undefined(vm));
6066 Local<JSValueRef> PromiseRef::GetPromiseState(const EcmaVM *vm)
6068 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6069 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
6087 ObjectFactory *factory = vm->GetFactory();
6091 Local<JSValueRef> PromiseRef::GetPromiseResult(const EcmaVM *vm)
6093 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6094 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
6098 return JSNApiHelper::ToLocal<JSValueRef>(JSHandle<JSTaggedValue>(vm->GetJSThread(), promise->GetPromiseResult()));
6101 Local<JSValueRef> ProxyRef::GetHandler(const EcmaVM *vm)
6103 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6104 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
6109 Local<JSValueRef> ProxyRef::GetTarget(const EcmaVM *vm)
6111 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6112 ecmascript::ThreadManagedScope scope(vm->GetJSThread());
6125 int32_t SetRef::GetSize(const EcmaVM *vm)
6128 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
6133 int32_t SetRef::GetTotalElements(const EcmaVM *vm)
6136 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
6142 Local<JSValueRef> SetRef::GetValue(const EcmaVM *vm, int entry)
6144 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6151 Local<SetRef> SetRef::New(const EcmaVM *vm)
6153 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6155 ObjectFactory *factory = vm->GetJSThread()->GetEcmaVM()->GetFactory();
6156 JSHandle<GlobalEnv> env = vm->GetJSThread()->GetEcmaVM()->GetGlobalEnv();
6160 JSHandle<LinkedHashSet> hashSet = LinkedHashSet::Create(vm->GetJSThread());
6161 set->SetLinkedSet(vm->GetJSThread(), hashSet);
6166 void SetRef::Add(const EcmaVM *vm, Local<JSValueRef> value)
6168 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
6172 JSSet::Add(vm->GetJSThread(), set, JSNApiHelper::ToJSHandle(value));
6176 int32_t WeakMapRef::GetSize(const EcmaVM *vm)
6179 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
6184 int32_t WeakMapRef::GetTotalElements(const EcmaVM *vm)
6187 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
6193 Local<JSValueRef> WeakMapRef::GetKey(const EcmaVM *vm, int entry)
6195 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6203 Local<JSValueRef> WeakMapRef::GetValue(const EcmaVM *vm, int entry)
6205 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6211 Local<WeakMapRef> WeakMapRef::New(const EcmaVM *vm)
6213 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6215 ObjectFactory *factory = vm->GetJSThread()->GetEcmaVM()->GetFactory();
6216 JSHandle<GlobalEnv> env = vm->GetJSThread()->GetEcmaVM()->GetGlobalEnv();
6220 JSHandle<LinkedHashMap> hashMap = LinkedHashMap::Create(vm->GetJSThread());
6221 weakMap->SetLinkedMap(vm->GetJSThread(), hashMap);
6226 void WeakMapRef::Set(const EcmaVM *vm, const Local<JSValueRef> &key, const Local<JSValueRef> &value)
6228 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
6232 JSWeakMap::Set(vm->GetJSThread(), weakMap, JSNApiHelper::ToJSHandle(key), JSNApiHelper::ToJSHandle(value));
6235 bool WeakMapRef::Has(const EcmaVM *vm, Local<JSValueRef> key)
6237 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
6245 int32_t WeakSetRef::GetSize(const EcmaVM *vm)
6248 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
6253 int32_t WeakSetRef::GetTotalElements(const EcmaVM *vm)
6256 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
6262 Local<JSValueRef> WeakSetRef::GetValue(const EcmaVM *vm, int entry)
6264 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6272 Local<WeakSetRef> WeakSetRef::New(const EcmaVM *vm)
6274 CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
6276 ObjectFactory *factory = vm->GetJSThread()->GetEcmaVM()->GetFactory();
6277 JSHandle<GlobalEnv> env = vm->GetJSThread()->GetEcmaVM()->GetGlobalEnv();
6281 JSHandle<LinkedHashSet> hashWeakSet = LinkedHashSet::Create(vm->GetJSThread());
6282 weakSet->SetLinkedSet(vm->GetJSThread(), hashWeakSet);
6287 void WeakSetRef::Add(const EcmaVM *vm, Local<JSValueRef> value)
6289 CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
6293 JSWeakSet::Add(vm->GetJSThread(), weakSet, JSNApiHelper::ToJSHandle(value));
6325 bool ExternalStringCache::RegisterStringCacheTable(const EcmaVM *vm, uint32_t size)
6330 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
6334 bool ExternalStringCache::SetCachedString(const EcmaVM *vm, const char *name, uint32_t propertyIndex)
6339 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
6340 [[maybe_unused]] LocalScope scope(vm);
6341 ObjectFactory *factory = vm->GetFactory();
6346 Local<StringRef> ExternalStringCache::GetCachedString(const EcmaVM *vm, uint32_t propertyIndex)
6351 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
6352 JSHandle<EcmaString> str = instance->GetCachedString(vm->GetJSThread(), propertyIndex);
6356 bool ExternalStringCache::HasCachedString([[maybe_unused]] const EcmaVM *vm, uint32_t propertyIndex)
6360 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());