Skip to content

Commit

Permalink
Don't use relaxed memory order when accessing class enum values
Browse files Browse the repository at this point in the history
Reviewed By: jtwarren, jano

Differential Revision: D57516812

fbshipit-source-id: 04cbb496fea1c314e4fd1b187db102348f96261e
  • Loading branch information
ottoni authored and facebook-github-bot committed May 18, 2024
1 parent 987d4b9 commit 0bd9816
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hphp/runtime/vm/class-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ inline MaybeDataType Class::enumBaseTy() const {
}

inline EnumValues* Class::getEnumValues() const {
return m_extra->m_enumValues.load(std::memory_order_relaxed);
return m_extra->m_enumValues.load(std::memory_order_acquire);
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions hphp/runtime/vm/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ EnumValues* Class::setEnumValues(EnumValues* values) {
auto extra = m_extra.ensureAllocated();
EnumValues* expected = nullptr;
if (!extra->m_enumValues.compare_exchange_strong(
expected, values, std::memory_order_relaxed)) {
expected, values, std::memory_order_acq_rel)) {
// Already set by someone else, use theirs.
delete values;
return expected;
Expand All @@ -440,7 +440,7 @@ EnumValues* Class::setEnumValues(EnumValues* values) {
}

Class::ExtraData::~ExtraData() {
delete m_enumValues.load(std::memory_order_relaxed);
delete m_enumValues.load(std::memory_order_acquire);
if (m_lsbMemoExtra.m_handles) {
for (auto const& kv : m_lsbMemoExtra.m_symbols) {
rds::unbind(kv.first, kv.second);
Expand Down

0 comments on commit 0bd9816

Please sign in to comment.