@@ -3862,6 +3862,61 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
38623862    native_context ()->set_bound_function_with_constructor_map (*map);
38633863  }
38643864
3865+   {  //  -- F i n a l i z a t i o n R e g i s t r y
3866+     Handle<JSFunction> finalization_registry_fun = InstallFunction (
3867+         isolate_, global, factory->FinalizationRegistry_string (),
3868+         JS_FINALIZATION_REGISTRY_TYPE, JSFinalizationRegistry::kHeaderSize , 0 ,
3869+         factory->the_hole_value (), Builtins::kFinalizationRegistryConstructor );
3870+     InstallWithIntrinsicDefaultProto (
3871+         isolate_, finalization_registry_fun,
3872+         Context::JS_FINALIZATION_REGISTRY_FUNCTION_INDEX);
3873+ 
3874+     finalization_registry_fun->shared ().DontAdaptArguments ();
3875+     finalization_registry_fun->shared ().set_length (1 );
3876+ 
3877+     Handle<JSObject> finalization_registry_prototype (
3878+         JSObject::cast (finalization_registry_fun->instance_prototype ()),
3879+         isolate ());
3880+ 
3881+     InstallToStringTag (isolate_, finalization_registry_prototype,
3882+                        factory->FinalizationRegistry_string ());
3883+ 
3884+     SimpleInstallFunction (isolate_, finalization_registry_prototype, " register" 
3885+                           Builtins::kFinalizationRegistryRegister , 2 , false );
3886+ 
3887+     SimpleInstallFunction (isolate_, finalization_registry_prototype,
3888+                           " unregister" 
3889+                           Builtins::kFinalizationRegistryUnregister , 1 , false );
3890+ 
3891+     //  The cleanupSome function is created but not exposed, as it is used
3892+     //  internally by InvokeFinalizationRegistryCleanupFromTask.
3893+     // 
3894+     //  It is exposed by FLAG_harmony_weak_refs_with_cleanup_some.
3895+     Handle<JSFunction> cleanup_some_fun = SimpleCreateFunction (
3896+         isolate_, factory->InternalizeUtf8String (" cleanupSome" 
3897+         Builtins::kFinalizationRegistryPrototypeCleanupSome , 0 , false );
3898+     native_context ()->set_finalization_registry_cleanup_some (*cleanup_some_fun);
3899+   }
3900+ 
3901+   {  //  -- W e a k R e f
3902+     Handle<JSFunction> weak_ref_fun = InstallFunction (
3903+         isolate_, global, " WeakRef" kHeaderSize ,
3904+         0 , factory->the_hole_value (), Builtins::kWeakRefConstructor );
3905+     InstallWithIntrinsicDefaultProto (isolate_, weak_ref_fun,
3906+                                      Context::JS_WEAK_REF_FUNCTION_INDEX);
3907+ 
3908+     weak_ref_fun->shared ().DontAdaptArguments ();
3909+     weak_ref_fun->shared ().set_length (1 );
3910+ 
3911+     Handle<JSObject> weak_ref_prototype (
3912+         JSObject::cast (weak_ref_fun->instance_prototype ()), isolate ());
3913+ 
3914+     InstallToStringTag (isolate_, weak_ref_prototype, factory->WeakRef_string ());
3915+ 
3916+     SimpleInstallFunction (isolate_, weak_ref_prototype, " deref" 
3917+                           Builtins::kWeakRefDeref , 0 , true );
3918+   }
3919+ 
38653920  {  //  --- sloppy arguments map
38663921    Handle<String> arguments_string = factory->Arguments_string ();
38673922    Handle<JSFunction> function = CreateFunctionForBuiltinWithPrototype (
@@ -4353,75 +4408,8 @@ void Genesis::InitializeGlobal_harmony_atomics() {
43534408  InstallToStringTag (isolate_, isolate ()->atomics_object (), " Atomics" 
43544409}
43554410
4356- void  Genesis::InitializeGlobal_harmony_weak_refs () {
4357-   if  (!FLAG_harmony_weak_refs) return ;
4358- 
4359-   Factory* factory = isolate ()->factory ();
4360-   Handle<JSGlobalObject> global (native_context ()->global_object (), isolate ());
4361- 
4362-   {
4363-     //  Create %FinalizationRegistry%
4364-     Handle<JSFunction> finalization_registry_fun = InstallFunction (
4365-         isolate (), global, factory->FinalizationRegistry_string (),
4366-         JS_FINALIZATION_REGISTRY_TYPE, JSFinalizationRegistry::kHeaderSize , 0 ,
4367-         factory->the_hole_value (), Builtins::kFinalizationRegistryConstructor );
4368-     InstallWithIntrinsicDefaultProto (
4369-         isolate (), finalization_registry_fun,
4370-         Context::JS_FINALIZATION_REGISTRY_FUNCTION_INDEX);
4371- 
4372-     finalization_registry_fun->shared ().DontAdaptArguments ();
4373-     finalization_registry_fun->shared ().set_length (1 );
4374- 
4375-     Handle<JSObject> finalization_registry_prototype (
4376-         JSObject::cast (finalization_registry_fun->instance_prototype ()),
4377-         isolate ());
4378- 
4379-     InstallToStringTag (isolate (), finalization_registry_prototype,
4380-                        factory->FinalizationRegistry_string ());
4381- 
4382-     SimpleInstallFunction (isolate (), finalization_registry_prototype,
4383-                           " register" kFinalizationRegistryRegister ,
4384-                           2 , false );
4385- 
4386-     SimpleInstallFunction (isolate (), finalization_registry_prototype,
4387-                           " unregister" 
4388-                           Builtins::kFinalizationRegistryUnregister , 1 , false );
4389- 
4390-     //  The cleanupSome function is created but not exposed, as it is used
4391-     //  internally by InvokeFinalizationRegistryCleanupFromTask.
4392-     // 
4393-     //  It is exposed by FLAG_harmony_weak_refs_with_cleanup_some.
4394-     Handle<JSFunction> cleanup_some_fun = SimpleCreateFunction (
4395-         isolate (), factory->InternalizeUtf8String (" cleanupSome" 
4396-         Builtins::kFinalizationRegistryPrototypeCleanupSome , 0 , false );
4397-     native_context ()->set_finalization_registry_cleanup_some (*cleanup_some_fun);
4398-   }
4399-   {
4400-     //  Create %WeakRef%
4401-     Handle<JSFunction> weak_ref_fun = InstallFunction (
4402-         isolate (), global, factory->WeakRef_string (), JS_WEAK_REF_TYPE,
4403-         JSWeakRef::kHeaderSize , 0 , factory->the_hole_value (),
4404-         Builtins::kWeakRefConstructor );
4405-     InstallWithIntrinsicDefaultProto (isolate (), weak_ref_fun,
4406-                                      Context::JS_WEAK_REF_FUNCTION_INDEX);
4407- 
4408-     weak_ref_fun->shared ().DontAdaptArguments ();
4409-     weak_ref_fun->shared ().set_length (1 );
4410- 
4411-     Handle<JSObject> weak_ref_prototype (
4412-         JSObject::cast (weak_ref_fun->instance_prototype ()), isolate ());
4413- 
4414-     InstallToStringTag (isolate (), weak_ref_prototype,
4415-                        factory->WeakRef_string ());
4416- 
4417-     SimpleInstallFunction (isolate (), weak_ref_prototype, " deref" 
4418-                           Builtins::kWeakRefDeref , 0 , true );
4419-   }
4420- }
4421- 
44224411void  Genesis::InitializeGlobal_harmony_weak_refs_with_cleanup_some () {
44234412  if  (!FLAG_harmony_weak_refs_with_cleanup_some) return ;
4424-   DCHECK (FLAG_harmony_weak_refs);
44254413
44264414  Handle<JSFunction> finalization_registry_fun =
44274415      isolate ()->js_finalization_registry_fun ();
0 commit comments