[cleanup] Improve the concurrent SharedMutexes comments and naming

Rename string_access to internalized_string_access and
transition_array_access to full_transition_array_access.

Bug: v8:7790
Change-Id: I225f90d4c0d6ddac1f15796848428bc962a2420f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2718145
Reviewed-by: Georg Neis <neis@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73044}
This commit is contained in:
Santiago Aboy Solanes 2021-02-24 16:21:20 +00:00 committed by Commit Bot
parent 2aad1b6429
commit 0b3f82b5c7
5 changed files with 26 additions and 18 deletions

View File

@ -631,20 +631,25 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
// Mutex for serializing access to break control structures.
base::RecursiveMutex* break_access() { return &break_access_; }
// Shared mutex for allowing concurrent read/writes to FeedbackVectors.
// Shared mutex for allowing thread-safe concurrent reads of FeedbackVectors.
base::SharedMutex* feedback_vector_access() {
return &feedback_vector_access_;
}
// Shared mutex for allowing concurrent read/writes to Strings.
base::SharedMutex* string_access() { return &string_access_; }
// Shared mutex for allowing concurrent read/writes to TransitionArrays.
base::SharedMutex* transition_array_access() {
return &transition_array_access_;
// Shared mutex for allowing thread-safe concurrent reads of
// InternalizedStrings.
base::SharedMutex* internalized_string_access() {
return &internalized_string_access_;
}
// Shared mutex for allowing concurrent read/writes to SharedFunctionInfos.
// Shared mutex for allowing thread-safe concurrent reads of TransitionArrays
// of kind kFullTransitionArray.
base::SharedMutex* full_transition_array_access() {
return &full_transition_array_access_;
}
// Shared mutex for allowing thread-safe concurrent reads of
// SharedFunctionInfos.
base::SharedMutex* shared_function_info_access() {
return &shared_function_info_access_;
}
@ -1805,8 +1810,8 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
std::shared_ptr<Counters> async_counters_;
base::RecursiveMutex break_access_;
base::SharedMutex feedback_vector_access_;
base::SharedMutex string_access_;
base::SharedMutex transition_array_access_;
base::SharedMutex internalized_string_access_;
base::SharedMutex full_transition_array_access_;
base::SharedMutex shared_function_info_access_;
Logger* logger_ = nullptr;
StubCache* load_stub_cache_ = nullptr;

View File

@ -53,7 +53,9 @@ class V8_EXPORT_PRIVATE LocalIsolate final : private HiddenLocalFactory {
inline Object root(RootIndex index) const;
StringTable* string_table() const { return isolate_->string_table(); }
base::SharedMutex* string_access() { return isolate_->string_access(); }
base::SharedMutex* internalized_string_access() {
return isolate_->internalized_string_access();
}
v8::internal::LocalFactory* factory() {
// Upcast to the privately inherited base-class using c-style casts to avoid

View File

@ -38,14 +38,15 @@ class V8_NODISCARD SharedStringAccessGuardIfNeeded {
// from a background thread.
explicit SharedStringAccessGuardIfNeeded(LocalIsolate* local_isolate) {
if (IsNeeded(local_isolate)) {
mutex_guard.emplace(local_isolate->string_access());
mutex_guard.emplace(local_isolate->internalized_string_access());
}
}
// Slow version which gets the isolate from the String.
explicit SharedStringAccessGuardIfNeeded(String str) {
Isolate* isolate = GetIsolateIfNeeded(str);
if (isolate != nullptr) mutex_guard.emplace(isolate->string_access());
if (isolate != nullptr)
mutex_guard.emplace(isolate->internalized_string_access());
}
static SharedStringAccessGuardIfNeeded NotNeeded() {

View File

@ -171,7 +171,7 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
}
base::SharedMutexGuard<base::kExclusive> shared_mutex_guard(
isolate->string_access());
isolate->internalized_string_access());
// Morph the string to an external string by replacing the map and
// reinitializing the fields. This won't work if the space the existing
// string occupies is too small for a regular external string. Instead, we
@ -249,7 +249,7 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
}
base::SharedMutexGuard<base::kExclusive> shared_mutex_guard(
isolate->string_access());
isolate->internalized_string_access());
// Morph the string to an external string by replacing the map and
// reinitializing the fields. This won't work if the space the existing
// string occupies is too small for a regular external string. Instead, we

View File

@ -145,7 +145,7 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
// If an existing entry was found, overwrite it and return.
if (index != kNotFound) {
base::SharedMutexGuard<base::kExclusive> shared_mutex_guard(
isolate_->transition_array_access());
isolate_->full_transition_array_access());
array.SetRawTarget(index, HeapObjectReference::Weak(*target));
return;
}
@ -158,7 +158,7 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
// If there is enough capacity, insert new entry into the existing array.
if (new_nof <= array.Capacity()) {
base::SharedMutexGuard<base::kExclusive> shared_mutex_guard(
isolate_->transition_array_access());
isolate_->full_transition_array_access());
array.SetNumberOfTransitions(new_nof);
for (int i = number_of_transitions; i > insertion_index; --i) {
array.SetKey(i, array.GetKey(i - 1));
@ -231,7 +231,7 @@ Map TransitionsAccessor::SearchTransition(Name name, PropertyKind kind,
}
case kFullTransitionArray: {
base::SharedMutexGuardIf<base::kShared> scope(
isolate_->transition_array_access(), concurrent_access_);
isolate_->full_transition_array_access(), concurrent_access_);
return transitions().SearchAndGetTarget(kind, name, attributes);
}
}