Changeset 234089 in webkit for trunk/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp
- Timestamp:
- Jul 22, 2018, 9:54:38 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp
r233122 r234089 42 42 SparseArrayValueMap::SparseArrayValueMap(VM& vm) 43 43 : Base(vm, vm.sparseArrayValueMapStructure.get()) 44 , m_flags(Normal)45 , m_reportedCapacity(0)46 {47 }48 49 SparseArrayValueMap::~SparseArrayValueMap()50 44 { 51 45 } … … 79 73 { 80 74 auto locker = holdLock(cellLock()); 81 SparseArrayEntry entry; 82 entry.setWithoutWriteBarrier(jsUndefined()); 83 84 result = m_map.add(i, entry); 75 result = m_map.add(i, SparseArrayEntry()); 85 76 capacity = m_map.capacity(); 86 77 } … … 146 137 } 147 138 148 if (entry.attributes & PropertyAttribute::ReadOnly)139 if (entry.attributes() & PropertyAttribute::ReadOnly) 149 140 return typeError(exec, scope, shouldThrow, ReadonlyPropertyWriteError); 150 141 151 entry.attributes = attributes; 152 entry.set(vm, this, value); 142 entry.forceSet(vm, this, value, attributes); 153 143 return true; 144 } 145 146 JSValue SparseArrayValueMap::getConcurrently(unsigned i) 147 { 148 auto locker = holdLock(cellLock()); 149 auto iterator = m_map.find(i); 150 if (iterator == m_map.end()) 151 return JSValue(); 152 return iterator->value.getConcurrently(); 154 153 } 155 154 … … 160 159 161 160 if (LIKELY(!value.isGetterSetter())) { 162 slot.setValue(thisObject, attributes, value);161 slot.setValue(thisObject, m_attributes, value); 163 162 return; 164 163 } 165 164 166 slot.setGetterSlot(thisObject, attributes, jsCast<GetterSetter*>(value));165 slot.setGetterSlot(thisObject, m_attributes, jsCast<GetterSetter*>(value)); 167 166 } 168 167 169 168 void SparseArrayEntry::get(PropertyDescriptor& descriptor) const 170 169 { 171 descriptor.setDescriptor(Base::get(), attributes); 170 descriptor.setDescriptor(Base::get(), m_attributes); 171 } 172 173 JSValue SparseArrayEntry::getConcurrently() const 174 { 175 // These attributes and value can be updated while executing getConcurrently. 176 // But this is OK since attributes should be never weaken once it gets DontDelete and ReadOnly. 177 // By emitting store-store-fence and load-load-fence between value setting and attributes setting, 178 // we can ensure that the value is what we want once the attributes get ReadOnly & DontDelete: 179 // once attributes get this state, the value should not be changed. 180 unsigned attributes = m_attributes; 181 Dependency attributesDependency = Dependency::fence(attributes); 182 if (attributes & PropertyAttribute::Accessor) 183 return JSValue(); 184 185 if (!(attributes & PropertyAttribute::ReadOnly)) 186 return JSValue(); 187 188 if (!(attributes & PropertyAttribute::DontDelete)) 189 return JSValue(); 190 191 return attributesDependency.consume(this)->Base::get(); 172 192 } 173 193 … … 177 197 auto scope = DECLARE_THROW_SCOPE(vm); 178 198 179 if (!( attributes & PropertyAttribute::Accessor)) {180 if ( attributes & PropertyAttribute::ReadOnly)199 if (!(m_attributes & PropertyAttribute::Accessor)) { 200 if (m_attributes & PropertyAttribute::ReadOnly) 181 201 return typeError(exec, scope, shouldThrow, ReadonlyPropertyWriteError); 182 202 … … 191 211 JSValue SparseArrayEntry::getNonSparseMode() const 192 212 { 193 ASSERT(! attributes);213 ASSERT(!m_attributes); 194 214 return Base::get(); 195 215 } … … 203 223 iterator end = thisMap->m_map.end(); 204 224 for (iterator it = thisMap->m_map.begin(); it != end; ++it) 205 visitor.append(it->value );225 visitor.append(it->value.asValue()); 206 226 } 207 227
Note:
See TracChangeset
for help on using the changeset viewer.