Skip to content

chore: remove locks #191

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions src/v8runtime/V8Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ void InspectorClient::SendRemoteMessage(
const v8_inspector::StringView &message) {
if (remoteConn_) {
v8::Isolate *isolate = GetIsolate();
v8::Locker locker(isolate);
v8::Isolate::Scope scopedIsolate(isolate);
v8::HandleScope scopedHandle(isolate);
v8::Context::Scope scopedContext(GetContext().Get(isolate));
Expand All @@ -249,25 +248,13 @@ void InspectorClient::AwakePauseLockWithMessage(const std::string &message) {

void InspectorClient::DispatchProxy(const std::string &message) {
std::string normalizedString = stripMetroCachePrevention(message);

auto messageObj = folly::parseJson(message);
auto method = messageObj["method"].asString();

// For `v8::CpuProfiler` or some other modules with thread local storage, we
// should dispatch messages in the js thread.
if (method == "Profiler.start" || method == "Profiler.stop") {
jsQueue_->runOnQueue([this, normalizedString]() {
v8::Isolate *isolate = GetIsolate();
v8::Locker locker(isolate);
v8::Isolate::Scope scopedIsolate(isolate);
v8::HandleScope scopedHandle(isolate);
v8::Context::Scope scopedContext(GetContext().Get(isolate));
session_->dispatchProtocolMessage(ToStringView(normalizedString));
});
return;
}

session_->dispatchProtocolMessage(ToStringView(normalizedString));
jsQueue_->runOnQueue([this, normalizedString]() {
v8::Isolate *isolate = GetIsolate();
v8::Isolate::Scope scopedIsolate(isolate);
v8::HandleScope scopedHandle(isolate);
v8::Context::Scope scopedContext(GetContext().Get(isolate));
session_->dispatchProtocolMessage(ToStringView(normalizedString));
});
}

void InspectorClient::DispatchProtocolMessage(const std::string &message) {
Expand All @@ -276,7 +263,6 @@ void InspectorClient::DispatchProtocolMessage(const std::string &message) {
return;
}
v8::Isolate *isolate = GetIsolate();
v8::Locker locker(isolate);
v8::Isolate::Scope scopedIsolate(isolate);
v8::HandleScope scopedHandle(isolate);
v8::Context::Scope scopedContext(GetContext().Get(isolate));
Expand All @@ -290,7 +276,6 @@ void InspectorClient::DispatchProtocolMessages(
return;
}
v8::Isolate *isolate = GetIsolate();
v8::Locker locker(isolate);
v8::Isolate::Scope scopedIsolate(isolate);
v8::HandleScope scopedHandle(isolate);
v8::Context::Scope scopedContext(GetContext().Get(isolate));
Expand Down
1 change: 0 additions & 1 deletion src/v8runtime/V8PointerValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ V8PointerValue *V8PointerValue::createFromUtf8(

void V8PointerValue::invalidate() {
{
v8::Locker locker(isolate_);
v8::Isolate::Scope scopedIsolate(isolate_);
value_.Reset();
}
Expand Down
Loading