Changeset 56435 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Mar 24, 2010, 12:11:51 AM (15 years ago)
Author:
[email protected]
Message:

Bug 36519 - JSGlobalContextRelease is unnecessarily slow

Reviewed by Oliver Hunt.

Since [ http://trac.webkit.org/changeset/35917 ], calling
JSGlobalContextRelease always triggers a GC heap collection
(if not a full destroy). As per 35917's changelog "This is
only really necessary when the (JSGlobalObject's) last
reference is released, but there is no way to determine that,
and no harm in collecting slightly more often."

Well, we now know of cases of API clients who are harmed by
the performance penalty of collecting too often, so it's time
to add a way to determine whether a call to JSGlobalContextRelease
is removing the last protect from it's global object. If further
protects are retaining the global object (likely from other
JSGlobalContextRefs), then don't trigger a GC collection.

  • API/JSContextRef.cpp:
  • runtime/Collector.cpp:

(JSC::Heap::unprotect): return a boolean indicating that the value is now unprotected.

  • runtime/Collector.h:
  • wtf/HashCountedSet.h:

(WTF::::remove): return a boolean indicating whether the value was removed from the set.

Location:
trunk/JavaScriptCore/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Collector.cpp

    r56370 r56435  
    981981}
    982982
    983 void Heap::unprotect(JSValue k)
     983bool Heap::unprotect(JSValue k)
    984984{
    985985    ASSERT(k);
     
    987987
    988988    if (!k.isCell())
    989         return;
    990 
    991     m_protectedValues.remove(k.asCell());
     989        return false;
     990
     991    return m_protectedValues.remove(k.asCell());
    992992}
    993993
  • trunk/JavaScriptCore/runtime/Collector.h

    r56370 r56435  
    9696
    9797        void protect(JSValue);
    98         void unprotect(JSValue);
     98        // Returns true if the value is no longer protected by any protect pointers
     99        // (though it may still be alive due to heap/stack references).
     100        bool unprotect(JSValue);
    99101
    100102        static Heap* heap(JSValue); // 0 for immediate values
Note: See TracChangeset for help on using the changeset viewer.