From 2f0384871fcb4a92aefb4024f05c520a9610a6b0 Mon Sep 17 00:00:00 2001 From: Dave Tapuska Date: Thu, 13 Oct 2022 10:59:47 -0400 Subject: [PATCH] [execution] Pass microtask queue from Context to MicrotasksScope With a unique microtask queue possibly per context we need to pass the microtask queue for the MicrotasksScope otherwise the default one for the isolate will be used. BUG=chromium:961186 Change-Id: Ib085f08e20185c69760aeea335d673d9c4c72999 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3950216 Reviewed-by: Benedikt Meurer Reviewed-by: Camillo Bruni Commit-Queue: Dave Tapuska Cr-Commit-Position: refs/heads/main@{#83803} --- include/v8-microtask-queue.h | 5 +++ src/api/api.cc | 5 +++ src/execution/isolate.cc | 4 +- src/inspector/custom-preview.cc | 2 +- src/inspector/injected-script.cc | 2 +- src/inspector/v8-console.cc | 10 ++--- src/inspector/v8-debugger-agent-impl.cc | 2 +- src/inspector/v8-debugger.cc | 2 +- src/inspector/v8-inspector-impl.cc | 4 +- src/inspector/v8-regex.cc | 2 +- src/inspector/v8-runtime-agent-impl.cc | 12 +++--- src/inspector/value-mirror.cc | 8 ++-- test/cctest/test-api.cc | 54 ++++++++++++------------- test/cctest/test-debug.cc | 2 +- test/inspector/frontend-channel.h | 4 +- test/inspector/isolate-data.cc | 2 +- test/inspector/tasks.cc | 4 +- test/inspector/tasks.h | 4 +- 18 files changed, 69 insertions(+), 59 deletions(-) diff --git a/include/v8-microtask-queue.h b/include/v8-microtask-queue.h index f1624b903b..85d227fa3f 100644 --- a/include/v8-microtask-queue.h +++ b/include/v8-microtask-queue.h @@ -118,7 +118,12 @@ class V8_EXPORT V8_NODISCARD MicrotasksScope { public: enum Type { kRunMicrotasks, kDoNotRunMicrotasks }; + V8_DEPRECATE_SOON( + "May be incorrect if context was created with non-default microtask " + "queue") MicrotasksScope(Isolate* isolate, Type type); + + MicrotasksScope(Local context, Type type); MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type); ~MicrotasksScope(); diff --git a/src/api/api.cc b/src/api/api.cc index 14b7c541b3..06cd9c4ce0 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -9721,6 +9721,11 @@ MicrotasksScope::MicrotasksScope(Isolate* v8_isolate, MicrotasksScope::Type type) : MicrotasksScope(v8_isolate, nullptr, type) {} +MicrotasksScope::MicrotasksScope(Local v8_context, + MicrotasksScope::Type type) + : MicrotasksScope(v8_context->GetIsolate(), v8_context->GetMicrotaskQueue(), + type) {} + MicrotasksScope::MicrotasksScope(Isolate* v8_isolate, MicrotaskQueue* microtask_queue, MicrotasksScope::Type type) diff --git a/src/execution/isolate.cc b/src/execution/isolate.cc index dfe492b0a8..3300e12f20 100644 --- a/src/execution/isolate.cc +++ b/src/execution/isolate.cc @@ -6085,9 +6085,9 @@ class DefaultWasmAsyncResolvePromiseTask : public v8::Task { void Run() override { v8::HandleScope scope(isolate_); - MicrotasksScope microtasks_scope(isolate_, - MicrotasksScope::kDoNotRunMicrotasks); v8::Local context = context_.Get(isolate_); + MicrotasksScope microtasks_scope(context, + MicrotasksScope::kDoNotRunMicrotasks); v8::Local resolver = resolver_.Get(isolate_); v8::Local result = result_.Get(isolate_); diff --git a/src/inspector/custom-preview.cc b/src/inspector/custom-preview.cc index 97b0a07210..a02cdadb73 100644 --- a/src/inspector/custom-preview.cc +++ b/src/inspector/custom-preview.cc @@ -260,7 +260,7 @@ void generateCustomPreview(int sessionId, const String16& groupName, } v8::Isolate* isolate = context->GetIsolate(); - v8::MicrotasksScope microtasksScope(isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::TryCatch tryCatch(isolate); diff --git a/src/inspector/injected-script.cc b/src/inspector/injected-script.cc index 3a91791881..c55249329b 100644 --- a/src/inspector/injected-script.cc +++ b/src/inspector/injected-script.cc @@ -713,7 +713,7 @@ void InjectedScript::addPromiseCallback( return; } - v8::MicrotasksScope microtasksScope(m_context->isolate(), + v8::MicrotasksScope microtasksScope(m_context->context(), v8::MicrotasksScope::kRunMicrotasks); ProtocolPromiseHandler::add(session, m_context->context(), value.ToLocalChecked(), m_context->contextId(), diff --git a/src/inspector/v8-console.cc b/src/inspector/v8-console.cc index 306ca9eee9..719aa69fc9 100644 --- a/src/inspector/v8-console.cc +++ b/src/inspector/v8-console.cc @@ -824,7 +824,7 @@ void V8Console::installAsyncStackTaggingAPI(v8::Local context, v8::Isolate* isolate = context->GetIsolate(); v8::Local data = v8::External::New(isolate, this); - v8::MicrotasksScope microtasksScope(isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); createBoundFunctionProperty(context, console, data, "createTask", @@ -834,7 +834,7 @@ void V8Console::installAsyncStackTaggingAPI(v8::Local context, v8::Local V8Console::createCommandLineAPI( v8::Local context, int sessionId) { v8::Isolate* isolate = context->GetIsolate(); - v8::MicrotasksScope microtasksScope(isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local commandLineAPI = v8::Object::New(isolate); @@ -933,7 +933,7 @@ void V8Console::CommandLineAPIScope::accessorGetterCallback( if (isCommandLineAPIGetter( toProtocolStringWithTypeCheck(info.GetIsolate(), name))) { DCHECK(value->IsFunction()); - v8::MicrotasksScope microtasks(info.GetIsolate(), + v8::MicrotasksScope microtasks(context, v8::MicrotasksScope::kDoNotRunMicrotasks); if (value.As() ->Call(context, commandLineAPI, 0, nullptr) @@ -964,7 +964,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope( m_commandLineAPI(commandLineAPI), m_global(global), m_installedMethods(v8::Set::New(context->GetIsolate())) { - v8::MicrotasksScope microtasksScope(context->GetIsolate(), + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local names; if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return; @@ -996,7 +996,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope( V8Console::CommandLineAPIScope::~CommandLineAPIScope() { auto isolate = m_context->GetIsolate(); if (isolate->IsExecutionTerminating()) return; - v8::MicrotasksScope microtasksScope(isolate, + v8::MicrotasksScope microtasksScope(m_context, v8::MicrotasksScope::kDoNotRunMicrotasks); *static_cast( m_thisReference->GetBackingStore()->Data()) = nullptr; diff --git a/src/inspector/v8-debugger-agent-impl.cc b/src/inspector/v8-debugger-agent-impl.cc index 45cc028e66..7155691286 100644 --- a/src/inspector/v8-debugger-agent-impl.cc +++ b/src/inspector/v8-debugger-agent-impl.cc @@ -793,7 +793,7 @@ Response V8DebuggerAgentImpl::getPossibleBreakpoints( return Response::ServerError("Cannot retrive script context"); } v8::Context::Scope contextScope(inspected->context()); - v8::MicrotasksScope microtasks(m_isolate, + v8::MicrotasksScope microtasks(inspected->context(), v8::MicrotasksScope::kDoNotRunMicrotasks); v8::TryCatch tryCatch(m_isolate); it->second->getPossibleBreakpoints( diff --git a/src/inspector/v8-debugger.cc b/src/inspector/v8-debugger.cc index 00fc67465a..cef1b9ffd0 100644 --- a/src/inspector/v8-debugger.cc +++ b/src/inspector/v8-debugger.cc @@ -818,7 +818,7 @@ v8::Local V8Debugger::queryObjects(v8::Local context, MatchPrototypePredicate predicate(m_inspector, context, prototype); v8::debug::QueryObjects(context, &predicate, &v8_objects); - v8::MicrotasksScope microtasksScope(isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local resultArray = v8::Array::New( m_inspector->isolate(), static_cast(v8_objects.size())); diff --git a/src/inspector/v8-inspector-impl.cc b/src/inspector/v8-inspector-impl.cc index e437868f31..27bdd3e812 100644 --- a/src/inspector/v8-inspector-impl.cc +++ b/src/inspector/v8-inspector-impl.cc @@ -97,7 +97,7 @@ v8::MaybeLocal V8InspectorImpl::compileAndRunInternalScript( if (!v8::debug::CompileInspectorScript(m_isolate, source) .ToLocal(&unboundScript)) return v8::MaybeLocal(); - v8::MicrotasksScope microtasksScope(m_isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Context::Scope contextScope(context); v8::Isolate::SafeForTerminationScope allowTermination(m_isolate); @@ -533,7 +533,7 @@ V8InspectorImpl::getAssociatedExceptionDataForProtocol( if (!exceptionMetaDataContext().ToLocal(&context)) return nullptr; v8::TryCatch tryCatch(m_isolate); - v8::MicrotasksScope microtasksScope(m_isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Context::Scope contextScope(context); std::unique_ptr jsonObject; diff --git a/src/inspector/v8-regex.cc b/src/inspector/v8-regex.cc index fd44a6a258..dcd120fded 100644 --- a/src/inspector/v8-regex.cc +++ b/src/inspector/v8-regex.cc @@ -63,7 +63,7 @@ int V8Regex::match(const String16& string, int startFrom, return -1; } v8::Context::Scope contextScope(context); - v8::MicrotasksScope microtasks(isolate, + v8::MicrotasksScope microtasks(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::TryCatch tryCatch(isolate); diff --git a/src/inspector/v8-runtime-agent-impl.cc b/src/inspector/v8-runtime-agent-impl.cc index 860b6f8a1a..1a3ee11ba1 100644 --- a/src/inspector/v8-runtime-agent-impl.cc +++ b/src/inspector/v8-runtime-agent-impl.cc @@ -152,7 +152,7 @@ void innerCallFunctionOn( if (inspector ->compileScript(scope.context(), "(" + expression + ")", String16()) .ToLocal(&functionScript)) { - v8::MicrotasksScope microtasksScope(inspector->isolate(), + v8::MicrotasksScope microtasksScope(scope.context(), v8::MicrotasksScope::kRunMicrotasks); maybeFunctionValue = functionScript->Run(scope.context()); } @@ -181,7 +181,7 @@ void innerCallFunctionOn( v8::MaybeLocal maybeResultValue; { - v8::MicrotasksScope microtasksScope(inspector->isolate(), + v8::MicrotasksScope microtasksScope(scope.context(), v8::MicrotasksScope::kRunMicrotasks); maybeResultValue = v8::debug::CallFunctionOn( scope.context(), functionValue.As(), recv, argc, @@ -299,7 +299,7 @@ void V8RuntimeAgentImpl::evaluate( return; } } - v8::MicrotasksScope microtasksScope(m_inspector->isolate(), + v8::MicrotasksScope microtasksScope(scope.context(), v8::MicrotasksScope::kRunMicrotasks); v8::debug::EvaluateGlobalMode mode = v8::debug::EvaluateGlobalMode::kDefault; @@ -447,7 +447,7 @@ Response V8RuntimeAgentImpl::getProperties( if (!response.IsSuccess()) return response; scope.ignoreExceptionsAndMuteConsole(); - v8::MicrotasksScope microtasks_scope(m_inspector->isolate(), + v8::MicrotasksScope microtasks_scope(scope.context(), v8::MicrotasksScope::kRunMicrotasks); if (!scope.object()->IsObject()) return Response::ServerError("Value with given id is not an object"); @@ -620,7 +620,7 @@ void V8RuntimeAgentImpl::runScript( v8::MaybeLocal maybeResultValue; { - v8::MicrotasksScope microtasksScope(m_inspector->isolate(), + v8::MicrotasksScope microtasksScope(scope.context(), v8::MicrotasksScope::kRunMicrotasks); maybeResultValue = script->Run(scope.context()); } @@ -799,7 +799,7 @@ void V8RuntimeAgentImpl::addBinding(InspectedContext* context, v8::Local global = localContext->Global(); v8::Local v8Name = toV8String(m_inspector->isolate(), name); v8::Local functionValue; - v8::MicrotasksScope microtasks(m_inspector->isolate(), + v8::MicrotasksScope microtasks(localContext, v8::MicrotasksScope::kDoNotRunMicrotasks); if (v8::Function::New(localContext, bindingCallback, v8Name) .ToLocal(&functionValue)) { diff --git a/src/inspector/value-mirror.cc b/src/inspector/value-mirror.cc index 59369cac65..ec565b144f 100644 --- a/src/inspector/value-mirror.cc +++ b/src/inspector/value-mirror.cc @@ -819,7 +819,7 @@ bool isArrayLike(v8::Local context, v8::Local value, if (!value->IsObject()) return false; v8::Isolate* isolate = context->GetIsolate(); v8::TryCatch tryCatch(isolate); - v8::MicrotasksScope microtasksScope(isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local object = value.As(); v8::Local spliceValue; @@ -1362,7 +1362,7 @@ bool ValueMirror::getProperties(v8::Local context, v8::TryCatch tryCatch(isolate); v8::Local set = v8::Set::New(isolate); - v8::MicrotasksScope microtasksScope(isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); V8InternalValueType internalType = v8InternalValueTypeFrom(context, object); if (internalType == V8InternalValueType::kScope) { @@ -1510,7 +1510,7 @@ void ValueMirror::getInternalProperties( v8::Local context, v8::Local object, std::vector* mirrors) { v8::Isolate* isolate = context->GetIsolate(); - v8::MicrotasksScope microtasksScope(isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::TryCatch tryCatch(isolate); if (object->IsFunction()) { @@ -1565,7 +1565,7 @@ std::vector ValueMirror::getPrivateProperties( bool accessorPropertiesOnly) { std::vector mirrors; v8::Isolate* isolate = context->GetIsolate(); - v8::MicrotasksScope microtasksScope(isolate, + v8::MicrotasksScope microtasksScope(context, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::TryCatch tryCatch(isolate); v8::Local privateProperties; diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 5e13f3b4ba..254ac731fc 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -19790,7 +19790,7 @@ TEST(CallCompletedCallbackTwoExceptions) { static void MicrotaskOne(const v8::FunctionCallbackInfo& info) { CHECK(v8::MicrotasksScope::IsRunningMicrotasks(info.GetIsolate())); v8::HandleScope scope(info.GetIsolate()); - v8::MicrotasksScope microtasks(info.GetIsolate(), + v8::MicrotasksScope microtasks(info.GetIsolate()->GetCurrentContext(), v8::MicrotasksScope::kDoNotRunMicrotasks); CompileRun("ext1Calls++;"); } @@ -19799,7 +19799,7 @@ static void MicrotaskOne(const v8::FunctionCallbackInfo& info) { static void MicrotaskTwo(const v8::FunctionCallbackInfo& info) { CHECK(v8::MicrotasksScope::IsRunningMicrotasks(info.GetIsolate())); v8::HandleScope scope(info.GetIsolate()); - v8::MicrotasksScope microtasks(info.GetIsolate(), + v8::MicrotasksScope microtasks(info.GetIsolate()->GetCurrentContext(), v8::MicrotasksScope::kDoNotRunMicrotasks); CompileRun("ext2Calls++;"); } @@ -20101,31 +20101,31 @@ TEST(ScopedMicrotasks) { v8::HandleScope handles(env->GetIsolate()); env->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); env->GetIsolate()->EnqueueMicrotask( Function::New(env.local(), MicrotaskOne).ToLocalChecked()); CompileRun("var ext1Calls = 0;"); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); ExpectInt32("ext1Calls", 1); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); env->GetIsolate()->EnqueueMicrotask( Function::New(env.local(), MicrotaskOne).ToLocalChecked()); CompileRun("throw new Error()"); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); ExpectInt32("ext1Calls", 2); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); env->GetIsolate()->EnqueueMicrotask( Function::New(env.local(), MicrotaskOne).ToLocalChecked()); @@ -20133,18 +20133,18 @@ TEST(ScopedMicrotasks) { CompileRun("throw new Error()"); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); ExpectInt32("ext1Calls", 3); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); env->GetIsolate()->EnqueueMicrotask( Function::New(env.local(), MicrotaskOne).ToLocalChecked()); env->GetIsolate()->TerminateExecution(); { - v8::MicrotasksScope scope2(env->GetIsolate(), + v8::MicrotasksScope scope2(env.local(), v8::MicrotasksScope::kRunMicrotasks); env->GetIsolate()->EnqueueMicrotask( Function::New(env.local(), MicrotaskOne).ToLocalChecked()); @@ -20152,21 +20152,21 @@ TEST(ScopedMicrotasks) { } env->GetIsolate()->CancelTerminateExecution(); { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); ExpectInt32("ext1Calls", 3); env->GetIsolate()->EnqueueMicrotask( Function::New(env.local(), MicrotaskOne).ToLocalChecked()); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); ExpectInt32("ext1Calls", 4); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); env->GetIsolate()->EnqueueMicrotask( Function::New(env.local(), MicrotaskOne).ToLocalChecked()); @@ -20177,13 +20177,13 @@ TEST(ScopedMicrotasks) { CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); { - v8::MicrotasksScope scope2(env->GetIsolate(), + v8::MicrotasksScope scope2(env.local(), v8::MicrotasksScope::kRunMicrotasks); CompileRun("1+1;"); CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); { - v8::MicrotasksScope scope3(env->GetIsolate(), + v8::MicrotasksScope scope3(env.local(), v8::MicrotasksScope::kRunMicrotasks); CompileRun("1+1;"); CHECK_EQ(0, @@ -20201,20 +20201,20 @@ TEST(ScopedMicrotasks) { } { - v8::MicrotasksScope scope(env->GetIsolate(), + v8::MicrotasksScope scope(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); CompileRun("1+1;"); CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); { - v8::MicrotasksScope scope2(env->GetIsolate(), + v8::MicrotasksScope scope2(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); } CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); @@ -20222,7 +20222,7 @@ TEST(ScopedMicrotasks) { } { - v8::MicrotasksScope scope(env->GetIsolate(), + v8::MicrotasksScope scope(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); @@ -20233,17 +20233,17 @@ TEST(ScopedMicrotasks) { { v8::Isolate::SuppressMicrotaskExecutionScope scope1(env->GetIsolate()); { - v8::MicrotasksScope scope2(env->GetIsolate(), + v8::MicrotasksScope scope2(env.local(), v8::MicrotasksScope::kRunMicrotasks); } - v8::MicrotasksScope scope3(env->GetIsolate(), + v8::MicrotasksScope scope3(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); } { - v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope scope1(env.local(), v8::MicrotasksScope::kRunMicrotasks); v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate()); CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); @@ -20251,7 +20251,7 @@ TEST(ScopedMicrotasks) { } { - v8::MicrotasksScope scope(env->GetIsolate(), + v8::MicrotasksScope scope(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); @@ -20260,7 +20260,7 @@ TEST(ScopedMicrotasks) { v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate()); { - v8::MicrotasksScope scope(env->GetIsolate(), + v8::MicrotasksScope scope(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); @@ -20271,7 +20271,7 @@ TEST(ScopedMicrotasks) { v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate()); { - v8::MicrotasksScope scope(env->GetIsolate(), + v8::MicrotasksScope scope(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); @@ -20282,7 +20282,7 @@ TEST(ScopedMicrotasks) { { v8::Isolate::SuppressMicrotaskExecutionScope scope1(env->GetIsolate()); v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate()); - v8::MicrotasksScope scope2(env->GetIsolate(), + v8::MicrotasksScope scope2(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); @@ -20291,7 +20291,7 @@ TEST(ScopedMicrotasks) { v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate()); { - v8::MicrotasksScope scope(env->GetIsolate(), + v8::MicrotasksScope scope(env.local(), v8::MicrotasksScope::kDoNotRunMicrotasks); CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 254df02ebb..0efcda9db8 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -5339,7 +5339,7 @@ bool microtask_one_ran = false; static void MicrotaskOne(const v8::FunctionCallbackInfo& info) { CHECK(v8::MicrotasksScope::IsRunningMicrotasks(info.GetIsolate())); v8::HandleScope scope(info.GetIsolate()); - v8::MicrotasksScope microtasks(info.GetIsolate(), + v8::MicrotasksScope microtasks(info.GetIsolate()->GetCurrentContext(), v8::MicrotasksScope::kDoNotRunMicrotasks); ExpectInt32("1 + 1", 2); microtask_one_ran = true; diff --git a/test/inspector/frontend-channel.h b/test/inspector/frontend-channel.h index 30ec4353f6..2198a94c40 100644 --- a/test/inspector/frontend-channel.h +++ b/test/inspector/frontend-channel.h @@ -55,11 +55,11 @@ class FrontendChannelImpl : public v8_inspector::V8Inspector::Channel { private: void Run(InspectorIsolateData* data) override { - v8::MicrotasksScope microtasks_scope(data->isolate(), - v8::MicrotasksScope::kRunMicrotasks); v8::HandleScope handle_scope(data->isolate()); v8::Local context = data->GetDefaultContext(channel_->context_group_id_); + v8::MicrotasksScope microtasks_scope(context, + v8::MicrotasksScope::kRunMicrotasks); v8::Context::Scope context_scope(context); v8::Local message = ToV8String(data->isolate(), message_); v8::MaybeLocal result; diff --git a/test/inspector/isolate-data.cc b/test/inspector/isolate-data.cc index a3bb4854b5..d20b996e60 100644 --- a/test/inspector/isolate-data.cc +++ b/test/inspector/isolate-data.cc @@ -389,7 +389,7 @@ bool InspectorIsolateData::isInspectableHeapObject( v8::Local object) { v8::Local context = isolate()->GetCurrentContext(); v8::MicrotasksScope microtasks_scope( - isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); + context, v8::MicrotasksScope::kDoNotRunMicrotasks); return !object->HasPrivate(context, not_inspectable_private_.Get(isolate())) .FromMaybe(false); } diff --git a/test/inspector/tasks.cc b/test/inspector/tasks.cc index 13168f2839..9a01555b2f 100644 --- a/test/inspector/tasks.cc +++ b/test/inspector/tasks.cc @@ -15,10 +15,10 @@ namespace v8 { namespace internal { void ExecuteStringTask::Run(InspectorIsolateData* data) { - v8::MicrotasksScope microtasks_scope(data->isolate(), - v8::MicrotasksScope::kRunMicrotasks); v8::HandleScope handle_scope(data->isolate()); v8::Local context = data->GetDefaultContext(context_group_id_); + v8::MicrotasksScope microtasks_scope(context, + v8::MicrotasksScope::kRunMicrotasks); v8::Context::Scope context_scope(context); v8::ScriptOrigin origin(data->isolate(), ToV8String(data->isolate(), name_), line_offset_, column_offset_, diff --git a/test/inspector/tasks.h b/test/inspector/tasks.h index 33d7135a59..e178c93766 100644 --- a/test/inspector/tasks.h +++ b/test/inspector/tasks.h @@ -129,10 +129,10 @@ class SetTimeoutTask : public TaskRunner::Task { private: void Run(InspectorIsolateData* data) override { - v8::MicrotasksScope microtasks_scope(data->isolate(), - v8::MicrotasksScope::kRunMicrotasks); v8::HandleScope handle_scope(data->isolate()); v8::Local context = data->GetDefaultContext(context_group_id_); + v8::MicrotasksScope microtasks_scope(context, + v8::MicrotasksScope::kRunMicrotasks); v8::Context::Scope context_scope(context); v8::Local function = function_.Get(data->isolate());