@@ -20,9 +20,9 @@ void FinalizationRegistryPrototype::initialize(GlobalObject& global_object)
20
20
Object::initialize (global_object);
21
21
u8 attr = Attribute::Writable | Attribute::Configurable;
22
22
23
- define_old_native_function (vm.names .cleanupSome , cleanup_some, 0 , attr);
24
- define_old_native_function (vm.names .register_ , register_, 2 , attr);
25
- define_old_native_function (vm.names .unregister , unregister, 1 , attr);
23
+ define_native_function (vm.names .cleanupSome , cleanup_some, 0 , attr);
24
+ define_native_function (vm.names .register_ , register_, 2 , attr);
25
+ define_native_function (vm.names .unregister , unregister, 1 , attr);
26
26
27
27
// 26.2.3.4 FinalizationRegistry.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-finalization-registry.prototype-@@tostringtag
28
28
define_direct_property (*vm.well_known_symbol_to_string_tag (), js_string (global_object.heap (), vm.names .FinalizationRegistry .as_string ()), Attribute::Configurable);
@@ -33,59 +33,49 @@ FinalizationRegistryPrototype::~FinalizationRegistryPrototype()
33
33
}
34
34
35
35
// @STAGE 2@ FinalizationRegistry.prototype.cleanupSome ( [ callback ] ), https://github.com/tc39/proposal-cleanup-some/blob/master/spec/finalization-registry.html
36
- JS_DEFINE_OLD_NATIVE_FUNCTION (FinalizationRegistryPrototype::cleanup_some)
36
+ JS_DEFINE_NATIVE_FUNCTION (FinalizationRegistryPrototype::cleanup_some)
37
37
{
38
- auto * finalization_registry = TRY_OR_DISCARD (typed_this_object (global_object));
38
+ auto * finalization_registry = TRY (typed_this_object (global_object));
39
39
40
40
auto callback = vm.argument (0 );
41
- if (vm.argument_count () > 0 && !callback.is_function ()) {
42
- vm.throw_exception <TypeError>(global_object, ErrorType::NotAFunction, callback.to_string_without_side_effects ());
43
- return {};
44
- }
41
+ if (vm.argument_count () > 0 && !callback.is_function ())
42
+ return vm.throw_completion <TypeError>(global_object, ErrorType::NotAFunction, callback.to_string_without_side_effects ());
45
43
46
44
finalization_registry->cleanup (callback.is_undefined () ? nullptr : &callback.as_function ());
47
45
48
46
return js_undefined ();
49
47
}
50
48
51
49
// 26.2.3.2 FinalizationRegistry.prototype.register ( target, heldValue [ , unregisterToken ] ), https://tc39.es/ecma262/#sec-finalization-registry.prototype.register
52
- JS_DEFINE_OLD_NATIVE_FUNCTION (FinalizationRegistryPrototype::register_)
50
+ JS_DEFINE_NATIVE_FUNCTION (FinalizationRegistryPrototype::register_)
53
51
{
54
- auto * finalization_registry = TRY_OR_DISCARD (typed_this_object (global_object));
52
+ auto * finalization_registry = TRY (typed_this_object (global_object));
55
53
56
54
auto target = vm.argument (0 );
57
- if (!target.is_object ()) {
58
- vm.throw_exception <TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects ());
59
- return {};
60
- }
55
+ if (!target.is_object ())
56
+ return vm.throw_completion <TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects ());
61
57
62
58
auto held_value = vm.argument (1 );
63
- if (same_value (target, held_value)) {
64
- vm.throw_exception <TypeError>(global_object, ErrorType::FinalizationRegistrySameTargetAndValue);
65
- return {};
66
- }
59
+ if (same_value (target, held_value))
60
+ return vm.throw_completion <TypeError>(global_object, ErrorType::FinalizationRegistrySameTargetAndValue);
67
61
68
62
auto unregister_token = vm.argument (2 );
69
- if (!unregister_token.is_object () && !unregister_token.is_undefined ()) {
70
- vm.throw_exception <TypeError>(global_object, ErrorType::NotAnObject, unregister_token.to_string_without_side_effects ());
71
- return {};
72
- }
63
+ if (!unregister_token.is_object () && !unregister_token.is_undefined ())
64
+ return vm.throw_completion <TypeError>(global_object, ErrorType::NotAnObject, unregister_token.to_string_without_side_effects ());
73
65
74
66
finalization_registry->add_finalization_record (target.as_cell (), held_value, unregister_token.is_undefined () ? nullptr : &unregister_token.as_object ());
75
67
76
68
return js_undefined ();
77
69
}
78
70
79
71
// 26.2.3.3 FinalizationRegistry.prototype.unregister ( unregisterToken ), https://tc39.es/ecma262/#sec-finalization-registry.prototype.unregister
80
- JS_DEFINE_OLD_NATIVE_FUNCTION (FinalizationRegistryPrototype::unregister)
72
+ JS_DEFINE_NATIVE_FUNCTION (FinalizationRegistryPrototype::unregister)
81
73
{
82
- auto * finalization_registry = TRY_OR_DISCARD (typed_this_object (global_object));
74
+ auto * finalization_registry = TRY (typed_this_object (global_object));
83
75
84
76
auto unregister_token = vm.argument (0 );
85
- if (!unregister_token.is_object ()) {
86
- vm.throw_exception <TypeError>(global_object, ErrorType::NotAnObject, unregister_token.to_string_without_side_effects ());
87
- return {};
88
- }
77
+ if (!unregister_token.is_object ())
78
+ return vm.throw_completion <TypeError>(global_object, ErrorType::NotAnObject, unregister_token.to_string_without_side_effects ());
89
79
90
80
return Value (finalization_registry->remove_by_token (unregister_token.as_object ()));
91
81
}
0 commit comments