Lines Matching refs:env

187 void Builtins::Initialize(const JSHandle<GlobalEnv> &env, JSThread *thread, bool lazyInit, bool isRealm)
207 env->SetObjectFunctionClass(thread_, objFuncClass);
221 env->SetJSGlobalObject(thread_, globalObject);
225 env->SetGlobalPatch(thread, globalPatch);
229 InitializeSSymbolAttributes(env);
230 InitializeSObjectAndSFunction(env);
232 CopySObjectAndSFunction(env, runtimeGlobalEnv);
233 RegisterSendableContainers(env);
235 InitializeFunction(env, objFuncPrototypeVal);
240 JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION, env->GetFunctionPrototype());
241 env->SetAsyncAwaitStatusFunctionClass(thread_, asyncAwaitStatusFuncClass);
246 env->GetFunctionPrototype());
249 env->SetAsyncGeneratorResNextRetProRstFtnClass(thread_, asyncGeneratorResNextRetProRstFtnClass);
252 JSProxyRevocFunction::SIZE, JSType::JS_PROXY_REVOC_FUNCTION, env->GetFunctionPrototype());
255 env->SetProxyRevocFunctionClass(thread_, proxyRevocFuncClass);
259 NewBuiltinConstructor(env, objFuncPrototype, Object::ObjectConstructor, "Object",
264 env->SetObjectFunction(thread_, objectFunction);
265 env->SetObjectFunctionPrototype(thread_, objFuncPrototype);
270 JSType::JS_FUNCTION, env->GetFunctionPrototype());
271 env->SetFunctionClassWithProto(thread_, functionClass);
273 env->GetFunctionPrototype());
274 env->SetFunctionClassWithoutProto(thread_, functionClass);
276 JSType::JS_FUNCTION, env->GetFunctionPrototype());
277 env->SetFunctionClassWithoutName(thread_, functionClass);
281 env->SetBoundFunctionClass(thread_, functionClass);
283 InitializeAllTypeError(env, objFuncClass);
284 InitializeSymbol(env, primRefObjHClass);
285 InitializeBigInt(env, primRefObjHClass);
288 InitializeAllTypeErrorWithRealm(env);
289 InitializeSymbolWithRealm(env, primRefObjHClass);
290 InitializeBigIntWithRealm(env);
294 InitializeArray(env, objFuncPrototypeVal);
296 LazyInitializeDate(env);
297 LazyInitializeSet(env);
298 LazyInitializeMap(env);
299 LazyInitializeWeakMap(env);
300 LazyInitializeWeakSet(env);
301 LazyInitializeWeakRef(env);
302 LazyInitializeFinalizationRegistry(env);
303 LazyInitializeTypedArray(env);
304 LazyInitializeArrayBuffer(env);
305 LazyInitializeDataView(env);
306 LazyInitializeSharedArrayBuffer(env);
308 InitializeDate(env, objFuncPrototypeVal);
309 InitializeSet(env, objFuncPrototypeVal);
310 InitializeMap(env, objFuncPrototypeVal);
311 InitializeWeakMap(env, objFuncClass);
312 InitializeWeakSet(env, objFuncClass);
313 InitializeWeakRef(env, objFuncClass);
314 InitializeFinalizationRegistry(env, objFuncClass);
315 InitializeTypedArray(env, objFuncPrototypeVal);
316 InitializeArrayBuffer(env, objFuncClass);
317 InitializeDataView(env, objFuncPrototypeVal);
318 InitializeSharedArrayBuffer(env, objFuncClass);
321 InitializeNumber(env, globalObject, primRefObjHClass);
322 InitializeObject(env, objFuncPrototype, objectFunction);
323 InitializeBoolean(env, primRefObjHClass);
324 InitializeRegExp(env);
325 InitializeString(env, objFuncPrototypeVal);
326 JSHandle<JSHClass> argumentsClass = factory_->CreateJSArguments(env);
327 env->SetArgumentsClass(thread_, argumentsClass);
328 SetArgumentsSharedAccessor(env);
330 InitializeMath(env, objFuncPrototypeVal);
331 InitializeGlobalObject(env, globalObject);
332 InitializeAtomics(env, objFuncPrototypeVal);
333 InitializeJson(env, objFuncPrototypeVal);
334 InitializeIterator(env, objFuncClass);
335 InitializeAsyncIterator(env, objFuncClass);
336 InitializeAsyncFromSyncIterator(env, objFuncClass);
337 InitializeProxy(env);
338 InitializeReflect(env, objFuncPrototypeVal);
339 InitializeAsyncFunction(env, objFuncClass);
340 InitializeGenerator(env, objFuncClass);
341 InitializeAsyncGenerator(env, objFuncClass);
342 InitializeGeneratorFunction(env, objFuncClass);
343 InitializeAsyncGeneratorFunction(env, objFuncClass);
344 InitializePromise(env, objFuncClass);
345 InitializePromiseJob(env);
348 InitializeIntl(env, objFuncPrototypeVal);
350 LazyInitializeLocale(env);
351 LazyInitializeDateTimeFormat(env);
352 LazyInitializeNumberFormat(env);
353 LazyInitializeRelativeTimeFormat(env);
354 LazyInitializeCollator(env);
355 LazyInitializePluralRules(env);
356 LazyInitializeDisplayNames(env);
357 LazyInitializeListFormat(env);
358 LazyInitializeSegments(env);
359 LazyInitializeSegmenter(env);
361 InitializeLocale(env);
362 InitializeDateTimeFormat(env);
363 InitializeNumberFormat(env);
364 InitializeRelativeTimeFormat(env);
365 InitializeCollator(env);
366 InitializePluralRules(env);
367 InitializeDisplayNames(env);
368 InitializeListFormat(env);
369 InitializeSegments(env);
370 InitializeSegmenter(env);
374 InitializeModuleNamespace(env, objFuncClass);
375 InitializeNativeModuleFailureInfo(env, objFuncClass);
376 InitializeCjsModule(env);
377 InitializeCjsExports(env);
378 InitializeCjsRequire(env);
379 InitializeDefaultExportOfScript(env);
380 InitializePropertyDetector(env, lazyInit);
383 env->GetGeneratorFunctionPrototype());
384 env->SetGeneratorFunctionClass(thread_, generatorFuncClass);
388 JSType::JS_ASYNC_GENERATOR_FUNCTION, env->GetAsyncGeneratorFunctionPrototype());
389 env->SetAsyncGeneratorFunctionClass(thread_, asyncGenetatorFuncClass);
390 env->SetObjectFunctionPrototypeClass(thread_, JSTaggedValue(objFuncPrototype->GetClass()));
393 env->GetAsyncFunctionPrototype());
394 env->SetAsyncFunctionClass(thread_, asyncFuncClass);
405 void Builtins::InitializePropertyDetector(const JSHandle<GlobalEnv> &env, bool lazyInit) const
412 env->Set##name(thread_, name##detector);
432 auto env = vm_->GetGlobalEnv();
433 auto globalObject = JSHandle<JSObject>::Cast(env->GetJSGlobalObject());
434 JSHandle<JSTaggedValue> arkTools(InitializeArkTools(env));
439 void Builtins::InitializeGlobalObject(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &globalObject)
444 SetFunction(env, globalObject, "print", Global::PrintEntrypoint, 0);
445 SetFunction(env, globalObject, "markModuleCollectable", Global::MarkModuleCollectable, 0);
446 SetFunction(env, globalObject, "isSendable", Global::IsSendable, 0);
447 SetFunction(env, globalObject, "loadNativeModule", Global::LoadNativeModule, 0);
449 SetFunction(env, globalObject, "startRuntimeStat", Global::StartRuntimeStat, 0);
450 SetFunction(env, globalObject, "stopRuntimeStat", Global::StopRuntimeStat, 0);
454 SetFunction(env, globalObject, "printOptStat", Global::PrintOptStat, 0);
458 SetFunction(env, globalObject, "printFunctionCallStat", Global::PrintFunctionCallStat, 0);
462 JSHandle<JSTaggedValue> arkTools(InitializeArkTools(env));
468 JSHandle<JSTaggedValue> arkPrivate(InitializeArkPrivate(env));
473 SetFunction(env, globalObject, "eval", Global::NotSupportEval, FunctionLength::ONE);
474 SetFunction(env, globalObject, "isFinite", Global::IsFinite, FunctionLength::ONE,
476 SetFunction(env, globalObject, "isNaN", Global::IsNaN, FunctionLength::ONE,
478 SetFunction(env, globalObject, "decodeURI", Global::DecodeURI, FunctionLength::ONE);
479 SetFunction(env, globalObject, "encodeURI", Global::EncodeURI, FunctionLength::ONE);
480 SetFunction(env, globalObject, "escape", Global::Escape, FunctionLength::ONE);
481 SetFunction(env, globalObject, "unescape", Global::Unescape, FunctionLength::ONE);
482 SetFunction(env, globalObject, "decodeURIComponent", Global::DecodeURIComponent, FunctionLength::ONE,
484 SetFunction(env, globalObject, "encodeURIComponent", Global::EncodeURIComponent, FunctionLength::ONE);
485 SetFunction(env, globalObject, "__getCurrentModuleName__", Global::GetCurrentModuleName, FunctionLength::ZERO);
486 SetFunction(env, globalObject, "__getCurrentBundleName__", Global::GetCurrentBundleName, FunctionLength::ZERO);
495 JSHandle<JSHClass> Builtins::CreateFunctionPrototypeHClass(const JSHandle<GlobalEnv> &env,
513 keyString = env->GetHasInstanceSymbol();
577 void Builtins::SetInlineFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj, std::string_view key,
582 SetInlineFunction(env, obj, keyString, func, index, length, builtinId);
585 void Builtins::SetInlineFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj,
589 JSHandle<JSFunction> function(NewFunction(env, key, func, length, builtinId));
593 JSHandle<JSFunction> Builtins::SetInlineFunctionAndRetJSFunction(const JSHandle<GlobalEnv> &env,
599 JSHandle<JSFunction> function(NewFunction(env, keyString, func, length, builtinId));
613 void Builtins::StrictModeForbiddenAccessCallerArguments(const JSHandle<GlobalEnv> &env, uint32_t &index,
617 factory_->NewJSFunction(env, reinterpret_cast<void *>(JSFunction::AccessCallerArgumentsThrowTypeError)));
624 void Builtins::InitializeFunctionPrototype(const JSHandle<GlobalEnv> &env, JSHandle<JSFunction> &funcFuncPrototype,
632 StrictModeForbiddenAccessCallerArguments(env, fieldIndex, funcFuncPrototypeObj);
635 SetInlineFunction(env, funcFuncPrototypeObj, entry.GetName(), entry.GetEntrypoint(), fieldIndex++,
639 SetInlineFunction(env, funcFuncPrototypeObj, thread_->GlobalConstants()->GetHandledToStringString(),
642 env, funcFuncPrototypeObj, "[Symbol.hasInstance]",
645 env->SetHasInstanceFunction(thread_, function);
648 void Builtins::InitializeFunction(const JSHandle<GlobalEnv> &env, JSHandle<JSTaggedValue> &objFuncPrototypeVal) const
652 JSHandle<JSHClass> funcPrototypeHClass = CreateFunctionPrototypeHClass(env, objFuncPrototypeVal);
675 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
680 env->SetFunctionFunction(thread_, funcFunc);
681 env->SetFunctionPrototype(thread_, funcFuncPrototype);
684 factory_->NewEcmaHClass(JSFunction::SIZE, JSType::JS_FUNCTION, env->GetFunctionPrototype());
685 env->SetNormalFunctionClass(thread_, normalFuncClass);
689 JSType::JS_INTL_BOUND_FUNCTION, env->GetFunctionPrototype());
690 env->SetJSIntlBoundFunctionClass(thread_, jSIntlBoundFunctionClass);
693 factory_->NewEcmaHClass(JSFunction::SIZE, JSType::JS_FUNCTION, env->GetFunctionPrototype());
695 env->SetConstructorFunctionClass(thread_, constructorFunctionClass);
696 InitializeFunctionPrototype(env, funcFuncPrototype, funcFunc);
699 void Builtins::InitializeObject(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &objFuncPrototype,
705 SetFunction(env, objFunc, entry.GetName(), entry.GetEntrypoint(),
710 SetFunction(env, objFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
716 JSHandle<JSTaggedValue> protoGetter = CreateGetter(env, Object::ProtoGetter, "__proto__", FunctionLength::ZERO);
717 JSHandle<JSTaggedValue> protoSetter = CreateSetter(env, Object::ProtoSetter, "__proto__", FunctionLength::ONE);
728 void Builtins::InitializeSymbol(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
742 NewBuiltinConstructor(env, symbolFuncPrototype, Symbol::SymbolConstructor, "Symbol", FunctionLength::ZERO));
752 SetFunction(env, symbolFunction, entry.GetName(), entry.GetEntrypoint(),
758 SetNoneAttributeProperty(symbolFunction, #name, env->Get##Name##Symbol());
761 env->SetSymbolFunction(thread_, symbolFunction);
766 JSHandle<JSTaggedValue> getter(factory_->NewJSFunction(env, reinterpret_cast<void *>(Symbol::DescriptionGetter)));
771 env, symbolFuncPrototype, env->GetToPrimitiveSymbol(), "[Symbol.toPrimitive]",
774 SetFunction(env, symbolFuncPrototype, thread_->GlobalConstants()->GetHandledToStringString(), Symbol::ToString,
776 SetFunction(env, symbolFuncPrototype, thread_->GlobalConstants()->GetHandledValueOfString(), Symbol::ValueOf,
780 SetStringTagSymbol(env, symbolFuncPrototype, "Symbol");
783 env->SetHoleySymbol(thread_, holeySymbol.GetTaggedValue());
785 env->SetElementICSymbol(thread_, elementIcSymbol.GetTaggedValue());
792 JSHandle<GlobalEnv> env = vm_->GetGlobalEnv();
819 SetNoneAttributeProperty(symbolFunction, #name, env->Get##Name##Symbol()); \
820 realm->Set##Name##Symbol(thread_, env->Get##Name##Symbol());
833 SetFunctionAtSymbol<JSSymbol::SYMBOL_TO_PRIMITIVE_TYPE>(realm, symbolFuncPrototype, env->GetToPrimitiveSymbol(),
851 void Builtins::InitializeNumber(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &globalObject,
867 NewBuiltinConstructor(env, numFuncPrototype, Number::NumberConstructor, "Number", FunctionLength::ONE,
875 SetFunction(env, numFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
880 SetFunction(env, numFunction, entry.GetName(), entry.GetEntrypoint(),
884 SetFuncToObjAndGlobal(env, globalObject, numFunction,
892 env->SetNumberFunction(thread_, numFunction);
893 env->SetNumberPrototype(thread_, numFuncPrototype);
898 JSHandle<GlobalEnv> env = vm_->GetGlobalEnv();
899 realm->SetBigIntFunction(thread_, env->GetBigIntFunction());
903 PropertyDescriptor descriptor(thread_, env->GetBigIntFunction(), true, false, true);
907 void Builtins::InitializeBigInt(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &primRefObjHClass) const
919 NewBuiltinConstructor(env, bigIntFuncPrototype, BuiltinsBigInt::BigIntConstructor, "BigInt",
927 SetFunction(env, bigIntFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
933 SetFunction(env, bigIntFunction, entry.GetName(), entry.GetEntrypoint(),
938 SetStringTagSymbol(env, bigIntFuncPrototype, "BigInt");
939 env->SetBigIntFunction(thread_, bigIntFunction);
942 void Builtins::InitializeDate(const JSHandle<GlobalEnv> &env, JSHandle<JSTaggedValue> objFuncPrototypeVal) const
957 NewBuiltinConstructor(env, dateFuncPrototype, Date::DateConstructor, "Date", FunctionLength::ONE,
965 SetFunction(env, dateFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
968 SetFunctionAtSymbol(env, dateFuncPrototype, env->GetToPrimitiveSymbol(), "[Symbol.toPrimitive]", Date::ToPrimitive,
973 SetFunction(env, dateFunction, entry.GetName(), entry.GetEntrypoint(),
979 env->SetDateFunction(thread_, dateFunction);
980 env->SetDatePrototype(thread_, dateFuncPrototype);
987 void Builtins::LazyInitializeDate(const JSHandle<GlobalEnv> &env) const
990 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
994 env->SetDateFunction(thread_, accessor);
995 env->SetDatePrototype(thread_, accessor);
998 void Builtins::InitializeBoolean(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &primRefObjHClass) const
1012 JSHandle<JSFunction> booleanFunction = NewBuiltinConstructor(env, booleanFuncPrototype, Boolean::BooleanConstructor,
1018 SetFunction(env, booleanFuncPrototype, thread_->GlobalConstants()->GetHandledToStringString(),
1020 SetFunction(env, booleanFuncPrototype, thread_->GlobalConstants()->GetHandledValueOfString(),
1023 env->SetBooleanFunction(thread_, booleanFunction);
1024 env->SetBooleanPrototype(thread_, booleanFuncPrototype);
1027 void Builtins::InitializeProxy(const JSHandle<GlobalEnv> &env)
1030 JSHandle<JSObject> proxyFunction(InitializeExoticConstructor(env, Proxy::ProxyConstructor, "Proxy", 2));
1033 SetFunction(env, proxyFunction, "revocable", Proxy::Revocable, FunctionLength::TWO);
1034 env->SetProxyFunction(thread_, proxyFunction);
1037 JSHandle<JSFunction> Builtins::InitializeExoticConstructor(const JSHandle<GlobalEnv> &env, EcmaEntrypoint ctorFunc,
1041 factory_->NewJSFunction(env, reinterpret_cast<void *>(ctorFunc), FunctionKind::BUILTIN_PROXY_CONSTRUCTOR,
1049 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1055 void Builtins::InitializeAsyncFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
1061 JSObject::SetPrototype(thread_, asyncFuncPrototype, env->GetFunctionPrototype());
1070 env, asyncFuncPrototype, AsyncFunction::AsyncFunctionConstructor, "AsyncFunction", FunctionLength::ONE);
1071 JSObject::SetPrototype(thread_, JSHandle<JSObject>::Cast(asyncFunction), env->GetFunctionFunction());
1078 SetStringTagSymbol(env, asyncFuncPrototype, "AsyncFunction");
1079 env->SetAsyncFunction(thread_, asyncFunction);
1080 env->SetAsyncFunctionPrototype(thread_, asyncFuncPrototype);
1083 void Builtins::InitializeAllTypeError(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
1093 NewBuiltinConstructor(env, errorFuncPrototype, Error::ErrorConstructor, "Error", FunctionLength::ONE));
1097 SetFunction(env, errorFuncPrototype, thread_->GlobalConstants()->GetHandledToStringString(), Error::ToString,
1103 env->SetErrorFunction(thread_, errorFunction);
1106 factory_->NewEcmaHClass(JSFunction::SIZE, JSType::JS_FUNCTION, env->GetErrorFunction());
1108 env->SetNativeErrorFunctionClass(thread_, nativeErrorFuncClass);
1112 InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_RANGE_ERROR);
1113 InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_REFERENCE_ERROR);
1114 InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_TYPE_ERROR);
1115 InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_AGGREGATE_ERROR);
1116 InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_URI_ERROR);
1117 InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_SYNTAX_ERROR);
1118 InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_EVAL_ERROR);
1119 InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_OOM_ERROR);
1120 InitializeError(env, errorNativeFuncInstanceHClass, JSType::JS_TERMINATION_ERROR);
1124 env->SetOOMErrorObject(thread_, oomError);
1129 JSHandle<GlobalEnv> env = vm_->GetGlobalEnv();
1131 realm->SetErrorFunction(thread_, env->GetErrorFunction());
1132 realm->SetNativeErrorFunctionClass(thread_, env->GetNativeErrorFunctionClass());
1147 JSHandle<GlobalEnv> env = vm_->GetGlobalEnv();
1153 nativeErrorFunction = env->GetRangeErrorFunction();
1158 nativeErrorFunction = env->GetEvalErrorFunction();
1163 nativeErrorFunction = env->GetReferenceErrorFunction();
1168 nativeErrorFunction = env->GetTypeErrorFunction();
1171 realm->SetThrowTypeError(thread_, env->GetThrowTypeError());
1174 nativeErrorFunction = env->GetAggregateErrorFunction();
1179 nativeErrorFunction = env->GetURIErrorFunction();
1184 nativeErrorFunction = env->GetSyntaxErrorFunction();
1189 nativeErrorFunction = env->GetOOMErrorFunction();
1194 nativeErrorFunction = env->GetTerminationErrorFunction();
1214 void Builtins::InitializeError(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass,
1274 factory_->NewJSNativeErrorFunction(env, reinterpret_cast<void *>(errorParameter.nativeConstructor));
1275 InitializeCtor(env, nativeErrorFuncPrototype, nativeErrorFunction, errorParameter.nativePropertyName,
1282 SetFunction(env, nativeErrorFuncPrototype, thread_->GlobalConstants()->GetHandledToStringString(),
1290 env->SetRangeErrorFunction(thread_, nativeErrorFunction);
1292 env->SetReferenceErrorFunction(thread_, nativeErrorFunction);
1294 env->SetTypeErrorFunction(thread_, nativeErrorFunction);
1296 factory_->NewJSFunction(env, reinterpret_cast<void *>(TypeError::ThrowTypeError));
1299 env->SetThrowTypeError(thread_, throwTypeErrorFunction);
1301 env->SetAggregateErrorFunction(thread_, nativeErrorFunction);
1303 env->SetURIErrorFunction(thread_, nativeErrorFunction);
1305 env->SetSyntaxErrorFunction(thread_, nativeErrorFunction);
1307 env->SetEvalErrorFunction(thread_, nativeErrorFunction);
1309 env->SetOOMErrorFunction(thread_, nativeErrorFunction);
1311 env->SetTerminationErrorFunction(thread_, nativeErrorFunction);
1315 void Builtins::InitializeCtor(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &prototype,
1331 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1337 void Builtins::InitializeSet(const JSHandle<GlobalEnv> &env, JSHandle<JSTaggedValue> objFuncPrototypeVal) const
1351 NewBuiltinConstructor(env, setFuncPrototype, BuiltinsSet::SetConstructor, "Set", FunctionLength::ZERO,
1363 SetFunction(env, setFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
1376 SetStringTagSymbol(env, setFuncPrototype, "Set");
1379 JSHandle<JSTaggedValue> sizeGetter = CreateGetter(env, BuiltinsSet::GetSize, "size", FunctionLength::ZERO);
1384 JSHandle<JSTaggedValue> speciesSymbol = env->GetSpeciesSymbol();
1386 CreateGetter(env, BuiltinsSet::Species, "[Symbol.species]", FunctionLength::ZERO);
1390 JSHandle<JSTaggedValue> iteratorSymbol = env->GetIteratorSymbol();
1393 env->SetBuiltinsSetFunction(thread_, setFunction);
1394 env->SetSetPrototype(thread_, setFuncPrototype);
1395 env->SetSetProtoValuesFunction(thread_, valuesFunc);
1402 void Builtins::LazyInitializeSet(const JSHandle<GlobalEnv> &env)
1405 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1409 env->SetBuiltinsSetFunction(thread_, accessor);
1410 env->SetSetPrototype(thread_, accessor);
1411 env->SetSetProtoValuesFunction(thread_, accessor);
1414 void Builtins::InitializeMap(const JSHandle<GlobalEnv> &env, JSHandle<JSTaggedValue> objFuncPrototypeVal) const
1426 env->SetMapClass(thread_, mapFuncInstanceHClass);
1430 NewBuiltinConstructor(env, mapFuncPrototype, BuiltinsMap::MapConstructor, "Map", FunctionLength::ZERO,
1443 SetFunction(env, mapFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
1447 SetStringTagSymbol(env, mapFuncPrototype, "Map");
1450 JSHandle<JSTaggedValue> sizeGetter = CreateGetter(env, BuiltinsMap::GetSize, "size", FunctionLength::ZERO);
1455 JSHandle<JSTaggedValue> speciesSymbol = env->GetSpeciesSymbol();
1457 CreateGetter(env, BuiltinsMap::Species, "[Symbol.species]", FunctionLength::ZERO);
1461 JSHandle<JSTaggedValue> iteratorSymbol = env->GetIteratorSymbol();
1469 env->SetBuiltinsMapFunction(thread_, mapFunction);
1470 env->SetMapPrototype(thread_, mapFuncPrototype);
1471 env->SetMapProtoEntriesFunction(thread_, entriesFunc);
1478 void Builtins::LazyInitializeMap(const JSHandle<GlobalEnv> &env) const
1481 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1485 env->SetBuiltinsMapFunction(thread_, accessor);
1486 env->SetMapPrototype(thread_, accessor);
1487 env->SetMapProtoEntriesFunction(thread_, accessor);
1488 env->SetMapClass(thread_, accessor);
1491 void Builtins::InitializeWeakMap(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
1503 env, weakMapFuncPrototype, BuiltinsWeakMap::WeakMapConstructor, "WeakMap", FunctionLength::ZERO));
1513 SetFunction(env, weakMapFuncPrototype, globalConst->GetHandledSetString(), BuiltinsWeakMap::Set,
1516 SetFunction(env, weakMapFuncPrototype, "delete", BuiltinsWeakMap::Delete, FunctionLength::ONE);
1518 SetFunction(env, weakMapFuncPrototype, "has", BuiltinsWeakMap::Has, FunctionLength::ONE);
1520 SetFunction(env, weakMapFuncPrototype, thread_->GlobalConstants()->GetHandledGetString(), BuiltinsWeakMap::Get,
1523 SetStringTagSymbol(env, weakMapFuncPrototype, "WeakMap");
1525 env->SetBuiltinsWeakMapFunction(thread_, weakMapFunction);
1528 void Builtins::LazyInitializeWeakMap(const JSHandle<GlobalEnv> &env) const
1531 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1535 env->SetBuiltinsWeakMapFunction(thread_, accessor);
1538 void Builtins::InitializeWeakSet(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
1550 env, weakSetFuncPrototype, BuiltinsWeakSet::WeakSetConstructor, "WeakSet", FunctionLength::ZERO));
1558 SetFunction(env, weakSetFuncPrototype, "add", BuiltinsWeakSet::Add, FunctionLength::ONE);
1560 SetFunction(env, weakSetFuncPrototype, "delete", BuiltinsWeakSet::Delete, FunctionLength::ONE);
1562 SetFunction(env, weakSetFuncPrototype, "has", BuiltinsWeakSet::Has, FunctionLength::ONE);
1565 SetStringTagSymbol(env, weakSetFuncPrototype, "WeakSet");
1567 env->SetBuiltinsWeakSetFunction(thread_, weakSetFunction);
1570 void Builtins::LazyInitializeWeakSet(const JSHandle<GlobalEnv> &env) const
1573 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1577 env->SetBuiltinsWeakSetFunction(thread_, accessor);
1580 void Builtins::InitializeAtomics(const JSHandle<GlobalEnv> &env,
1589 SetFunction(env, atomicsObject, entry.GetName(), entry.GetEntrypoint(),
1593 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1597 SetStringTagSymbol(env, atomicsObject, "Atomics");
1598 env->SetAtomicsFunction(thread_, atomicsObject);
1601 void Builtins::InitializeWeakRef(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
1613 env, weakRefFuncPrototype, BuiltinsWeakRef::WeakRefConstructor, "WeakRef", FunctionLength::ONE));
1621 SetFunction(env, weakRefFuncPrototype, "deref", BuiltinsWeakRef::Deref, FunctionLength::ZERO);
1624 SetStringTagSymbol(env, weakRefFuncPrototype, "WeakRef");
1626 env->SetBuiltinsWeakRefFunction(thread_, weakRefFunction);
1629 void Builtins::LazyInitializeWeakRef(const JSHandle<GlobalEnv> &env) const
1632 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1636 env->SetBuiltinsWeakRefFunction(thread_, accessor);
1639 void Builtins::InitializeFinalizationRegistry(const JSHandle<GlobalEnv> &env,
1653 env, finalizationRegistryFuncPrototype, BuiltinsFinalizationRegistry::FinalizationRegistryConstructor,
1664 SetFunction(env, finalizationRegistryFuncPrototype, "register",
1666 SetFunction(env, finalizationRegistryFuncPrototype, "unregister",
1669 SetStringTagSymbol(env, finalizationRegistryFuncPrototype, "FinalizationRegistry");
1671 env->SetBuiltinsFinalizationRegistryFunction(thread_, finalizationRegistryFunction);
1674 void Builtins::LazyInitializeFinalizationRegistry(const JSHandle<GlobalEnv> &env) const
1677 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1682 env->SetBuiltinsFinalizationRegistryFunction(thread_, accessor);
1685 void Builtins::InitializeMath(const JSHandle<GlobalEnv> &env, const JSHandle<JSTaggedValue> &objFuncPrototypeVal) const
1693 SetFunction(env, mathObject, entry.GetName(), entry.GetEntrypoint(),
1700 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1704 SetStringTagSymbol(env, mathObject, "Math");
1705 env->SetMathFunction(thread_, mathObject);
1706 env->SetMathFunctionClass(thread_, JSHandle<JSHClass>(thread_, mathObject->GetJSHClass()));
1709 void Builtins::InitializeJson(const JSHandle<GlobalEnv> &env, const JSHandle<JSTaggedValue> &objFuncPrototypeVal) const
1715 SetFunction(env, jsonObject, "parse", Json::Parse, FunctionLength::TWO);
1716 SetFunction(env, jsonObject, "parseSendable", SendableJson::Parse, FunctionLength::THREE);
1717 SetFunction(env, jsonObject, "parseBigInt", BigIntJson::Parse, FunctionLength::THREE);
1718 SetFunction(env, jsonObject, "stringify", Json::Stringify, FunctionLength::THREE, BUILTINS_STUB_ID(JsonStringify));
1719 SetFunction(env, jsonObject, "stringifySendable", SendableJson::Stringify, FunctionLength::THREE);
1720 SetFunction(env, jsonObject, "stringifyBigInt", BigIntJson::Stringify, FunctionLength::THREE);
1724 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
1727 SetStringTagSymbol(env, jsonObject, "JSON");
1728 env->SetJsonFunction(thread_, jsonObject);
1731 void Builtins::InitializeString(const JSHandle<GlobalEnv> &env, JSHandle<JSTaggedValue> objFuncPrototypeVal) const
1748 JSHandle<JSObject> stringFunction(NewBuiltinConstructor(env, stringFuncPrototype, BuiltinsString::StringConstructor,
1756 SetFunction(env, stringFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
1759 JSHandle<JSTaggedValue> stringIter = SetAndReturnFunctionAtSymbol(env, stringFuncPrototype,
1760 env->GetIteratorSymbol(), "[Symbol.iterator]", BuiltinsString::GetStringIterator, FunctionLength::ZERO,
1765 SetFunction(env, stringFunction, entry.GetName(), entry.GetEntrypoint(),
1770 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(env, BuiltinsString::GetLength, "length", FunctionLength::ZERO);
1774 env->SetStringFunction(thread_, stringFunction);
1775 env->SetStringPrototype(thread_, stringFuncPrototype);
1776 env->SetStringProtoIterFunction(thread_, stringIter);
1780 void Builtins::InitializeStringIterator(const JSHandle<GlobalEnv> &env,
1791 factory_->NewJSFunction(env, static_cast<void *>(nullptr), FunctionKind::BASE_CONSTRUCTOR));
1795 SetFunction(env, strIterPrototype, "next", StringIterator::Next, FunctionLength::ZERO,
1797 SetStringTagSymbol(env, strIterPrototype, "String Iterator");
1799 env->SetStringIterator(thread_, strIterFunction);
1800 env->SetStringIteratorClass(thread_, strIterFuncInstanceHClass);
1801 env->SetStringIteratorPrototype(thread_, strIterPrototype);
1804 void Builtins::InitializeAsyncFromSyncIterator(const JSHandle<GlobalEnv> &env,
1810 SetFunction(env, asyncItPrototype, "next", BuiltinsAsyncFromSyncIterator::Next, FunctionLength::ONE);
1811 SetFunction(env, asyncItPrototype, "return", BuiltinsAsyncFromSyncIterator::Return, FunctionLength::ONE);
1812 SetFunction(env, asyncItPrototype, "throw", BuiltinsAsyncFromSyncIterator::Throw, FunctionLength::ONE);
1817 factory_->NewJSFunction(env, static_cast<void *>(nullptr), FunctionKind::BASE_CONSTRUCTOR));
1819 env->SetAsyncFromSyncIterator(thread_, iterFunction);
1820 env->SetAsyncFromSyncIteratorPrototype(thread_, asyncItPrototype);
1825 env->GetFunctionPrototype());
1828 env->SetAsyncFromSyncIterUnwarpClass(thread_, asyncFromSyncIterUnwarpClass);
1831 void Builtins::InitializeIterator(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
1837 SetFunction(env, iteratorPrototype, "next", BuiltinsIterator::Next, FunctionLength::ONE);
1839 SetFunction(env, iteratorPrototype, "return", BuiltinsIterator::Return, FunctionLength::ONE,
1842 SetFunction(env, iteratorPrototype, "throw", BuiltinsIterator::Throw, FunctionLength::ONE);
1844 SetFunctionAtSymbol(env, iteratorPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
1846 env->SetIteratorPrototype(thread_, iteratorPrototype);
1856 JSHandle<JSHClass> iterResultHClass = factory_->CreateIteratorResultInstanceClass(env);
1870 InitializeForinIterator(env, iteratorFuncClass);
1871 InitializeSetIterator(env, iteratorFuncClass);
1872 InitializeSSetIterator(env, iteratorFuncClass);
1873 InitializeMapIterator(env, iteratorFuncClass);
1874 InitializeSMapIterator(env, iteratorFuncClass);
1875 InitializeArrayIterator(env, iteratorFuncClass, iteratorPrototypeHClass);
1876 InitializeSArrayIterator(env, iteratorFuncClass);
1877 InitializeStringIterator(env, iteratorFuncClass);
1878 InitializeRegexpIterator(env, iteratorFuncClass);
1880 InitializeSegmentIterator(env, iteratorFuncClass);
1884 void Builtins::InitializeAsyncIterator(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncDynclass) const
1890 SetFunction(env, asyncIteratorPrototype, "next", BuiltinsAsyncIterator::Next, FunctionLength::ONE);
1892 SetFunction(env, asyncIteratorPrototype, "return", BuiltinsAsyncIterator::Return, FunctionLength::ONE);
1894 SetFunction(env, asyncIteratorPrototype, "throw", BuiltinsAsyncIterator::Throw, FunctionLength::ONE);
1896 SetFunctionAtSymbol(env, asyncIteratorPrototype, env->GetAsyncIteratorSymbol(), "[Symbol.asyncIterator]",
1898 env->SetAsyncIteratorPrototype(thread_, asyncIteratorPrototype);
1909 void Builtins::InitializeForinIterator(const JSHandle<GlobalEnv> &env,
1919 SetFunction(env, forinIteratorPrototype, "next", JSForInIterator::Next, FunctionLength::ONE);
1920 env->SetForinIteratorPrototype(thread_, forinIteratorPrototype);
1921 env->SetForinIteratorClass(thread_, hclass);
1924 void Builtins::InitializeSetIterator(const JSHandle<GlobalEnv> &env,
1930 SetFunction(env, setIteratorPrototype, "next", JSSetIterator::Next, FunctionLength::ZERO,
1932 SetStringTagSymbol(env, setIteratorPrototype, "Set Iterator");
1933 env->SetSetIteratorPrototype(thread_, setIteratorPrototype);
1934 JSHandle<JSTaggedValue> protoValue = env->GetSetIteratorPrototype();
1941 void Builtins::InitializeSSetIterator(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &iteratorFuncClass) const
1946 SetFunction(env, setIteratorPrototype, "next", JSSharedSetIterator::Next, FunctionLength::ZERO);
1947 SetStringTagSymbol(env, setIteratorPrototype, "SharedSet Iterator");
1948 env->SetSharedSetIteratorPrototype(thread_, setIteratorPrototype);
1949 JSHandle<JSTaggedValue> protoValue = env->GetSharedSetIteratorPrototype();
1956 void Builtins::InitializeMapIterator(const JSHandle<GlobalEnv> &env,
1962 SetFunction(env, mapIteratorPrototype, "next", JSMapIterator::Next, FunctionLength::ZERO,
1964 SetStringTagSymbol(env, mapIteratorPrototype, "Map Iterator");
1965 env->SetMapIteratorPrototype(thread_, mapIteratorPrototype);
1966 JSHandle<JSTaggedValue> protoValue = env->GetMapIteratorPrototype();
1973 void Builtins::InitializeSMapIterator(const JSHandle<GlobalEnv> &env,
1979 SetFunction(env, mapIteratorPrototype, "next", JSSharedMapIterator::Next, FunctionLength::ZERO);
1980 SetStringTagSymbol(env, mapIteratorPrototype, "SharedMap Iterator");
1981 env->SetSharedMapIteratorPrototype(thread_, mapIteratorPrototype);
1982 JSHandle<JSTaggedValue> protoValue = env->GetSharedMapIteratorPrototype();
1989 void Builtins::InitializeArrayIterator(const JSHandle<GlobalEnv> &env,
1999 SetFunction(env, arrayIteratorPrototype, "next", JSArrayIterator::Next, FunctionLength::ZERO,
2002 SetStringTagSymbol(env, arrayIteratorPrototype, "Array Iterator");
2005 env->SetArrayIteratorPrototype(thread_, arrayIteratorPrototype);
2008 void Builtins::InitializeSArrayIterator(const JSHandle<GlobalEnv> &env,
2014 SetFunction(env, arrayIteratorPrototype, "next", JSSharedArrayIterator::Next, FunctionLength::ZERO);
2015 SetStringTagSymbol(env, arrayIteratorPrototype, "SharedArray Iterator");
2016 env->SetSharedArrayIteratorPrototype(thread_, arrayIteratorPrototype);
2019 void Builtins::InitializeRegexpIterator(const JSHandle<GlobalEnv> &env,
2025 SetFunction(env, regExpIteratorPrototype, "next", JSRegExpIterator::Next, FunctionLength::ZERO);
2026 SetStringTagSymbol(env, regExpIteratorPrototype, "RegExp String Iterator");
2027 env->SetRegExpIteratorPrototype(thread_, regExpIteratorPrototype);
2030 void Builtins::InitializeRegExp(const JSHandle<GlobalEnv> &env)
2034 JSHandle<JSFunction> objFun(env->GetObjectFunction());
2035 JSHandle<JSObject> regPrototype = factory_->NewJSObjectByConstructor(env, objFun, REGEXP_INLINE_PROPS);
2043 NewBuiltinConstructor(env, regPrototype, RegExp::RegExpConstructor, "RegExp", FunctionLength::TWO));
2054 JSHandle<JSFunction> execFunc = SetAndReturnFunction(env, regPrototype, "exec", RegExp::Exec, FunctionLength::ONE);
2055 SetFunction(env, regPrototype, "test", RegExp::Test, FunctionLength::ONE);
2056 SetFunction(env, regPrototype, globalConstants->GetHandledToStringString(), RegExp::ToString,
2058 JSHandle<JSFunction>(execFunc)->SetLexicalEnv(thread_, env);
2060 JSHandle<JSTaggedValue> flagsGetter = CreateGetter(env, RegExp::GetFlags, "flags", FunctionLength::ZERO,
2064 JSHandle<JSFunction>(flagsGetter)->SetLexicalEnv(thread_, env);
2066 JSHandle<JSTaggedValue> sourceGetter = CreateGetter(env, RegExp::GetSource, "source", FunctionLength::ZERO);
2069 JSHandle<JSFunction>(sourceGetter)->SetLexicalEnv(thread_, env);
2071 JSHandle<JSTaggedValue> globalGetter = CreateGetter(env, RegExp::GetGlobal, "global", FunctionLength::ZERO);
2074 JSHandle<JSFunction>(globalGetter)->SetLexicalEnv(thread_, env);
2077 CreateGetter(env, RegExp::GetHasIndices, "hasIndices", FunctionLength::ZERO);
2080 JSHandle<JSFunction>(hasIndicesGetter)->SetLexicalEnv(thread_, env);
2083 CreateGetter(env, RegExp::GetIgnoreCase, "ignoreCase", FunctionLength::ZERO);
2086 JSHandle<JSFunction>(ignoreCaseGetter)->SetLexicalEnv(thread_, env);
2089 CreateGetter(env, RegExp::GetMultiline, "multiline", FunctionLength::ZERO);
2092 JSHandle<JSFunction>(multilineGetter)->SetLexicalEnv(thread_, env);
2094 JSHandle<JSTaggedValue> dotAllGetter = CreateGetter(env, RegExp::GetDotAll, "dotAll", FunctionLength::ZERO);
2097 JSHandle<JSFunction>(dotAllGetter)->SetLexicalEnv(thread_, env);
2099 JSHandle<JSTaggedValue> stickyGetter = CreateGetter(env, RegExp::GetSticky, "sticky", FunctionLength::ZERO);
2102 JSHandle<JSFunction>(stickyGetter)->SetLexicalEnv(thread_, env);
2104 JSHandle<JSTaggedValue> unicodeGetter = CreateGetter(env, RegExp::GetUnicode, "unicode", FunctionLength::ZERO);
2107 JSHandle<JSFunction>(unicodeGetter)->SetLexicalEnv(thread_, env);
2110 JSHandle<JSTaggedValue> speciesSymbol = env->GetSpeciesSymbol();
2112 CreateGetter(env, BuiltinsMap::Species, "[Symbol.species]", FunctionLength::ZERO);
2114 JSHandle<JSFunction>(speciesGetter)->SetLexicalEnv(thread_, env);
2118 env, regPrototype, env->GetSplitSymbol(), "[Symbol.split]", RegExp::Split, FunctionLength::TWO);
2121 env, regPrototype, env->GetSearchSymbol(), "[Symbol.search]", RegExp::Search, FunctionLength::ONE);
2124 env, regPrototype, env->GetMatchSymbol(), "[Symbol.match]", RegExp::Match, FunctionLength::ONE);
2127 env, regPrototype, env->GetMatchAllSymbol(), "[Symbol.matchAll]", RegExp::MatchAll, FunctionLength::ONE);
2130 env, regPrototype, env->GetReplaceSymbol(), "[Symbol.replace]", RegExp::Replace, FunctionLength::TWO);
2132 env->SetRegExpFunction(thread_, regexpFunction);
2133 env->SetRegExpPrototype(thread_, regPrototype);
2134 env->SetRegExpExecFunction(thread_, execFunc);
2135 env->SetRegExpSplitFunction(thread_, splitFunc);
2136 env->SetRegExpSearchFunction(thread_, searchFunc);
2137 env->SetRegExpMatchFunction(thread_, matchFunc);
2138 env->SetRegExpMatchAllFunction(thread_, matchAllFunc);
2139 env->SetRegExpReplaceFunction(thread_, replaceFunc);
2142 env->SetRegExpPrototypeClass(thread_, regPrototypeClass.GetTaggedValue());
2148 void Builtins::InitializeArray(const JSHandle<GlobalEnv> &env, const JSHandle<JSTaggedValue> &objFuncPrototypeVal) const
2181 NewBuiltinConstructor(env, arrFuncPrototype, BuiltinsArray::ArrayConstructor, "Array", FunctionLength::ONE,
2187 lexicalEnv->SetParentEnv(thread_, env.GetTaggedValue());
2195 SetFunction(env, arrFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
2201 JSHandle<JSTaggedValue> iteratorSymbol = env->GetIteratorSymbol();
2210 SetFunction(env, arrayFunction, entry.GetName(), entry.GetEntrypoint(),
2215 JSHandle<JSTaggedValue> speciesSymbol = env->GetSpeciesSymbol();
2217 CreateGetter(env, BuiltinsArray::Species, "[Symbol.species]", FunctionLength::ZERO);
2231 JSHandle<JSTaggedValue> unscopablesSymbol = env->GetUnscopablesSymbol();
2236 env->SetArrayProtoValuesFunction(thread_, desc.GetValue());
2237 env->SetArrayFunction(thread_, arrayFunction);
2238 env->SetArrayPrototype(thread_, arrFuncPrototype);
2244 void Builtins::InitializeTypedArray(const JSHandle<GlobalEnv> &env, JSHandle<JSTaggedValue> objFuncPrototypeVal) const
2260 env, typedArrFuncPrototype, BuiltinsTypedArray::TypedArrayBaseConstructor, "TypedArray", FunctionLength::ZERO));
2267 SetFunction(env, typedArrFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
2273 CreateGetter(env, entry.GetEntrypoint(), entry.GetName(), entry.GetLength());
2279 JSHandle<JSTaggedValue> arrFuncPrototype = env->GetArrayPrototype();
2289 JSHandle<JSTaggedValue> iteratorSymbol = env->GetIteratorSymbol();
2297 JSHandle<JSTaggedValue> toStringTagSymbol = env->GetToStringTagSymbol();
2299 CreateGetter(env, BuiltinsTypedArray::ToStringTag, "[Symbol.toStringTag]", FunctionLength::ZERO);
2304 SetFunction(env, typedArrayFunction, entry.GetName(), entry.GetEntrypoint(),
2309 JSHandle<JSTaggedValue> speciesSymbol = env->GetSpeciesSymbol();
2311 CreateGetter(env, BuiltinsTypedArray::Species, "[Symbol.species]", FunctionLength::ZERO);
2314 env->SetTypedArrayFunction(thread_, typedArrayFunction.GetTaggedValue());
2315 env->SetTypedArrayPrototype(thread_, typedArrFuncPrototype);
2316 env->SetTypedArrayProtoValuesFunction(thread_, valuesFunc);
2323 factory_->NewEcmaHClass(JSFunction::SIZE, JSType::JS_FUNCTION, env->GetTypedArrayFunction());
2325 env->SetSpecificTypedArrayFunctionClass(thread_, specificTypedArrayFuncClass);
2328 Initialize##Type(env, typedArrFuncInstanceHClass);
2333 void Builtins::LazyInitializeTypedArray(const JSHandle<GlobalEnv> &env) const
2336 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
2341 env->SetTypedArrayFunction(thread_, accessor);
2342 env->SetTypedArrayPrototype(thread_, accessor);
2343 env->SetSpecificTypedArrayFunctionClass(thread_, accessor);
2346 LazyInitialize##Type(env);
2352 void Builtins::Initialize##Type(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &arrFuncClass) const \
2367 env, reinterpret_cast<void *>(BuiltinsTypedArray::Type##Constructor), \
2369 InitializeCtor(env, arrFuncPrototype, arrayFunction, #Type, FunctionLength::THREE); \
2376 env->Set##Type##Function(thread_, arrayFunction); \
2377 env->Set##Type##FunctionPrototype(thread_, arrFuncPrototypeValue); \
2378 env->Set##Type##RootHclass(thread_, arrFuncInstanceHClass); \
2379 env->Set##Type##RootHclassOnHeap(thread_, arrFuncInstanceHClassOnHeap); \
2393 void Builtins::LazyInitialize##Type(const JSHandle<GlobalEnv> &env) const \
2396 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject()); \
2400 env->Set##Type##Function(thread_, accessor); \
2401 env->Set##Type##FunctionPrototype(thread_, accessor); \
2402 env->Set##Type##RootHclass(thread_, accessor); \
2403 env->Set##Type##RootHclassOnHeap(thread_, accessor); \
2409 void Builtins::InitializeArrayBuffer(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
2422 env, arrayBufferFuncPrototype, ArrayBuffer::ArrayBufferConstructor, "ArrayBuffer", FunctionLength::ONE));
2429 SetFunction(env, arrayBufferFuncPrototype, "slice", ArrayBuffer::Slice, FunctionLength::TWO);
2433 SetFunction(env,
2442 JSHandle<JSTaggedValue> speciesSymbol = env->GetSpeciesSymbol();
2444 CreateGetter(env, ArrayBuffer::Species, "[Symbol.species]", FunctionLength::ZERO);
2449 CreateGetter(env, ArrayBuffer::GetByteLength, "byteLength", FunctionLength::ZERO);
2454 SetStringTagSymbol(env, arrayBufferFuncPrototype, "ArrayBuffer");
2456 env->SetArrayBufferFunction(thread_, arrayBufferFunction.GetTaggedValue());
2459 void Builtins::LazyInitializeArrayBuffer(const JSHandle<GlobalEnv> &env) const
2462 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
2467 env->SetArrayBufferFunction(thread_, accessor);
2470 void Builtins::InitializeReflect(const JSHandle<GlobalEnv> &env,
2480 SetFunction(env, reflectObject, entry.GetName(), entry.GetEntrypoint(),
2485 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
2490 SetStringTagSymbol(env, reflectObject, "Reflect");
2492 env->SetReflectFunction(thread_, reflectObject.GetTaggedValue());
2495 void Builtins::InitializeSharedArrayBuffer(const JSHandle<GlobalEnv> &env,
2509 JSHandle<JSObject> SharedArrayBufferFunction(NewBuiltinConstructor(env, sharedArrayBufferFuncPrototype,
2517 SetFunction(env, sharedArrayBufferFuncPrototype, "slice", SharedArrayBuffer::Slice, FunctionLength::TWO);
2520 SetFunction(env, SharedArrayBufferFunction,
2524 JSHandle<JSTaggedValue> speciesSymbol = env->GetSpeciesSymbol();
2526 CreateGetter(env, SharedArrayBuffer::Species, "[Symbol.species]", FunctionLength::ZERO);
2531 CreateGetter(env, SharedArrayBuffer::GetByteLength, "byteLength", FunctionLength::ZERO);
2536 SetStringTagSymbol(env, sharedArrayBufferFuncPrototype, "SharedArrayBuffer");
2538 env->SetSharedArrayBufferFunction(thread_, SharedArrayBufferFunction.GetTaggedValue());
2541 void Builtins::LazyInitializeSharedArrayBuffer(const JSHandle<GlobalEnv> &env) const
2544 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
2549 env->SetSharedArrayBufferFunction(thread_, accessor);
2552 void Builtins::InitializePromise(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &promiseFuncClass)
2563 NewBuiltinConstructor(env, promiseFuncPrototype, Promise::PromiseConstructor, "Promise", FunctionLength::ONE));
2570 SetFunction(env, promiseFunction, entry.GetName(), entry.GetEntrypoint(),
2575 SetFunction(env, promiseFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
2579 SetStringTagSymbol(env, promiseFuncPrototype, "Promise");
2582 JSHandle<JSTaggedValue> speciesSymbol(env->GetSpeciesSymbol());
2584 CreateGetter(env, Promise::GetSpecies, "[Symbol.species]", FunctionLength::ZERO);
2587 env->SetPromiseFunction(thread_, promiseFunction);
2588 InitializeForPromiseFuncClass(env);
2592 void Builtins::InitializeForPromiseFuncClass(const JSHandle<GlobalEnv> &env)
2598 JSPromiseReactionsFunction::SIZE, JSType::JS_PROMISE_REACTIONS_FUNCTION, env->GetFunctionPrototype());
2601 env->SetPromiseReactionFunctionClass(thread_, promiseReactionFuncClass);
2604 JSPromiseExecutorFunction::SIZE, JSType::JS_PROMISE_EXECUTOR_FUNCTION, env->GetFunctionPrototype());
2607 env->SetPromiseExecutorFunctionClass(thread_, promiseExecutorFuncClass);
2610 JSAsyncModuleFulfilledFunction::SIZE, JSType::JS_ASYNC_MODULE_FULFILLED_FUNCTION, env->GetFunctionPrototype());
2613 env->SetAsyncModuleFulfilledFunctionClass(thread_, asyncModuleFulfilledFuncClass);
2616 JSAsyncModuleRejectedFunction::SIZE, JSType::JS_ASYNC_MODULE_REJECTED_FUNCTION, env->GetFunctionPrototype());
2619 env->SetAsyncModuleRejectedFunctionClass(thread_, asyncModuleRejectedFuncClass);
2623 JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION, env->GetFunctionPrototype());
2626 env->SetPromiseAllResolveElementFunctionClass(thread_, promiseAllResolveElementFunctionClass);
2630 JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION, env->GetFunctionPrototype());
2633 env->SetPromiseAnyRejectElementFunctionClass(thread_, promiseAnyRejectElementFunctionClass);
2637 JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION, env->GetFunctionPrototype());
2640 env->SetPromiseAllSettledElementFunctionClass(thread_, promiseAllSettledElementFunctionClass);
2644 JSType::JS_PROMISE_FINALLY_FUNCTION, env->GetFunctionPrototype());
2647 env->SetPromiseFinallyFunctionClass(thread_, promiseFinallyFunctionClass);
2651 JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION, env->GetFunctionPrototype());
2654 env->SetPromiseValueThunkOrThrowerFunctionClass(thread_, promiseValueThunkOrThrowerFunctionClass);
2657 void Builtins::InitializePromiseJob(const JSHandle<GlobalEnv> &env)
2660 auto func = NewFunction(env, keyString, BuiltinsPromiseJob::PromiseReactionJob, FunctionLength::TWO);
2661 env->SetPromiseReactionJob(thread_, func);
2662 func = NewFunction(env, keyString, BuiltinsPromiseJob::PromiseResolveThenableJob, FunctionLength::THREE);
2663 env->SetPromiseResolveThenableJob(thread_, func);
2664 func = NewFunction(env, keyString, BuiltinsPromiseJob::DynamicImportJob, FunctionLength::FOUR);
2665 env->SetDynamicImportJob(thread_, func);
2668 void Builtins::InitializeDataView(const JSHandle<GlobalEnv> &env, JSHandle<JSTaggedValue> objFuncPrototypeVal) const
2682 JSHandle<JSObject> dataViewFunction(NewBuiltinConstructor(env, dataViewFuncPrototype, DataView::DataViewConstructor,
2688 SetFunction(env, dataViewFuncPrototype, entry.GetName(), entry.GetEntrypoint(),
2693 JSHandle<JSTaggedValue> bufferGetter = CreateGetter(env, DataView::GetBuffer, "buffer", FunctionLength::ZERO);
2699 CreateGetter(env, DataView::GetByteLength, "byteLength", FunctionLength::ZERO);
2704 JSHandle<JSTaggedValue> offsetGetter = CreateGetter(env, DataView::GetOffset, "byteOffset", FunctionLength::ZERO);
2709 SetStringTagSymbol(env, dataViewFuncPrototype, "DataView");
2711 env->SetDataViewFunction(thread_, dataViewFunction.GetTaggedValue());
2712 env->SetDataViewPrototype(thread_, dataViewFuncPrototype.GetTaggedValue());
2719 void Builtins::LazyInitializeDataView(const JSHandle<GlobalEnv> &env) const
2722 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
2726 env->SetDataViewFunction(thread_, accessor);
2727 env->SetDataViewPrototype(thread_, accessor);
2730 JSHandle<JSFunction> Builtins::NewBuiltinConstructor(const JSHandle<GlobalEnv> &env,
2736 factory_->NewJSFunction(env, reinterpret_cast<void *>(ctorFunc), FunctionKind::BUILTIN_CONSTRUCTOR, builtinId);
2737 InitializeCtor(env, prototype, ctor, name, length);
2741 JSHandle<JSFunction> Builtins::NewBuiltinCjsCtor(const JSHandle<GlobalEnv> &env,
2746 factory_->NewJSFunction(env, reinterpret_cast<void *>(ctorFunc), FunctionKind::BUILTIN_CONSTRUCTOR);
2760 JSHandle<JSFunction> Builtins::NewFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSTaggedValue> &key,
2765 JSHandle<JSFunction> function = factory_->NewJSFunction(env, reinterpret_cast<void *>(func),
2777 void Builtins::SetFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj, std::string_view key,
2781 SetFunction(env, obj, keyString, func, length, builtinId);
2784 void Builtins::SetFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj,
2788 JSHandle<JSFunction> function(NewFunction(env, key, func, length, builtinId));
2793 JSHandle<JSFunction> Builtins::SetAndReturnFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj,
2798 return SetAndReturnFunction(env, obj, keyString, func, length, builtinId);
2801 JSHandle<JSFunction> Builtins::SetAndReturnFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj,
2805 JSHandle<JSFunction> function(NewFunction(env, key, func, length, builtinId));
2811 void Builtins::SetFrozenFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj, std::string_view key,
2815 JSHandle<JSFunction> function = NewFunction(env, keyString, func, length);
2821 void Builtins::SetFunctionAtSymbol(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj,
2825 JSHandle<JSFunction> function = factory_->NewJSFunction(env, reinterpret_cast<void *>(func));
2841 env->SetHasInstanceFunction(thread_, function);
2849 JSHandle<JSTaggedValue> Builtins::SetAndReturnFunctionAtSymbol(const JSHandle<GlobalEnv> &env,
2857 JSHandle<JSFunction> function = factory_->NewJSFunction(env, reinterpret_cast<void *>(func),
2874 env->SetHasInstanceFunction(thread_, function);
2882 void Builtins::SetStringTagSymbol(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj,
2886 JSHandle<JSTaggedValue> symbol = env->GetToStringTagSymbol();
2891 JSHandle<JSTaggedValue> Builtins::CreateGetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func,
2896 return CreateGetter(env, func, funcName, length, builtinId);
2899 JSHandle<JSTaggedValue> Builtins::CreateGetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func,
2903 JSHandle<JSFunction> function = factory_->NewJSFunction(env, reinterpret_cast<void *>(func),
2911 JSHandle<JSTaggedValue> Builtins::CreateSetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func,
2915 return CreateSetter(env, func, funcName, length);
2918 JSHandle<JSTaggedValue> Builtins::CreateSetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func,
2921 JSHandle<JSFunction> function = factory_->NewJSFunction(env, reinterpret_cast<void *>(func));
2975 void Builtins::SetFuncToObjAndGlobal(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &globalObject,
2979 JSHandle<JSFunction> function = factory_->NewJSFunction(env, reinterpret_cast<void *>(func),
2995 void Builtins::InitializeGeneratorFunction(const JSHandle<GlobalEnv> &env,
3011 NewBuiltinConstructor(env, generatorFuncPrototype, GeneratorObject::GeneratorFunctionConstructor,
3013 JSObject::SetPrototype(thread_, JSHandle<JSObject>::Cast(generatorFunction), env->GetFunctionFunction());
3018 env->SetGeneratorFunctionFunction(thread_, generatorFunction);
3021 PropertyDescriptor descriptor(thread_, env->GetGeneratorPrototype(), false, false, true);
3025 SetStringTagSymbol(env, generatorFuncPrototype, "GeneratorFunction");
3028 JSObject::SetPrototype(thread_, generatorFuncPrototype, env->GetFunctionPrototype());
3032 JSObject::DefineOwnProperty(thread_, JSHandle<JSObject>(env->GetGeneratorPrototype()),
3037 JSObject::DefineOwnProperty(thread_, JSHandle<JSObject>(env->GetInitialGenerator()),
3040 env->SetGeneratorFunctionPrototype(thread_, generatorFuncPrototype);
3043 void Builtins::InitializeAsyncGeneratorFunction(const JSHandle<GlobalEnv> &env,
3057 NewBuiltinConstructor(env, asyncGeneratorFuncPrototype,
3060 JSObject::SetPrototype(thread_, JSHandle<JSObject>::Cast(asyncGeneratorFunction), env->GetFunctionFunction());
3066 env->SetAsyncGeneratorFunctionFunction(thread_, asyncGeneratorFunction);
3069 PropertyDescriptor descriptor(thread_, env->GetAsyncGeneratorPrototype(), false, false, true);
3074 SetStringTagSymbol(env, asyncGeneratorFuncPrototype, "AsyncGeneratorFunction");
3076 JSObject::SetPrototype(thread_, asyncGeneratorFuncPrototype, env->GetFunctionPrototype());
3079 JSObject::DefineOwnProperty(thread_, JSHandle<JSObject>(env->GetInitialAsyncGenerator()),
3083 JSObject::DefineOwnProperty(thread_, JSHandle<JSObject>(env->GetInitialAsyncGenerator()),
3086 env->SetAsyncGeneratorFunctionPrototype(thread_, asyncGeneratorFuncPrototype);
3089 void Builtins::InitializeGenerator(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
3096 SetFunction(env, generatorPrototype, "constructor",
3099 SetFunction(env, generatorPrototype, "next", GeneratorObject::GeneratorPrototypeNext, FunctionLength::ONE);
3101 SetFunction(env, generatorPrototype, "return", GeneratorObject::GeneratorPrototypeReturn, FunctionLength::ONE);
3103 SetFunction(env, generatorPrototype, "throw", GeneratorObject::GeneratorPrototypeThrow, FunctionLength::ONE);
3106 SetStringTagSymbol(env, generatorPrototype, "Generator");
3108 env->SetGeneratorPrototype(thread_, generatorPrototype);
3109 JSObject::SetPrototype(thread_, generatorPrototype, env->GetIteratorPrototype());
3114 env->SetInitialGenerator(thread_, initialGeneratorFuncPrototype);
3117 void Builtins::InitializeAsyncGenerator(const JSHandle<GlobalEnv> &env,
3127 SetFunction(env, asyncGeneratorFuncPrototype, "next", AsyncGeneratorObject::AsyncGeneratorPrototypeNext,
3130 SetFunction(env, asyncGeneratorFuncPrototype, "return", AsyncGeneratorObject::AsyncGeneratorPrototypeReturn,
3133 SetFunction(env, asyncGeneratorFuncPrototype, "throw", AsyncGeneratorObject::AsyncGeneratorPrototypeThrow,
3137 SetStringTagSymbol(env, asyncGeneratorFuncPrototype, "AsyncGenerator");
3139 PropertyDescriptor descriptor(thread_, env->GetAsyncIteratorPrototype(), true, false, false);
3142 env->SetAsyncGeneratorPrototype(thread_, asyncGeneratorFuncPrototype);
3143 JSObject::SetPrototype(thread_, asyncGeneratorFuncPrototype, env->GetAsyncIteratorPrototype());
3148 env->SetInitialAsyncGenerator(thread_, initialAsyncGeneratorFuncPrototype);
3151 void Builtins::SetArgumentsSharedAccessor(const JSHandle<GlobalEnv> &env)
3153 JSHandle<JSTaggedValue> throwFunction = env->GetThrowTypeError();
3158 env->SetArgumentsCallerAccessor(thread_, accessor);
3163 env->SetArgumentsCalleeAccessor(thread_, accessor);
3186 JSHandle<JSFunction> Builtins::NewIntlConstructor(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &prototype,
3190 factory_->NewJSFunction(env, reinterpret_cast<void *>(ctorFunc), FunctionKind::BUILTIN_CONSTRUCTOR);
3191 InitializeIntlCtor(env, prototype, ctor, name, length);
3196 void Builtins::LazyInitialize##type(const JSHandle<GlobalEnv> &env) const \
3199 JSHandle<JSObject> intlObject(env->GetIntlFunction()); \
3204 env->Set##type##Function(thread_, accessor); \
3210 void Builtins::InitializeIntlCtor(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &prototype,
3226 JSHandle<JSObject> intlObject(thread_, env->GetIntlFunction().GetTaggedValue());
3232 void Builtins::InitializeIntl(const JSHandle<GlobalEnv> &env, const JSHandle<JSTaggedValue> &objFuncPrototypeValue)
3241 SetFunction(env, intlObject, "getCanonicalLocales", Intl::GetCanonicalLocales, FunctionLength::ONE);
3245 JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
3249 SetStringTagSymbol(env, intlObject, "Intl");
3251 env->SetIntlFunction(thread_, intlObject);
3254 void Builtins::InitializeDateTimeFormat(const JSHandle<GlobalEnv> &env)
3258 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3268 JSHandle<JSObject> dtfFunction(NewIntlConstructor(env, dtfPrototype, DateTimeFormat::DateTimeFormatConstructor,
3275 SetFunction(env, dtfFunction, "supportedLocalesOf", DateTimeFormat::SupportedLocalesOf, FunctionLength::ONE);
3279 SetStringTagSymbol(env, dtfPrototype, "Intl.DateTimeFormat");
3280 env->SetDateTimeFormatFunction(thread_, dtfFunction);
3283 JSHandle<JSTaggedValue> formatGetter = CreateGetter(env, DateTimeFormat::Format, "format", FunctionLength::ZERO);
3288 SetFunction(env, dtfPrototype, "formatToParts", DateTimeFormat::FormatToParts, FunctionLength::ONE);
3291 SetFunction(env, dtfPrototype, "resolvedOptions", DateTimeFormat::ResolvedOptions, FunctionLength::ZERO);
3293 SetFunction(env, dtfPrototype, "formatRange", DateTimeFormat::FormatRange, FunctionLength::TWO);
3295 SetFunction(env, dtfPrototype, "formatRangeToParts", DateTimeFormat::FormatRangeToParts, FunctionLength::TWO);
3298 void Builtins::InitializeRelativeTimeFormat(const JSHandle<GlobalEnv> &env)
3302 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3312 JSHandle<JSObject> rtfFunction(NewIntlConstructor(env, rtfPrototype,
3320 SetFunction(env, rtfFunction, "supportedLocalesOf", RelativeTimeFormat::SupportedLocalesOf, FunctionLength::ONE);
3324 SetStringTagSymbol(env, rtfPrototype, "Intl.RelativeTimeFormat");
3325 env->SetRelativeTimeFormatFunction(thread_, rtfFunction);
3328 SetFunction(env, rtfPrototype, "format", RelativeTimeFormat::Format, FunctionLength::TWO);
3331 SetFunction(env, rtfPrototype, "formatToParts", RelativeTimeFormat::FormatToParts, FunctionLength::TWO);
3334 SetFunction(env, rtfPrototype, "resolvedOptions", RelativeTimeFormat::ResolvedOptions, FunctionLength::ZERO);
3337 void Builtins::InitializeNumberFormat(const JSHandle<GlobalEnv> &env)
3341 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3351 JSHandle<JSObject> nfFunction(NewIntlConstructor(env, nfPrototype, NumberFormat::NumberFormatConstructor,
3358 SetFunction(env, nfFunction, "supportedLocalesOf", NumberFormat::SupportedLocalesOf, FunctionLength::ONE);
3362 SetStringTagSymbol(env, nfPrototype, "Intl.NumberFormat");
3363 env->SetNumberFormatFunction(thread_, nfFunction);
3366 JSHandle<JSTaggedValue> formatGetter = CreateGetter(env, NumberFormat::Format, "format", FunctionLength::ZERO);
3371 SetFunction(env, nfPrototype, "formatToParts", NumberFormat::FormatToParts, FunctionLength::ONE);
3374 SetFunction(env, nfPrototype, "resolvedOptions", NumberFormat::ResolvedOptions, FunctionLength::ZERO);
3377 void Builtins::InitializeLocale(const JSHandle<GlobalEnv> &env)
3381 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3391 NewIntlConstructor(env, localePrototype, Locale::LocaleConstructor, "Locale", FunctionLength::ONE));
3397 SetFunction(env, localePrototype, "maximize", Locale::Maximize, FunctionLength::ZERO);
3398 SetFunction(env, localePrototype, "minimize", Locale::Minimize, FunctionLength::ZERO);
3399 SetFunction(env, localePrototype, "toString", Locale::ToString, FunctionLength::ZERO);
3401 JSHandle<JSTaggedValue> baseNameGetter = CreateGetter(env, Locale::GetBaseName, "baseName", FunctionLength::ZERO);
3404 JSHandle<JSTaggedValue> calendarGetter = CreateGetter(env, Locale::GetCalendar, "calendar", FunctionLength::ZERO);
3408 CreateGetter(env, Locale::GetCaseFirst, "caseFirst", FunctionLength::ZERO);
3412 CreateGetter(env, Locale::GetCollation, "collation", FunctionLength::ZERO);
3416 CreateGetter(env, Locale::GetHourCycle, "hourCycle", FunctionLength::ZERO);
3419 JSHandle<JSTaggedValue> numericGetter = CreateGetter(env, Locale::GetNumeric, "numeric", FunctionLength::ZERO);
3423 CreateGetter(env, Locale::GetNumberingSystem, "numberingSystem", FunctionLength::ZERO);
3426 JSHandle<JSTaggedValue> languageGetter = CreateGetter(env, Locale::GetLanguage, "language", FunctionLength::ZERO);
3429 JSHandle<JSTaggedValue> scriptGetter = CreateGetter(env, Locale::GetScript, "script", FunctionLength::ZERO);
3432 JSHandle<JSTaggedValue> regionGetter = CreateGetter(env, Locale::GetRegion, "region", FunctionLength::ZERO);
3436 SetStringTagSymbol(env, localePrototype, "Intl.Locale");
3437 env->SetLocaleFunction(thread_, localeFunction);
3440 void Builtins::InitializeCollator(const JSHandle<GlobalEnv> &env)
3444 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3455 NewIntlConstructor(env, collatorPrototype, Collator::CollatorConstructor, "Collator", FunctionLength::ZERO));
3461 SetFunction(env, collatorFunction, "supportedLocalesOf", Collator::SupportedLocalesOf, FunctionLength::ONE);
3465 SetStringTagSymbol(env, collatorPrototype, "Intl.Collator");
3466 env->SetCollatorFunction(thread_, collatorFunction);
3469 JSHandle<JSTaggedValue> compareGetter = CreateGetter(env, Collator::Compare, "compare", FunctionLength::ZERO);
3474 SetFunction(env, collatorPrototype, "resolvedOptions", Collator::ResolvedOptions, FunctionLength::ZERO,
3478 void Builtins::InitializePluralRules(const JSHandle<GlobalEnv> &env)
3482 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3493 NewIntlConstructor(env, prPrototype, PluralRules::PluralRulesConstructor, "PluralRules", FunctionLength::ZERO));
3499 SetFunction(env, prFunction, "supportedLocalesOf", PluralRules::SupportedLocalesOf, FunctionLength::ONE);
3503 SetStringTagSymbol(env, prPrototype, "Intl.PluralRules");
3504 env->SetPluralRulesFunction(thread_, prFunction);
3507 SetFunction(env, prPrototype, "select", PluralRules::Select, FunctionLength::ONE);
3510 SetFunction(env, prPrototype, "resolvedOptions", PluralRules::ResolvedOptions, FunctionLength::ZERO);
3513 void Builtins::InitializeDisplayNames(const JSHandle<GlobalEnv> &env)
3517 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3527 JSHandle<JSObject> dnFunction(NewIntlConstructor(env, dnPrototype, DisplayNames::DisplayNamesConstructor,
3534 SetFunction(env, dnFunction, "supportedLocalesOf", DisplayNames::SupportedLocalesOf, FunctionLength::ONE);
3538 SetStringTagSymbol(env, dnPrototype, "Intl.DisplayNames");
3539 env->SetDisplayNamesFunction(thread_, dnFunction);
3542 SetFunction(env, dnPrototype, "of", DisplayNames::Of, FunctionLength::ONE);
3545 SetFunction(env, dnPrototype, "resolvedOptions", DisplayNames::ResolvedOptions, FunctionLength::ZERO);
3548 void Builtins::InitializeListFormat(const JSHandle<GlobalEnv> &env)
3552 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3562 JSHandle<JSObject> lfFunction(NewIntlConstructor(env, lfPrototype, ListFormat::ListFormatConstructor,
3569 SetFunction(env, lfFunction, "supportedLocalesOf", ListFormat::SupportedLocalesOf, FunctionLength::ONE);
3573 SetStringTagSymbol(env, lfPrototype, "Intl.ListFormat");
3574 env->SetListFormatFunction(thread_, lfFunction);
3577 SetFunction(env, lfPrototype, "format", ListFormat::Format, FunctionLength::ONE);
3580 SetFunction(env, lfPrototype, "formatToParts", ListFormat::FormatToParts, FunctionLength::ONE);
3583 SetFunction(env, lfPrototype, "resolvedOptions", ListFormat::ResolvedOptions, FunctionLength::ZERO);
3586 void Builtins::InitializeSegmenter(const JSHandle<GlobalEnv> &env)
3590 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3600 JSHandle<JSObject> sgFunction(NewIntlConstructor(env, sgPrototype, Segmenter::SegmenterConstructor,
3607 SetFunction(env, sgFunction, "supportedLocalesOf", Segmenter::SupportedLocalesOf, FunctionLength::ONE);
3611 SetStringTagSymbol(env, sgPrototype, "Intl.Segmenter");
3612 env->SetSegmenterFunction(thread_, sgFunction);
3615 SetFunction(env, sgPrototype, "resolvedOptions", Segmenter::ResolvedOptions, FunctionLength::ZERO);
3618 SetFunction(env, sgPrototype, "segment", Segmenter::Segment, FunctionLength::ONE);
3621 void Builtins::InitializeSegments(const JSHandle<GlobalEnv> &env)
3625 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3634 factory_->NewJSFunction(env, static_cast<void *>(nullptr), FunctionKind::BASE_CONSTRUCTOR));
3639 env->SetSegmentsFunction(thread_, segmentsFunction);
3642 SetFunction(env, segmentsPrototype, "containing", Segments::Containing, FunctionLength::ONE);
3643 SetAndReturnFunctionAtSymbol(env, segmentsPrototype,
3644 env->GetIteratorSymbol(), "[Symbol.iterator]", Segments::GetSegmentIterator, FunctionLength::ZERO);
3647 void Builtins::InitializeSegmentIterator(const JSHandle<GlobalEnv> &env,
3658 factory_->NewJSFunction(env, static_cast<void *>(nullptr), FunctionKind::BASE_CONSTRUCTOR));
3663 SetFunction(env, segIterPrototype, "next", SegmentIterator::Next, FunctionLength::ZERO);
3664 SetStringTagSymbol(env, segIterPrototype, "Segmenter String Iterator");
3666 env->SetSegmentIterator(thread_, segIterFunction);
3667 env->SetSegmentIteratorPrototype(thread_, segIterPrototype);
3671 JSHandle<JSObject> Builtins::InitializeArkTools(const JSHandle<GlobalEnv> &env) const
3675 SetFunction(env, tools, entry.GetName(), entry.GetEntrypoint(),
3678 JSHandle<JSTaggedValue> gcBuiltins(InitializeGcBuiltins(env));
3683 JSHandle<JSObject> Builtins::InitializeGcBuiltins(const JSHandle<GlobalEnv> &env) const
3687 SetFunction(env, builtins, entry.GetName(), entry.GetEntrypoint(),
3751 JSHandle<JSObject> Builtins::InitializeArkPrivate(const JSHandle<GlobalEnv> &env) const
3754 SetFrozenFunction(env, arkPrivate, "Load", ContainersPrivate::Load, FunctionLength::ZERO);
3777 void Builtins::InitializeModuleNamespace(const JSHandle<GlobalEnv> &env,
3789 env->SetModuleNamespaceClass(thread_, moduleNamespaceHClass.GetTaggedValue());
3792 SetStringTagSymbol(env, moduleNamespacePrototype, "Module");
3795 void Builtins::InitializeNativeModuleFailureInfo(const JSHandle<GlobalEnv> &env,
3808 env->SetNativeModuleFailureInfoClass(thread_, nativeModuleFailureInfoHClass.GetTaggedValue());
3811 void Builtins::InitializeCjsModule(const JSHandle<GlobalEnv> &env) const
3815 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3825 NewBuiltinCjsCtor(env, cjsModulePrototype, BuiltinsCjsModule::CjsModuleConstructor, "Module",
3833 SetFunction(env, cjsModuleFunction, "_load", BuiltinsCjsModule::Load, FunctionLength::ONE);
3834 SetFunction(env, cjsModuleFunction, "_resolveFilename", BuiltinsCjsModule::ResolveFilename, FunctionLength::ONE);
3837 SetFunction(env, cjsModulePrototype, "require", BuiltinsCjsModule::Require, FunctionLength::ONE);
3838 SetFunction(env, cjsModulePrototype, "getExportsForCircularRequire",
3840 SetFunction(env, cjsModulePrototype, "updateChildren", BuiltinsCjsModule::UpdateChildren, FunctionLength::ONE);
3864 env->SetCjsModuleFunction(thread_, cjsModuleFunction);
3867 void Builtins::InitializeCjsExports(const JSHandle<GlobalEnv> &env) const
3872 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3882 NewBuiltinCjsCtor(env, cjsExportsPrototype, BuiltinsCjsExports::CjsExportsConstructor, "Exports",
3889 env->SetCjsExportsFunction(thread_, cjsExportsFunction);
3892 void Builtins::InitializeCjsRequire(const JSHandle<GlobalEnv> &env) const
3896 JSHandle<JSFunction> objFun(env->GetObjectFunction());
3906 NewBuiltinCjsCtor(env, cjsRequirePrototype, BuiltinsCjsRequire::CjsRequireConstructor, "require",
3913 SetFunction(env, cjsRequirePrototype, "Main", BuiltinsCjsRequire::Main, FunctionLength::ONE);
3915 env->SetCjsRequireFunction(thread_, cjsRequireFunction);
3918 void Builtins::InitializeDefaultExportOfScript(const JSHandle<GlobalEnv> &env) const
3920 JSHandle<JSFunction> builtinObj(env->GetObjectFunction());
3930 env->SetExportOfScript(thread_, obj);
3993 void Builtins::RegisterSendableContainers(const JSHandle<GlobalEnv> &env) const
3995 auto globalObject = JSHandle<JSObject>::Cast(env->GetJSGlobalObject());
3998 PropertyDescriptor desc(thread_, env->GetSBuiltininMapFunction(), true, false, true);
4003 PropertyDescriptor desc(thread_, env->GetSBuiltininSetFunction(), true, false, true);
4008 PropertyDescriptor desc(thread_, env->GetSharedArrayFunction(), true, false, true);
4013 PropertyDescriptor desc(thread_, env->GetSBuiltininArrayBufferFunction(), true, false, true);
4020 PropertyDescriptor desc(thread_, env->Get##ctorName##Function(), true, false, true); \