Changeset 227906 in webkit
- Timestamp:
- Jan 31, 2018, 10:57:13 AM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 11 edited
-
ChangeLog (modified) (1 diff)
-
bytecode/UnlinkedCodeBlock.cpp (modified) (3 diffs)
-
bytecode/UnlinkedCodeBlock.h (modified) (7 diffs)
-
runtime/ErrorInstance.cpp (modified) (3 diffs)
-
runtime/JSArray.cpp (modified) (2 diffs)
-
runtime/JSCell.cpp (modified) (2 diffs)
-
runtime/JSCell.h (modified) (4 diffs)
-
runtime/JSCellInlines.h (modified) (4 diffs)
-
runtime/JSObject.cpp (modified) (3 diffs)
-
runtime/JSPropertyNameEnumerator.cpp (modified) (2 diffs)
-
runtime/SparseArrayValueMap.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r227898 r227906 1 2018-01-31 Keith Miller <keith_miller@apple.com> 2 3 Canonicalize aquiring the JSCell lock. 4 https://bugs.webkit.org/show_bug.cgi?id=182320 5 6 Reviewed by Michael Saboff. 7 8 It's currently kinda annoying to figure out where 9 we aquire the a JSCell's lock. This patch adds a 10 helper to make it easier to grep... 11 12 * bytecode/UnlinkedCodeBlock.cpp: 13 (JSC::UnlinkedCodeBlock::visitChildren): 14 (JSC::UnlinkedCodeBlock::setInstructions): 15 (JSC::UnlinkedCodeBlock::shrinkToFit): 16 * runtime/ErrorInstance.cpp: 17 (JSC::ErrorInstance::finishCreation): 18 (JSC::ErrorInstance::materializeErrorInfoIfNeeded): 19 (JSC::ErrorInstance::visitChildren): 20 * runtime/JSArray.cpp: 21 (JSC::JSArray::shiftCountWithArrayStorage): 22 (JSC::JSArray::unshiftCountWithArrayStorage): 23 * runtime/JSCell.h: 24 (JSC::JSCell::cellLock): 25 * runtime/JSObject.cpp: 26 (JSC::JSObject::visitButterflyImpl): 27 (JSC::JSObject::convertContiguousToArrayStorage): 28 * runtime/JSPropertyNameEnumerator.cpp: 29 (JSC::JSPropertyNameEnumerator::visitChildren): 30 * runtime/SparseArrayValueMap.cpp: 31 (JSC::SparseArrayValueMap::add): 32 (JSC::SparseArrayValueMap::remove): 33 (JSC::SparseArrayValueMap::visitChildren): 34 1 35 2018-01-31 Saam Barati <sbarati@apple.com> 2 36 -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
r226928 r227906 95 95 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 96 96 Base::visitChildren(thisObject, visitor); 97 auto locker = holdLock( *thisObject);97 auto locker = holdLock(thisObject->cellLock()); 98 98 for (FunctionExpressionVector::iterator ptr = thisObject->m_functionDecls.begin(), end = thisObject->m_functionDecls.end(); ptr != end; ++ptr) 99 99 visitor.append(*ptr); … … 318 318 ASSERT(instructions); 319 319 { 320 auto locker = holdLock( *this);320 auto locker = holdLock(cellLock()); 321 321 m_unlinkedInstructions = WTFMove(instructions); 322 322 } … … 393 393 void UnlinkedCodeBlock::shrinkToFit() 394 394 { 395 auto locker = holdLock( *this);395 auto locker = holdLock(cellLock()); 396 396 397 397 m_jumpTargets.shrinkToFit(); -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
r226928 r227906 161 161 createRareDataIfNecessary(); 162 162 VM& vm = *this->vm(); 163 auto locker = lockDuringMarking(vm.heap, *this);163 auto locker = lockDuringMarking(vm.heap, cellLock()); 164 164 unsigned size = m_rareData->m_regexps.size(); 165 165 m_rareData->m_regexps.append(WriteBarrier<RegExp>(vm, this, r)); … … 192 192 { 193 193 VM& vm = *this->vm(); 194 auto locker = lockDuringMarking(vm.heap, *this);194 auto locker = lockDuringMarking(vm.heap, cellLock()); 195 195 unsigned result = m_constantRegisters.size(); 196 196 m_constantRegisters.append(WriteBarrier<Unknown>()); … … 202 202 { 203 203 VM& vm = *this->vm(); 204 auto locker = lockDuringMarking(vm.heap, *this);204 auto locker = lockDuringMarking(vm.heap, cellLock()); 205 205 unsigned result = m_constantRegisters.size(); 206 206 m_constantRegisters.append(WriteBarrier<Unknown>()); … … 212 212 { 213 213 VM& vm = *this->vm(); 214 auto locker = lockDuringMarking(vm.heap, *this);214 auto locker = lockDuringMarking(vm.heap, cellLock()); 215 215 unsigned result = m_constantRegisters.size(); 216 216 ASSERT(result); … … 275 275 { 276 276 VM& vm = *this->vm(); 277 auto locker = lockDuringMarking(vm.heap, *this);277 auto locker = lockDuringMarking(vm.heap, cellLock()); 278 278 unsigned size = m_functionDecls.size(); 279 279 m_functionDecls.append(WriteBarrier<UnlinkedFunctionExecutable>()); … … 286 286 { 287 287 VM& vm = *this->vm(); 288 auto locker = lockDuringMarking(vm.heap, *this);288 auto locker = lockDuringMarking(vm.heap, cellLock()); 289 289 unsigned size = m_functionExprs.size(); 290 290 m_functionExprs.append(WriteBarrier<UnlinkedFunctionExecutable>()); … … 416 416 { 417 417 if (!m_rareData) { 418 auto locker = lockDuringMarking(*heap(), *this);418 auto locker = lockDuringMarking(*heap(), cellLock()); 419 419 m_rareData = std::make_unique<RareData>(); 420 420 } -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp
r225768 r227906 118 118 std::unique_ptr<Vector<StackFrame>> stackTrace = getStackTrace(exec, vm, this, useCurrentFrame); 119 119 { 120 auto locker = holdLock( *this);120 auto locker = holdLock(cellLock()); 121 121 m_stackTrace = WTFMove(stackTrace); 122 122 } … … 210 210 addErrorInfo(vm, m_stackTrace.get(), this); 211 211 { 212 auto locker = holdLock( *this);212 auto locker = holdLock(cellLock()); 213 213 m_stackTrace = nullptr; 214 214 } … … 235 235 236 236 { 237 auto locker = holdLock( *thisObject);237 auto locker = holdLock(thisObject->cellLock()); 238 238 if (thisObject->m_stackTrace) { 239 239 for (StackFrame& frame : *thisObject->m_stackTrace) -
trunk/Source/JavaScriptCore/runtime/JSArray.cpp
r227617 r227906 803 803 804 804 DisallowGC disallowGC; 805 auto locker = holdLock( *this);805 auto locker = holdLock(cellLock()); 806 806 807 807 if (startIndex + count > vectorLength) … … 1006 1006 // a weird state: some parts of it will be left uninitialized, which we will fill in here. 1007 1007 DeferGC deferGC(vm.heap); 1008 auto locker = holdLock( *this);1008 auto locker = holdLock(cellLock()); 1009 1009 1010 1010 if (moveFront && storage->m_indexBias >= count) { -
trunk/Source/JavaScriptCore/runtime/JSCell.cpp
r226338 r227906 309 309 } 310 310 311 void JSCell ::lockSlow()311 void JSCellLock::lockSlow() 312 312 { 313 313 Atomic<IndexingType>* lock = bitwise_cast<Atomic<IndexingType>*>(&m_indexingTypeAndMisc); … … 315 315 } 316 316 317 void JSCell ::unlockSlow()317 void JSCellLock::unlockSlow() 318 318 { 319 319 Atomic<IndexingType>* lock = bitwise_cast<Atomic<IndexingType>*>(&m_indexingTypeAndMisc); -
trunk/Source/JavaScriptCore/runtime/JSCell.h
r225799 r227906 51 51 class PropertyNameArray; 52 52 class Structure; 53 class JSCellLock; 53 54 54 55 enum class GCDeferralContextArgPresense { … … 121 122 // a full-blown WTF::Lock. Note that this lock is currently used in JSArray and that lock's 122 123 // ordering with the Structure lock is that the Structure lock must be acquired first. 123 void lock(); 124 bool tryLock(); 125 void unlock(); 126 bool isLocked() const; 124 125 // We use this abstraction to make it easier to grep for places where we lock cells. 126 // to lock a cell you can just do: 127 // auto locker = holdLock(cell->cellLocker()); 128 JSCellLock& cellLock() { return *reinterpret_cast<JSCellLock*>(this); } 127 129 128 130 JSType type() const; … … 273 275 private: 274 276 friend class LLIntOffsetsExtractor; 277 friend class JSCellLock; 275 278 276 279 JS_EXPORT_PRIVATE JSObject* toObjectSlow(ExecState*, JSGlobalObject*) const; 277 JS_EXPORT_PRIVATE void lockSlow();278 JS_EXPORT_PRIVATE void unlockSlow();279 280 280 281 StructureID m_structureID; … … 285 286 }; 286 287 288 class JSCellLock : public JSCell { 289 public: 290 void lock(); 291 bool tryLock(); 292 void unlock(); 293 bool isLocked() const; 294 private: 295 JS_EXPORT_PRIVATE void lockSlow(); 296 JS_EXPORT_PRIVATE void unlockSlow(); 297 }; 298 287 299 template<typename To, typename From> 288 300 inline To jsCast(From* from) -
trunk/Source/JavaScriptCore/runtime/JSCellInlines.h
r227617 r227906 324 324 } 325 325 326 inline void JSCell ::lock()326 inline void JSCellLock::lock() 327 327 { 328 328 Atomic<IndexingType>* lock = bitwise_cast<Atomic<IndexingType>*>(&m_indexingTypeAndMisc); … … 331 331 } 332 332 333 inline bool JSCell ::tryLock()333 inline bool JSCellLock::tryLock() 334 334 { 335 335 Atomic<IndexingType>* lock = bitwise_cast<Atomic<IndexingType>*>(&m_indexingTypeAndMisc); … … 337 337 } 338 338 339 inline void JSCell ::unlock()339 inline void JSCellLock::unlock() 340 340 { 341 341 Atomic<IndexingType>* lock = bitwise_cast<Atomic<IndexingType>*>(&m_indexingTypeAndMisc); … … 344 344 } 345 345 346 inline bool JSCell ::isLocked() const346 inline bool JSCellLock::isLocked() const 347 347 { 348 348 Atomic<IndexingType>* lock = bitwise_cast<Atomic<IndexingType>*>(&m_indexingTypeAndMisc); -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r227435 r227906 384 384 IndexingType indexingType = structure->indexingType(); 385 385 Dependency indexingTypeDependency = Dependency::fence(indexingType); 386 Locker<JSCell > locker(NoLockingNecessary);386 Locker<JSCellLock> locker(NoLockingNecessary); 387 387 switch (indexingType) { 388 388 case ALL_CONTIGUOUS_INDEXING_TYPES: … … 392 392 // assume that a contiguous butterfly may transform into an array storage one, though 393 393 // this is probably more conservative than necessary. 394 locker = Locker<JSCell>(*this);394 locker = holdLock(cellLock()); 395 395 break; 396 396 default: … … 1359 1359 1360 1360 if (vm.heap.mutatorShouldBeFenced()) { 1361 auto locker = holdLock( *this);1361 auto locker = holdLock(cellLock()); 1362 1362 m_butterflyIndexingMask = newStorage->butterfly()->computeIndexingMask(); 1363 1363 setStructureIDDirectly(nuke(structureID())); -
trunk/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.cpp
r222017 r227906 72 72 73 73 { 74 auto locker = lockDuringMarking(vm.heap, *this);74 auto locker = lockDuringMarking(vm.heap, cellLock()); 75 75 m_propertyNames.resizeToFit(vector.size()); 76 76 } … … 90 90 Base::visitChildren(cell, visitor); 91 91 JSPropertyNameEnumerator* thisObject = jsCast<JSPropertyNameEnumerator*>(cell); 92 auto locker = holdLock( *thisObject);92 auto locker = holdLock(thisObject->cellLock()); 93 93 for (auto& propertyName : thisObject->m_propertyNames) 94 94 visitor.append(propertyName); -
trunk/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp
r222473 r227906 78 78 size_t capacity; 79 79 { 80 auto locker = holdLock( *this);80 auto locker = holdLock(cellLock()); 81 81 SparseArrayEntry entry; 82 82 entry.setWithoutWriteBarrier(jsUndefined()); … … 96 96 void SparseArrayValueMap::remove(iterator it) 97 97 { 98 auto locker = holdLock( *this);98 auto locker = holdLock(cellLock()); 99 99 m_map.remove(it); 100 100 } … … 102 102 void SparseArrayValueMap::remove(unsigned i) 103 103 { 104 auto locker = holdLock( *this);104 auto locker = holdLock(cellLock()); 105 105 m_map.remove(i); 106 106 } … … 198 198 { 199 199 Base::visitChildren(thisObject, visitor); 200 200 201 auto locker = holdLock(thisObject->cellLock()); 201 202 SparseArrayValueMap* thisMap = jsCast<SparseArrayValueMap*>(thisObject); 202 auto locker = holdLock(*thisMap);203 203 iterator end = thisMap->m_map.end(); 204 204 for (iterator it = thisMap->m_map.begin(); it != end; ++it)
Note:
See TracChangeset
for help on using the changeset viewer.