Commit 494388da authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[objects] Remove unnecessary loop in LookupKey

Change-Id: Iee3a65c6df143a41b45b610a10a19ec28ad5c268
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2565513Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71518}
parent 277f4dc2
...@@ -464,8 +464,6 @@ Handle<String> StringTable::LookupKey(LocalIsolate* isolate, ...@@ -464,8 +464,6 @@ Handle<String> StringTable::LookupKey(LocalIsolate* isolate,
// allocation if another write also did an allocation. This assumes that // allocation if another write also did an allocation. This assumes that
// writes are rarer than reads. // writes are rarer than reads.
Handle<String> new_string;
while (true) {
// Load the current string table data, in case another thread updates the // Load the current string table data, in case another thread updates the
// data while we're reading. // data while we're reading.
const Data* data = data_.load(std::memory_order_acquire); const Data* data = data_.load(std::memory_order_acquire);
...@@ -486,7 +484,7 @@ Handle<String> StringTable::LookupKey(LocalIsolate* isolate, ...@@ -486,7 +484,7 @@ Handle<String> StringTable::LookupKey(LocalIsolate* isolate,
// allocated value on insertion retries. If another thread concurrently // allocated value on insertion retries. If another thread concurrently
// allocates the same string, the insert will fail, the lookup above will // allocates the same string, the insert will fail, the lookup above will
// succeed, and this string will be discarded. // succeed, and this string will be discarded.
if (new_string.is_null()) new_string = key->AsHandle(isolate); Handle<String> new_string = key->AsHandle(isolate);
{ {
base::MutexGuard table_write_guard(&write_mutex_); base::MutexGuard table_write_guard(&write_mutex_);
...@@ -495,8 +493,7 @@ Handle<String> StringTable::LookupKey(LocalIsolate* isolate, ...@@ -495,8 +493,7 @@ Handle<String> StringTable::LookupKey(LocalIsolate* isolate,
// Check one last time if the key is present in the table, in case it was // Check one last time if the key is present in the table, in case it was
// added after the check. // added after the check.
InternalIndex entry = entry = data->FindEntryOrInsertionEntry(isolate, key, key->hash());
data->FindEntryOrInsertionEntry(isolate, key, key->hash());
Object element = data->Get(isolate, entry); Object element = data->Get(isolate, entry);
if (element == empty_element()) { if (element == empty_element()) {
...@@ -516,7 +513,6 @@ Handle<String> StringTable::LookupKey(LocalIsolate* isolate, ...@@ -516,7 +513,6 @@ Handle<String> StringTable::LookupKey(LocalIsolate* isolate,
return handle(String::cast(element), isolate); return handle(String::cast(element), isolate);
} }
} }
}
} }
template Handle<String> StringTable::LookupKey(Isolate* isolate, template Handle<String> StringTable::LookupKey(Isolate* isolate,
......
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