| Index: src/isolate.cc
|
| diff --git a/src/isolate.cc b/src/isolate.cc
|
| index 2dc01358fa3c28e80dd55e4a3e3dfabc79a8c08c..34e6453ad77ec863dd01e1f048ad143c9767fc22 100644
|
| --- a/src/isolate.cc
|
| +++ b/src/isolate.cc
|
| @@ -3337,7 +3337,8 @@ void Isolate::FireCallCompletedCallback() {
|
| if (!handle_scope_implementer()->CallDepthIsZero()) return;
|
|
|
| bool run_microtasks =
|
| - pending_microtask_count() &&
|
| + (heap()->weak_refs()->length() ||
|
| + pending_microtask_count()) &&
|
| !handle_scope_implementer()->HasMicrotasksSuppressions() &&
|
| handle_scope_implementer()->microtasks_policy() ==
|
| v8::MicrotasksPolicy::kAuto;
|
| @@ -3502,6 +3503,34 @@ void Isolate::RunMicrotasks() {
|
| RunMicrotasksInternal();
|
| is_running_microtasks_ = false;
|
| FireMicrotasksCompletedCallback();
|
| + int left = 0;
|
| + for (int i = 0; i < heap()->weak_refs()->length(); i++) {
|
| + JSWeakRef* weak_ref = reinterpret_cast<JSWeakRef*>(
|
| + heap()->weak_refs()->get(i));
|
| + if (weak_ref->queued()) {
|
| + JSFunction* executor = weak_ref->executor();
|
| + if (executor == nullptr) continue;
|
| + MaybeHandle<Object> maybe_exception;
|
| + Handle<Object> argv[] = {
|
| + Handle<Object>(weak_ref->holdings(), this),
|
| + Handle<Object>(weak_ref, this)
|
| + };
|
| + int argc = 2;
|
| + Execution::TryCall(this,
|
| + Handle<Object>(executor, this),
|
| + factory()->undefined_value(),
|
| + argc, argv,
|
| + Execution::MessageHandling::kReport, &maybe_exception);
|
| + weak_ref->set_executor(nullptr);
|
| + weak_ref->set_holdings(nullptr);
|
| + weak_ref->set_held(false);
|
| + heap()->weak_refs()->set(left, weak_ref);
|
| + } else {
|
| + left++;
|
| + }
|
| + weak_ref->set_held(false);
|
| + }
|
| + heap()->weak_refs()->Shrink(left);
|
| }
|
|
|
|
|
| @@ -3602,7 +3631,6 @@ void Isolate::FireMicrotasksCompletedCallback() {
|
| }
|
| }
|
|
|
| -
|
| void Isolate::SetUseCounterCallback(v8::Isolate::UseCounterCallback callback) {
|
| DCHECK(!use_counter_callback_);
|
| use_counter_callback_ = callback;
|
|
|