Commit 9c72b62a authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[offthread] Use acq/rel for string table read/write

When creating and inserting strings into the string table, we have to
make sure that the writes to the string's fields (including its
characters) are not reordered to after the write of the string into the
table itself.

Thanks TSAN!

Bug: chromium:1011762
Change-Id: Ib8a22e3980f6b5c57561ca23549c1462c4c017c8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2404767
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69838}
parent 17d4868c
...@@ -164,11 +164,21 @@ Object OffHeapCompressedObjectSlot::Relaxed_Load(const Isolate* isolate) const { ...@@ -164,11 +164,21 @@ Object OffHeapCompressedObjectSlot::Relaxed_Load(const Isolate* isolate) const {
return Object(DecompressTaggedAny(isolate, value)); return Object(DecompressTaggedAny(isolate, value));
} }
Object OffHeapCompressedObjectSlot::Acquire_Load(const Isolate* isolate) const {
AtomicTagged_t value = AsAtomicTagged::Acquire_Load(location());
return Object(DecompressTaggedAny(isolate, value));
}
void OffHeapCompressedObjectSlot::Relaxed_Store(Object value) const { void OffHeapCompressedObjectSlot::Relaxed_Store(Object value) const {
Tagged_t ptr = CompressTagged(value.ptr()); Tagged_t ptr = CompressTagged(value.ptr());
AsAtomicTagged::Relaxed_Store(location(), ptr); AsAtomicTagged::Relaxed_Store(location(), ptr);
} }
void OffHeapCompressedObjectSlot::Release_Store(Object value) const {
Tagged_t ptr = CompressTagged(value.ptr());
AsAtomicTagged::Release_Store(location(), ptr);
}
void OffHeapCompressedObjectSlot::Release_CompareAndSwap(Object old, void OffHeapCompressedObjectSlot::Release_CompareAndSwap(Object old,
Object target) const { Object target) const {
Tagged_t old_ptr = CompressTagged(old.ptr()); Tagged_t old_ptr = CompressTagged(old.ptr());
......
...@@ -135,7 +135,9 @@ class OffHeapCompressedObjectSlot ...@@ -135,7 +135,9 @@ class OffHeapCompressedObjectSlot
inline void store(Object value) const; inline void store(Object value) const;
inline Object Relaxed_Load(const Isolate* isolate) const; inline Object Relaxed_Load(const Isolate* isolate) const;
inline Object Acquire_Load(const Isolate* isolate) const;
inline void Relaxed_Store(Object value) const; inline void Relaxed_Store(Object value) const;
inline void Release_Store(Object value) const;
inline void Release_CompareAndSwap(Object old, Object target) const; inline void Release_CompareAndSwap(Object old, Object target) const;
}; };
......
...@@ -39,6 +39,10 @@ Object FullObjectSlot::Acquire_Load() const { ...@@ -39,6 +39,10 @@ Object FullObjectSlot::Acquire_Load() const {
return Object(base::AsAtomicPointer::Acquire_Load(location())); return Object(base::AsAtomicPointer::Acquire_Load(location()));
} }
Object FullObjectSlot::Acquire_Load(const Isolate* isolate) const {
return Acquire_Load();
}
Object FullObjectSlot::Relaxed_Load() const { Object FullObjectSlot::Relaxed_Load() const {
return Object(base::AsAtomicPointer::Relaxed_Load(location())); return Object(base::AsAtomicPointer::Relaxed_Load(location()));
} }
......
...@@ -114,6 +114,7 @@ class FullObjectSlot : public SlotBase<FullObjectSlot, Address> { ...@@ -114,6 +114,7 @@ class FullObjectSlot : public SlotBase<FullObjectSlot, Address> {
inline void store(Object value) const; inline void store(Object value) const;
inline Object Acquire_Load() const; inline Object Acquire_Load() const;
inline Object Acquire_Load(const Isolate* isolate) const;
inline Object Relaxed_Load() const; inline Object Relaxed_Load() const;
inline Object Relaxed_Load(const Isolate* isolate) const; inline Object Relaxed_Load(const Isolate* isolate) const;
inline void Relaxed_Store(Object value) const; inline void Relaxed_Store(Object value) const;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "src/objects/string-table.h" #include "src/objects/string-table.h"
#include "src/base/atomicops.h"
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/common/assert-scope.h" #include "src/common/assert-scope.h"
#include "src/common/globals.h" #include "src/common/globals.h"
...@@ -95,11 +96,11 @@ class StringTable::Data { ...@@ -95,11 +96,11 @@ class StringTable::Data {
} }
Object Get(const Isolate* isolate, InternalIndex index) const { Object Get(const Isolate* isolate, InternalIndex index) const {
return slot(index).Relaxed_Load(isolate); return slot(index).Acquire_Load(isolate);
} }
void Set(InternalIndex index, String entry) { void Set(InternalIndex index, String entry) {
slot(index).Relaxed_Store(entry); slot(index).Release_Store(entry);
} }
void ElementAdded() { void ElementAdded() {
......
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