Ignore:
Timestamp:
Oct 12, 2011, 1:28:49 PM (14 years ago)
Author:
[email protected]
Message:

ValueProfile::computeUpdatedPrediction doesn't merge statistics correctly
https://bugs.webkit.org/show_bug.cgi?id=69906

Reviewed by Gavin Barraclough.

It turns out that the simplest fix is to switch computeUpdatedPredictions()
to using predictionFromValue() combined with mergePrediction(). Doing so
allowed me to kill off weakBuckets and visitWeakReferences(). Hence this
not only fixes a performance bug but kills off a lot of code that I never
liked to begin with.

This appears to be a 1% win on V8.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::visitAggregate):

  • bytecode/CodeBlock.h:
  • bytecode/PredictedType.cpp:

(JSC::predictionFromValue):

  • bytecode/ValueProfile.cpp:

(JSC::ValueProfile::computeStatistics):
(JSC::ValueProfile::computeUpdatedPrediction):

  • bytecode/ValueProfile.h:

(JSC::ValueProfile::classInfo):
(JSC::ValueProfile::numberOfSamples):
(JSC::ValueProfile::isLive):
(JSC::ValueProfile::dump):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r96463 r97294  
    15281528void CodeBlock::visitAggregate(SlotVisitor& visitor)
    15291529{
    1530     bool handleWeakReferences = false;
    1531    
    15321530    if (!!m_alternative)
    15331531        m_alternative->visitAggregate(visitor);
     
    15811579
    15821580#if ENABLE(VALUE_PROFILER)
    1583     for (unsigned profileIndex = 0; profileIndex < numberOfValueProfiles(); ++profileIndex) {
    1584         ValueProfile* profile = valueProfile(profileIndex);
    1585        
    1586         for (unsigned index = 0; index < ValueProfile::numberOfBuckets; ++index) {
    1587             if (!profile->m_buckets[index]) {
    1588                 if (!!profile->m_weakBuckets[index])
    1589                     handleWeakReferences = true;
    1590                 continue;
    1591             }
    1592            
    1593             if (!JSValue::decode(profile->m_buckets[index]).isCell()) {
    1594                 profile->m_weakBuckets[index] = ValueProfile::WeakBucket();
    1595                 continue;
    1596             }
    1597            
    1598             handleWeakReferences = true;
    1599         }
    1600     }
    1601 #endif
    1602    
    1603     if (handleWeakReferences)
    1604         visitor.addWeakReferenceHarvester(this);
    1605 }
    1606 
    1607 void CodeBlock::visitWeakReferences(SlotVisitor&)
    1608 {
    1609 #if ENABLE(VALUE_PROFILER)
    1610     for (unsigned profileIndex = 0; profileIndex < numberOfValueProfiles(); ++profileIndex) {
    1611         ValueProfile* profile = valueProfile(profileIndex);
    1612        
    1613         for (unsigned index = 0; index < ValueProfile::numberOfBuckets; ++index) {
    1614             if (!!profile->m_buckets[index]) {
    1615                 JSValue value = JSValue::decode(profile->m_buckets[index]);
    1616                 if (!value.isCell())
    1617                     continue;
    1618                
    1619                 JSCell* cell = value.asCell();
    1620                 if (Heap::isMarked(cell))
    1621                     continue;
    1622                
    1623                 profile->m_buckets[index] = JSValue::encode(JSValue());
    1624                 profile->m_weakBuckets[index] = cell->structure();
    1625             }
    1626            
    1627             ValueProfile::WeakBucket weak = profile->m_weakBuckets[index];
    1628             if (!weak || weak.isClassInfo())
    1629                 continue;
    1630            
    1631             ASSERT(weak.isStructure());
    1632             if (Heap::isMarked(weak.asStructure()))
    1633                 continue;
    1634            
    1635             profile->m_weakBuckets[index] = weak.asStructure()->classInfo();
    1636         }
    1637     }
     1581    for (unsigned profileIndex = 0; profileIndex < numberOfValueProfiles(); ++profileIndex)
     1582        valueProfile(profileIndex)->computeUpdatedPrediction();
    16381583#endif
    16391584}
Note: See TracChangeset for help on using the changeset viewer.