Skip to content

Commit

Permalink
remove locks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudo committed Jul 11, 2023
1 parent b5ce9d8 commit 8f1eac1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 84 deletions.
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

0 comments on commit 8f1eac1

Please sign in to comment.