Changeset 201590 in webkit
- Timestamp:
- Jun 1, 2016, 9:26:32 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
runtime/Structure.cpp (modified) (4 diffs)
-
runtime/Structure.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r201589 r201590 1 2016-06-01 Filip Pizlo <fpizlo@apple.com> 2 3 Structure::previousID() races with Structure::allocateRareData() 4 https://bugs.webkit.org/show_bug.cgi?id=158280 5 6 Reviewed by Mark Lam. 7 8 The problem is that previousID() would test hasRareData() and then either load the 9 previous Structure from the rare data, or load it directly. allocateRareData() would set 10 the hasRareData() bit separately from moving the Structure pointer into the rare data. So 11 we'd have a race that would cause previousID() to sometimes return the rarae data instead 12 of the previous Structure. 13 14 The fix is to get rid of the hasRareData bit. We can use the structureID of the 15 previousOrRareData cell to determine if it's the previousID or the RareData. This fixes the 16 race and it's probably not any slower. 17 18 * runtime/Structure.cpp: 19 (JSC::Structure::Structure): 20 (JSC::Structure::allocateRareData): 21 * runtime/Structure.h: 22 1 23 2016-06-01 Michael Saboff <msaboff@apple.com> 2 24 -
trunk/Source/JavaScriptCore/runtime/Structure.cpp
r200405 r201590 207 207 setDidTransition(false); 208 208 setStaticFunctionsReified(false); 209 setHasRareData(false);210 209 setTransitionWatchpointIsLikelyToBeFired(false); 211 210 setHasBeenDictionary(false); … … 239 238 setDidTransition(false); 240 239 setStaticFunctionsReified(false); 241 setHasRareData(false);242 240 setTransitionWatchpointIsLikelyToBeFired(false); 243 241 setHasBeenDictionary(false); … … 270 268 setDidTransition(true); 271 269 setStaticFunctionsReified(previous->staticFunctionsReified()); 272 setHasRareData(false);273 270 setHasBeenDictionary(previous->hasBeenDictionary()); 274 271 … … 824 821 { 825 822 ASSERT(!hasRareData()); 826 StructureRareData* rareData = StructureRareData::create(vm, previous ());823 StructureRareData* rareData = StructureRareData::create(vm, previousID()); 827 824 WTF::storeStoreFence(); 828 825 m_previousOrRareData.set(vm, this, rareData); 829 WTF::storeStoreFence();830 setHasRareData(true);831 826 ASSERT(hasRareData()); 832 827 } -
trunk/Source/JavaScriptCore/runtime/Structure.h
r200405 r201590 275 275 // Will just the prototype chain intercept this property access? 276 276 JS_EXPORT_PRIVATE bool prototypeChainMayInterceptStoreTo(VM&, PropertyName); 277 277 278 bool hasRareData() const 279 { 280 return isRareData(m_previousOrRareData.get()); 281 } 282 278 283 Structure* previousID() const 279 284 { 280 285 ASSERT(structure()->classInfo() == info()); 281 if (hasRareData()) 282 return rareData()->previousID(); 283 return previous(); 286 // This is so written because it's used concurrently. We only load from m_previousOrRareData 287 // once, and this load is guaranteed atomic. 288 JSCell* cell = m_previousOrRareData.get(); 289 if (isRareData(cell)) 290 return static_cast<StructureRareData*>(cell)->previousID(); 291 return static_cast<Structure*>(cell); 284 292 } 285 293 bool transitivelyTransitionedFrom(Structure* structureToFind); … … 603 611 DEFINE_BITFIELD(bool, didTransition, DidTransition, 1, 21); 604 612 DEFINE_BITFIELD(bool, staticFunctionsReified, StaticFunctionsReified, 1, 22); 605 DEFINE_BITFIELD(bool, hasRareData, HasRareData, 1, 23); 606 DEFINE_BITFIELD(bool, hasBeenFlattenedBefore, HasBeenFlattenedBefore, 1, 24); 607 DEFINE_BITFIELD(bool, hasCustomGetterSetterProperties, HasCustomGetterSetterProperties, 1, 25); 608 DEFINE_BITFIELD(bool, didWatchInternalProperties, DidWatchInternalProperties, 1, 26); 609 DEFINE_BITFIELD(bool, transitionWatchpointIsLikelyToBeFired, TransitionWatchpointIsLikelyToBeFired, 1, 27); 610 DEFINE_BITFIELD(bool, hasBeenDictionary, HasBeenDictionary, 1, 28); 613 DEFINE_BITFIELD(bool, hasBeenFlattenedBefore, HasBeenFlattenedBefore, 1, 23); 614 DEFINE_BITFIELD(bool, hasCustomGetterSetterProperties, HasCustomGetterSetterProperties, 1, 24); 615 DEFINE_BITFIELD(bool, didWatchInternalProperties, DidWatchInternalProperties, 1, 25); 616 DEFINE_BITFIELD(bool, transitionWatchpointIsLikelyToBeFired, TransitionWatchpointIsLikelyToBeFired, 1, 26); 617 DEFINE_BITFIELD(bool, hasBeenDictionary, HasBeenDictionary, 1, 27); 611 618 612 619 private: … … 694 701 695 702 void pin(); 696 697 Structure* previous() const 698 { 699 ASSERT(!hasRareData()); 700 return static_cast<Structure*>(m_previousOrRareData.get()); 703 704 bool isRareData(JSCell* cell) const 705 { 706 return cell && cell->structureID() != structureID(); 701 707 } 702 708
Note:
See TracChangeset
for help on using the changeset viewer.