-
Notifications
You must be signed in to change notification settings - Fork 16.2k
refactor: avoid deprecated v8::Context::GetIsolate()
calls (pt 1)
#47760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -1856,8 +1856,8 @@ void Initialize(v8::Local<v8::Object> exports, | |||
v8::Local<v8::Value> unused, | |||
v8::Local<v8::Context> context, | |||
void* priv) { | |||
v8::Isolate* isolate = context->GetIsolate(); | |||
gin_helper::Dictionary dict(isolate, exports); | |||
v8::Isolate* const isolate = v8::Isolate::GetCurrent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For browser layer usages it would be better to replace with JavascriptEnvironment::GetIsolate
@@ -125,16 +125,16 @@ void ElectronRendererClient::DidCreateScriptContext( | |||
render_frame->GetWebFrame()->GetDocumentLoader()->SetDefersLoading( | |||
blink::LoaderFreezeMode::kStrict); | |||
|
|||
v8::Isolate* const isolate = renderer_context->GetIsolate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not call v8::Isolate::GetCurrent()
here already ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deepak1556 see #24179 - we shouldn't be trying to use v8::Isolate::GetCurrent()
if we have other options imho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow, isn't getting isolate from context is being deprecated ? Whats' the alternative here, this is the renderer layer fwiw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://chromium-review.googlesource.com/c/chromium/src/+/6718066 v8::Isolate::GetCurrent
is what is being preferred for third_party/blink
irrespective of the source context.
@@ -49,7 +49,7 @@ WebWorkerObserver::~WebWorkerObserver() = default; | |||
void WebWorkerObserver::WorkerScriptReadyForEvaluation( | |||
v8::Local<v8::Context> worker_context) { | |||
v8::Context::Scope context_scope(worker_context); | |||
auto* isolate = worker_context->GetIsolate(); | |||
v8::Isolate* const isolate = worker_context->GetIsolate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Description of Change
Part 1 of a very short series to remove calls to
v8::Context::GetIsolate()
which is being deprecated.Even though the individual changes are pretty straightforward, the overall diff is pretty heavy due to the number of places where we are using that method. So I'm breaking into a couple of smaller PRs to make review easier.
This PR:
GetIsolate()
inNodeBindings::CreateEnvironment()
by adding av8::Isolate*
arg to that method.GetIsolate()
in the Node.js moduleInitialize()
methods by usingv8::Isolate::GetCurrent()
instead.Checklist
npm test
passesRelease Notes
Notes: none.