Commit 177f51df authored by Georg Neis's avatar Georg Neis Committed by V8 LUCI CQ

Support concurrent access in TransitionsAccessor::SearchSpecial

Bug: v8:12128
Change-Id: Ie32a582da7b823f75462c0cea3fff68daf483df1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3114140Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76459}
parent 954c19c4
...@@ -180,14 +180,16 @@ Map TransitionArray::SearchAndGetTargetForTesting( ...@@ -180,14 +180,16 @@ Map TransitionArray::SearchAndGetTargetForTesting(
return SearchAndGetTarget(kind, name, attributes); return SearchAndGetTarget(kind, name, attributes);
} }
int TransitionArray::SearchSpecial(Symbol symbol, int* out_insertion_index) { int TransitionArray::SearchSpecial(Symbol symbol, bool concurrent_search,
return SearchName(symbol, out_insertion_index); int* out_insertion_index) {
return SearchName(symbol, concurrent_search, out_insertion_index);
} }
int TransitionArray::SearchName(Name name, int* out_insertion_index) { int TransitionArray::SearchName(Name name, bool concurrent_search,
int* out_insertion_index) {
DCHECK(name.IsUniqueName()); DCHECK(name.IsUniqueName());
return internal::Search<ALL_ENTRIES>(this, name, number_of_entries(), return internal::Search<ALL_ENTRIES>(this, name, number_of_entries(),
out_insertion_index); out_insertion_index, concurrent_search);
} }
TransitionsAccessor::TransitionsAccessor(Isolate* isolate, Map map, TransitionsAccessor::TransitionsAccessor(Isolate* isolate, Map map,
......
...@@ -95,7 +95,8 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target, ...@@ -95,7 +95,8 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
int insertion_index; int insertion_index;
int index; int index;
if (flag == SPECIAL_TRANSITION) { if (flag == SPECIAL_TRANSITION) {
index = result->SearchSpecial(Symbol::cast(*name), &insertion_index); index =
result->SearchSpecial(Symbol::cast(*name), false, &insertion_index);
} else { } else {
PropertyDetails details = GetTargetDetails(*name, *target); PropertyDetails details = GetTargetDetails(*name, *target);
index = result->Search(details.kind(), *name, details.attributes(), index = result->Search(details.kind(), *name, details.attributes(),
...@@ -139,10 +140,11 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target, ...@@ -139,10 +140,11 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
TransitionArray array = transitions(); TransitionArray array = transitions();
number_of_transitions = array.number_of_transitions(); number_of_transitions = array.number_of_transitions();
int index = is_special_transition int index =
? array.SearchSpecial(Symbol::cast(*name), &insertion_index) is_special_transition
: array.Search(details.kind(), *name, details.attributes(), ? array.SearchSpecial(Symbol::cast(*name), false, &insertion_index)
&insertion_index); : array.Search(details.kind(), *name, details.attributes(),
&insertion_index);
// If an existing entry was found, overwrite it and return. // If an existing entry was found, overwrite it and return.
if (index != kNotFound) { if (index != kNotFound) {
base::SharedMutexGuard<base::kExclusive> shared_mutex_guard( base::SharedMutexGuard<base::kExclusive> shared_mutex_guard(
...@@ -186,10 +188,11 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target, ...@@ -186,10 +188,11 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
if (array.number_of_transitions() != number_of_transitions) { if (array.number_of_transitions() != number_of_transitions) {
DCHECK_LT(array.number_of_transitions(), number_of_transitions); DCHECK_LT(array.number_of_transitions(), number_of_transitions);
int index = is_special_transition int index =
? array.SearchSpecial(Symbol::cast(*name), &insertion_index) is_special_transition
: array.Search(details.kind(), *name, details.attributes(), ? array.SearchSpecial(Symbol::cast(*name), false, &insertion_index)
&insertion_index); : array.Search(details.kind(), *name, details.attributes(),
&insertion_index);
CHECK_EQ(index, kNotFound); CHECK_EQ(index, kNotFound);
USE(index); USE(index);
DCHECK_GE(insertion_index, 0); DCHECK_GE(insertion_index, 0);
...@@ -241,7 +244,9 @@ Map TransitionsAccessor::SearchTransition(Name name, PropertyKind kind, ...@@ -241,7 +244,9 @@ Map TransitionsAccessor::SearchTransition(Name name, PropertyKind kind,
Map TransitionsAccessor::SearchSpecial(Symbol name) { Map TransitionsAccessor::SearchSpecial(Symbol name) {
if (encoding() != kFullTransitionArray) return Map(); if (encoding() != kFullTransitionArray) return Map();
int transition = transitions().SearchSpecial(name); base::SharedMutexGuardIf<base::kShared> scope(
isolate_->full_transition_array_access(), concurrent_access_);
int transition = transitions().SearchSpecial(name, concurrent_access_);
if (transition == kNotFound) return Map(); if (transition == kNotFound) return Map();
return transitions().GetTarget(transition); return transitions().GetTarget(transition);
} }
...@@ -646,14 +651,14 @@ Map TransitionArray::SearchDetailsAndGetTarget(int transition, ...@@ -646,14 +651,14 @@ Map TransitionArray::SearchDetailsAndGetTarget(int transition,
int TransitionArray::Search(PropertyKind kind, Name name, int TransitionArray::Search(PropertyKind kind, Name name,
PropertyAttributes attributes, PropertyAttributes attributes,
int* out_insertion_index) { int* out_insertion_index) {
int transition = SearchName(name, out_insertion_index); int transition = SearchName(name, false, out_insertion_index);
if (transition == kNotFound) return kNotFound; if (transition == kNotFound) return kNotFound;
return SearchDetails(transition, kind, attributes, out_insertion_index); return SearchDetails(transition, kind, attributes, out_insertion_index);
} }
Map TransitionArray::SearchAndGetTarget(PropertyKind kind, Name name, Map TransitionArray::SearchAndGetTarget(PropertyKind kind, Name name,
PropertyAttributes attributes) { PropertyAttributes attributes) {
int transition = SearchName(name, nullptr); int transition = SearchName(name);
if (transition == kNotFound) { if (transition == kNotFound) {
return Map(); return Map();
} }
...@@ -662,7 +667,7 @@ Map TransitionArray::SearchAndGetTarget(PropertyKind kind, Name name, ...@@ -662,7 +667,7 @@ Map TransitionArray::SearchAndGetTarget(PropertyKind kind, Name name,
void TransitionArray::ForEachTransitionTo( void TransitionArray::ForEachTransitionTo(
Name name, const ForEachTransitionCallback& callback) { Name name, const ForEachTransitionCallback& callback) {
int transition = SearchName(name, nullptr); int transition = SearchName(name);
if (transition == kNotFound) return; if (transition == kNotFound) return;
int nof_transitions = number_of_transitions(); int nof_transitions = number_of_transitions();
......
...@@ -335,9 +335,11 @@ class TransitionArray : public WeakFixedArray { ...@@ -335,9 +335,11 @@ class TransitionArray : public WeakFixedArray {
// Search a non-property transition (like elements kind, observe or frozen // Search a non-property transition (like elements kind, observe or frozen
// transitions). // transitions).
inline int SearchSpecial(Symbol symbol, int* out_insertion_index = nullptr); inline int SearchSpecial(Symbol symbol, bool concurrent_search = false,
int* out_insertion_index = nullptr);
// Search a first transition for a given property name. // Search a first transition for a given property name.
inline int SearchName(Name name, int* out_insertion_index = nullptr); inline int SearchName(Name name, bool concurrent_search = false,
int* out_insertion_index = nullptr);
int SearchDetails(int transition, PropertyKind kind, int SearchDetails(int transition, PropertyKind kind,
PropertyAttributes attributes, int* out_insertion_index); PropertyAttributes attributes, int* out_insertion_index);
Map SearchDetailsAndGetTarget(int transition, PropertyKind kind, Map SearchDetailsAndGetTarget(int transition, PropertyKind kind,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment