From f579e1194046c50f2e6bb54348d48c8e7d1a53cf Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Fri, 15 Mar 2019 18:35:06 +0530 Subject: deps: update V8 to 7.4.288.13 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/26685 Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso Reviewed-By: Refael Ackermann --- deps/v8/src/builtins/builtins-weak-refs.cc | 108 +++++++++++++++-------------- 1 file changed, 55 insertions(+), 53 deletions(-) (limited to 'deps/v8/src/builtins/builtins-weak-refs.cc') diff --git a/deps/v8/src/builtins/builtins-weak-refs.cc b/deps/v8/src/builtins/builtins-weak-refs.cc index e89deb705b..1d8a6f39f6 100644 --- a/deps/v8/src/builtins/builtins-weak-refs.cc +++ b/deps/v8/src/builtins/builtins-weak-refs.cc @@ -9,7 +9,7 @@ namespace v8 { namespace internal { -BUILTIN(WeakFactoryConstructor) { +BUILTIN(FinalizationGroupConstructor) { HandleScope scope(isolate); Handle target = args.target(); if (args.new_target()->IsUndefined(isolate)) { // [[Call]] @@ -31,91 +31,92 @@ BUILTIN(WeakFactoryConstructor) { isolate, result, JSObject::New(target, new_target, Handle::null())); - Handle weak_factory = Handle::cast(result); - weak_factory->set_native_context(*isolate->native_context()); - weak_factory->set_cleanup(*cleanup); - weak_factory->set_flags( - JSWeakFactory::ScheduledForCleanupField::encode(false)); - return *weak_factory; + Handle finalization_group = + Handle::cast(result); + finalization_group->set_native_context(*isolate->native_context()); + finalization_group->set_cleanup(*cleanup); + finalization_group->set_flags( + JSFinalizationGroup::ScheduledForCleanupField::encode(false)); + + DCHECK(finalization_group->active_cells()->IsUndefined(isolate)); + DCHECK(finalization_group->cleared_cells()->IsUndefined(isolate)); + DCHECK(finalization_group->key_map()->IsUndefined(isolate)); + return *finalization_group; } -BUILTIN(WeakFactoryMakeCell) { +BUILTIN(FinalizationGroupRegister) { HandleScope scope(isolate); - const char* method_name = "WeakFactory.prototype.makeCell"; + const char* method_name = "FinalizationGroup.prototype.register"; - CHECK_RECEIVER(JSWeakFactory, weak_factory, method_name); + CHECK_RECEIVER(JSFinalizationGroup, finalization_group, method_name); Handle target = args.atOrUndefined(isolate, 1); if (!target->IsJSReceiver()) { THROW_NEW_ERROR_RETURN_FAILURE( isolate, - NewTypeError(MessageTemplate::kWeakRefsMakeCellTargetMustBeObject)); + NewTypeError(MessageTemplate::kWeakRefsRegisterTargetMustBeObject)); } - Handle target_receiver = Handle::cast(target); Handle holdings = args.atOrUndefined(isolate, 2); if (target->SameValue(*holdings)) { THROW_NEW_ERROR_RETURN_FAILURE( isolate, NewTypeError( - MessageTemplate::kWeakRefsMakeCellTargetAndHoldingsMustNotBeSame)); + MessageTemplate::kWeakRefsRegisterTargetAndHoldingsMustNotBeSame)); } + Handle key = args.atOrUndefined(isolate, 3); + // TODO(marja, gsathya): Restrictions on "key" (e.g., does it need to be an + // object). + // TODO(marja): Realms. - Handle weak_cell_map(isolate->native_context()->js_weak_cell_map(), - isolate); - - // Allocate the JSWeakCell object in the old space, because 1) JSWeakCell - // weakness handling is only implemented in the old space 2) they're - // supposedly long-living. TODO(marja): Support JSWeakCells in Scavenger. - Handle weak_cell = - Handle::cast(isolate->factory()->NewJSObjectFromMap( - weak_cell_map, TENURED, Handle::null())); - weak_cell->set_target(*target_receiver); - weak_cell->set_holdings(*holdings); - weak_factory->AddWeakCell(*weak_cell); - return *weak_cell; + JSFinalizationGroup::Register(finalization_group, + Handle::cast(target), holdings, key, + isolate); + return ReadOnlyRoots(isolate).undefined_value(); +} + +BUILTIN(FinalizationGroupUnregister) { + HandleScope scope(isolate); + const char* method_name = "FinalizationGroup.prototype.unregister"; + + CHECK_RECEIVER(JSFinalizationGroup, finalization_group, method_name); + + Handle key = args.atOrUndefined(isolate, 1); + JSFinalizationGroup::Unregister(finalization_group, key, isolate); + return ReadOnlyRoots(isolate).undefined_value(); } -BUILTIN(WeakFactoryCleanupSome) { +BUILTIN(FinalizationGroupCleanupSome) { HandleScope scope(isolate); - const char* method_name = "WeakFactory.prototype.cleanupSome"; + const char* method_name = "FinalizationGroup.prototype.cleanupSome"; - CHECK_RECEIVER(JSWeakFactory, weak_factory, method_name); + CHECK_RECEIVER(JSFinalizationGroup, finalization_group, method_name); + + // TODO(marja, gsathya): Add missing "cleanup" callback. // Don't do set_scheduled_for_cleanup(false); we still have the microtask // scheduled and don't want to schedule another one in case the user never // executes microtasks. - JSWeakFactory::Cleanup(weak_factory, isolate); + JSFinalizationGroup::Cleanup(finalization_group, isolate); return ReadOnlyRoots(isolate).undefined_value(); } -BUILTIN(WeakFactoryCleanupIteratorNext) { +BUILTIN(FinalizationGroupCleanupIteratorNext) { HandleScope scope(isolate); - CHECK_RECEIVER(JSWeakFactoryCleanupIterator, iterator, "next"); + CHECK_RECEIVER(JSFinalizationGroupCleanupIterator, iterator, "next"); - Handle weak_factory(iterator->factory(), isolate); - if (!weak_factory->NeedsCleanup()) { + Handle finalization_group(iterator->finalization_group(), + isolate); + if (!finalization_group->NeedsCleanup()) { return *isolate->factory()->NewJSIteratorResult( handle(ReadOnlyRoots(isolate).undefined_value(), isolate), true); } - Handle weak_cell_object = - handle(weak_factory->PopClearedCell(isolate), isolate); - - return *isolate->factory()->NewJSIteratorResult(weak_cell_object, false); -} - -BUILTIN(WeakCellHoldingsGetter) { - HandleScope scope(isolate); - CHECK_RECEIVER(JSWeakCell, weak_cell, "get WeakCell.holdings"); - return weak_cell->holdings(); -} + Handle holdings = handle( + JSFinalizationGroup::PopClearedCellHoldings(finalization_group, isolate), + isolate); -BUILTIN(WeakCellClear) { - HandleScope scope(isolate); - CHECK_RECEIVER(JSWeakCell, weak_cell, "WeakCell.prototype.clear"); - weak_cell->Clear(isolate); - return ReadOnlyRoots(isolate).undefined_value(); + return *isolate->factory()->NewJSIteratorResult(holdings, false); } BUILTIN(WeakRefConstructor) { @@ -135,8 +136,9 @@ BUILTIN(WeakRefConstructor) { NewTypeError( MessageTemplate::kWeakRefsWeakRefConstructorTargetMustBeObject)); } - isolate->heap()->AddKeepDuringJobTarget( - Handle::cast(target_object)); + Handle target_receiver = + handle(JSReceiver::cast(*target_object), isolate); + isolate->heap()->AddKeepDuringJobTarget(target_receiver); // TODO(marja): Realms. @@ -146,7 +148,7 @@ BUILTIN(WeakRefConstructor) { JSObject::New(target, new_target, Handle::null())); Handle weak_ref = Handle::cast(result); - weak_ref->set_target(*target_object); + weak_ref->set_target(*target_receiver); return *weak_ref; } -- cgit v1.2.1