Commit 1c2141ae authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[runtime] Read and write layout descriptor words with atomics

This fixes benign data races reported by TSAN when a shared layout
descriptor is updated at the end.

Change-Id: I76662cb5fc2b8ab1728e3d1bf42a55a107442eed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1709422Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62863}
parent b9d3651e
......@@ -560,6 +560,16 @@ void ByteArray::set_uint32(int index, uint32_t value) {
WriteField<uint32_t>(kHeaderSize + index * kUInt32Size, value);
}
uint32_t ByteArray::get_uint32_relaxed(int index) const {
DCHECK(index >= 0 && index < this->length() / kUInt32Size);
return RELAXED_READ_UINT32_FIELD(*this, kHeaderSize + index * kUInt32Size);
}
void ByteArray::set_uint32_relaxed(int index, uint32_t value) {
DCHECK(index >= 0 && index < this->length() / kUInt32Size);
RELAXED_WRITE_UINT32_FIELD(*this, kHeaderSize + index * kUInt32Size, value);
}
void ByteArray::clear_padding() {
int data_size = length() + kHeaderSize;
memset(reinterpret_cast<void*>(address() + data_size), 0, Size() - data_size);
......
......@@ -488,6 +488,9 @@ class ByteArray : public FixedArrayBase {
inline uint32_t get_uint32(int index) const;
inline void set_uint32(int index, uint32_t value);
inline uint32_t get_uint32_relaxed(int index) const;
inline void set_uint32_relaxed(int index, uint32_t value);
// Clear uninitialized padding space. This ensures that the snapshot content
// is deterministic.
inline void clear_padding();
......
......@@ -209,11 +209,11 @@ int LayoutDescriptor::number_of_layout_words() {
}
uint32_t LayoutDescriptor::get_layout_word(int index) const {
return get_uint32(index);
return get_uint32_relaxed(index);
}
void LayoutDescriptor::set_layout_word(int index, uint32_t value) {
set_uint32(index, value);
set_uint32_relaxed(index, value);
}
// LayoutDescriptorHelper is a helper class for querying whether inobject
......
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