diff --git a/src/objects/contexts-inl.h b/src/objects/contexts-inl.h index fcecb96d3e..f2164d7d3b 100644 --- a/src/objects/contexts-inl.h +++ b/src/objects/contexts-inl.h @@ -31,11 +31,11 @@ OBJECT_CONSTRUCTORS_IMPL(ScriptContextTable, FixedArray) CAST_ACCESSOR(ScriptContextTable) int ScriptContextTable::synchronized_used() const { - return Smi::ToInt(synchronized_get(kUsedSlotIndex)); + return Smi::ToInt(get(kUsedSlotIndex, kAcquireLoad)); } void ScriptContextTable::synchronized_set_used(int used) { - synchronized_set(kUsedSlotIndex, Smi::FromInt(used)); + set(kUsedSlotIndex, Smi::FromInt(used), kReleaseStore); } // static diff --git a/src/objects/fixed-array-inl.h b/src/objects/fixed-array-inl.h index e4b4609119..a91f89784f 100644 --- a/src/objects/fixed-array-inl.h +++ b/src/objects/fixed-array-inl.h @@ -123,21 +123,50 @@ void FixedArray::NoWriteBarrierSet(FixedArray array, int index, Object value) { RELAXED_WRITE_FIELD(array, offset, value); } -Object FixedArray::synchronized_get(int index) const { +Object FixedArray::get(int index, RelaxedLoadTag) const { IsolateRoot isolate = GetIsolateForPtrCompr(*this); - return synchronized_get(isolate, index); + return get(isolate, index); } -Object FixedArray::synchronized_get(IsolateRoot isolate, int index) const { +Object FixedArray::get(IsolateRoot isolate, int index, RelaxedLoadTag) const { + DCHECK_LT(static_cast(index), static_cast(length())); + return RELAXED_READ_FIELD(*this, OffsetOfElementAt(index)); +} + +void FixedArray::set(int index, Object value, RelaxedStoreTag, + WriteBarrierMode mode) { + DCHECK_NE(map(), GetReadOnlyRoots().fixed_cow_array_map()); + DCHECK_LT(static_cast(index), static_cast(length())); + RELAXED_WRITE_FIELD(*this, OffsetOfElementAt(index), value); + CONDITIONAL_WRITE_BARRIER(*this, OffsetOfElementAt(index), value, mode); +} + +void FixedArray::set(int index, Smi value, RelaxedStoreTag tag) { + DCHECK(Object(value).IsSmi()); + set(index, value, tag, SKIP_WRITE_BARRIER); +} + +Object FixedArray::get(int index, AcquireLoadTag) const { + IsolateRoot isolate = GetIsolateForPtrCompr(*this); + return get(isolate, index); +} + +Object FixedArray::get(IsolateRoot isolate, int index, AcquireLoadTag) const { DCHECK_LT(static_cast(index), static_cast(length())); return ACQUIRE_READ_FIELD(*this, OffsetOfElementAt(index)); } -void FixedArray::synchronized_set(int index, Smi value) { +void FixedArray::set(int index, Object value, ReleaseStoreTag, + WriteBarrierMode mode) { DCHECK_NE(map(), GetReadOnlyRoots().fixed_cow_array_map()); DCHECK_LT(static_cast(index), static_cast(length())); - DCHECK(Object(value).IsSmi()); RELEASE_WRITE_FIELD(*this, OffsetOfElementAt(index), value); + CONDITIONAL_WRITE_BARRIER(*this, OffsetOfElementAt(index), value, mode); +} + +void FixedArray::set(int index, Smi value, ReleaseStoreTag tag) { + DCHECK(Object(value).IsSmi()); + set(index, value, tag, SKIP_WRITE_BARRIER); } void FixedArray::set_undefined(int index) { diff --git a/src/objects/fixed-array.h b/src/objects/fixed-array.h index 564f82b736..53b4cbb22b 100644 --- a/src/objects/fixed-array.h +++ b/src/objects/fixed-array.h @@ -111,12 +111,19 @@ class FixedArray Isolate* isolate, Handle array, int index, Handle value); - // Synchronized setters and getters. - inline Object synchronized_get(int index) const; - inline Object synchronized_get(IsolateRoot isolate, int index) const; - // Currently only Smis are written with release semantics, hence we can avoid - // a write barrier. - inline void synchronized_set(int index, Smi value); + // Relaxed accessors. + inline Object get(int index, RelaxedLoadTag) const; + inline Object get(IsolateRoot isolate, int index, RelaxedLoadTag) const; + inline void set(int index, Object value, RelaxedStoreTag, + WriteBarrierMode mode = UPDATE_WRITE_BARRIER); + inline void set(int index, Smi value, RelaxedStoreTag); + + // Acquire/release accessors. + inline Object get(int index, AcquireLoadTag) const; + inline Object get(IsolateRoot isolate, int index, AcquireLoadTag) const; + inline void set(int index, Object value, ReleaseStoreTag, + WriteBarrierMode mode = UPDATE_WRITE_BARRIER); + inline void set(int index, Smi value, ReleaseStoreTag); // Setter that uses write barrier. inline void set(int index, Object value);