diff --git a/runtime/ecma_profiling.h b/runtime/ecma_profiling.h index ce07cf5aea29834f65031f98b3cbb87f8179f671..714900a1517a12d89a8a50a117cf076c78bcf633 100644 --- a/runtime/ecma_profiling.h +++ b/runtime/ecma_profiling.h @@ -384,7 +384,9 @@ public: static void Update(Base::ValueType *data, JSTaggedValue value) { - *data |= OperandType::Encode(GetTypeOfFromValue(value)); + // Atomic with release order reason: profile data may be updated while the compiler thread loads it + reinterpret_cast *>(data)->store( + *data | OperandType::Encode(GetTypeOfFromValue(value)), std::memory_order_release); } protected: diff --git a/runtime/js_hclass.h b/runtime/js_hclass.h index 016c1a06495b497567e6a1cb4f4592f68c377b9d..bb13cff9a7a6e2fa272fccecf6cb9bcdeb6123f5 100644 --- a/runtime/js_hclass.h +++ b/runtime/js_hclass.h @@ -302,48 +302,46 @@ public: inline void SetObjectType(JSType type) { - uint32_t bits = GetBitField(); - uint32_t new_val = ObjectTypeBits::Update(bits, type); - SetBitField(new_val); + UpdateBitField(type); } - inline void SetConstructor(bool flag) const + inline void SetConstructor(bool flag) { - ConstructorBit::Set(flag, GetBitFieldAddr()); + UpdateBitField(flag); } - inline void SetExtensible(bool flag) const + inline void SetExtensible(bool flag) { - ExtensibleBit::Set(flag, GetBitFieldAddr()); + UpdateBitField(flag); } - inline void SetIsPrototype(bool flag) const + inline void SetIsPrototype(bool flag) { - IsPrototypeBit::Set(flag, GetBitFieldAddr()); + UpdateBitField(flag); } - inline void SetIsLiteral(bool flag) const + inline void SetIsLiteral(bool flag) { - IsLiteralBit::Set(flag, GetBitFieldAddr()); + UpdateBitField(flag); } - inline void SetClassConstructor(bool flag) const + inline void SetClassConstructor(bool flag) { - ClassConstructorBit::Set(flag, GetBitFieldAddr()); + UpdateBitField(flag); } - inline void SetClassPrototype(bool flag) const + inline void SetClassPrototype(bool flag) { - ClassPrototypeBit::Set(flag, GetBitFieldAddr()); + UpdateBitField(flag); } - inline void SetIsDictionaryMode(bool flag) const + inline void SetIsDictionaryMode(bool flag) { - IsDictionaryBit::Set(flag, GetBitFieldAddr()); + UpdateBitField(flag); } inline void SetWeakContainer(bool flag) { - WeakContainerBit::Set(flag, GetBitFieldAddr()); + UpdateBitField(flag); } inline bool IsJSObject() const @@ -941,9 +939,7 @@ public: inline void SetElementRepresentation(Representation representation) { - uint32_t bits = GetBitField(); - uint32_t new_val = ElementRepresentationBits::Update(bits, representation); - SetBitField(new_val); + UpdateBitField(representation); } inline Representation GetElementRepresentation() const @@ -960,8 +956,7 @@ public: inline void SetIsDictionaryElement(bool value) { - JSTaggedType new_val = DictionaryElementBits::Update(GetBitField(), value); - SetBitField(new_val); + UpdateBitField(value); } inline bool IsDictionaryElement() const { @@ -969,8 +964,7 @@ public: } inline void SetIsStableElements(bool value) { - JSTaggedType new_val = IsStableElementsBit::Update(GetBitField(), value); - SetBitField(new_val); + UpdateBitField(value); } inline bool IsStableElements() const { @@ -990,8 +984,7 @@ public: } inline void SetHasConstructor(bool value) { - TaggedType new_val = HasConstructorBits::Update(GetBitField(), value); - SetBitField(new_val); + UpdateBitField(value); } inline bool HasConstructor() const { @@ -1137,9 +1130,12 @@ private: void Copy(const JSThread *thread, const JSHClass *jshclass); - uint32_t *GetBitFieldAddr() const + template + inline void UpdateBitField(T value) { - return reinterpret_cast(ToUintPtr(this) + BIT_FIELD_OFFSET); + auto bits = GetBitField(); + auto new_val = Field::Update(bits, value); + SetBitField(new_val); } HClass hclass_;