Changeset 73223 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Dec 2, 2010, 5:16:11 PM (14 years ago)
Author:
[email protected]
Message:

Fixed <rdar://problem/8310571> CrashTracer: 60 crashes in Photo Booth at
com.apple.JavaScriptCore: JSC::Heap::markRoots + 746

Reviewed by Gavin Barraclough.

  • API/APIShims.h:

(JSC::APIEntryShimWithoutLock::APIEntryShimWithoutLock): Call our new
synchronize() function.

  • runtime/Collector.cpp:

(JSC::Heap::activityCallback):

  • runtime/Collector.h: Added an activityCallback() accessor, for the

call above.

  • runtime/GCActivityCallback.h:

(JSC::GCActivityCallback::synchronize):

  • runtime/GCActivityCallbackCF.cpp:

(JSC::DefaultGCActivityCallback::DefaultGCActivityCallback):
(JSC::DefaultGCActivityCallback::~DefaultGCActivityCallback):
(JSC::DefaultGCActivityCallback::operator()):
(JSC::DefaultGCActivityCallback::synchronize): Track the run loop we're
scheduled in. If we begin/resume execution within a new run loop, reschedule
on it. This prevents a crash when using a lockless context group on
multiple threads -- the crash would happen if the GC timer scheduled on
thread A, then you continued execution on thread B, then the thread A
timer fired.

Location:
trunk/JavaScriptCore/runtime
Files:
4 edited

Legend:

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

    r72360 r73223  
    12331233}
    12341234
     1235GCActivityCallback* Heap::activityCallback()
     1236{
     1237    return m_activityCallback.get();
     1238}
     1239
    12351240} // namespace JSC
  • trunk/JavaScriptCore/runtime/Collector.h

    r68893 r73223  
    9999        bool isBusy(); // true if an allocation or collection is in progress
    100100        void collectAllGarbage();
     101
     102        GCActivityCallback* activityCallback();
    101103        void setActivityCallback(PassOwnPtr<GCActivityCallback>);
    102104
  • trunk/JavaScriptCore/runtime/GCActivityCallback.h

    r64585 r73223  
    4141    virtual ~GCActivityCallback() {}
    4242    virtual void operator()() {}
     43    virtual void synchronize() {}
    4344
    4445protected:
     
    5657
    5758    void operator()();
     59    void synchronize();
    5860
    5961private:
  • trunk/JavaScriptCore/runtime/GCActivityCallbackCF.cpp

    r67683 r73223  
    4848
    4949    RetainPtr<CFRunLoopTimerRef> timer;
     50    RetainPtr<CFRunLoopRef> runLoop;
    5051    CFRunLoopTimerContext context;
    5152};
    5253
    5354const CFTimeInterval decade = 60 * 60 * 24 * 365 * 10;
     55const CFTimeInterval triggerInterval = 2; // seconds
    5456
    5557void DefaultGCActivityCallbackPlatformData::trigger(CFRunLoopTimerRef, void *info)
     
    6668    memset(&d->context, '\0', sizeof(CFRunLoopTimerContext));
    6769    d->context.info = heap;
     70    d->runLoop = CFRunLoopGetCurrent();
    6871    d->timer.adoptCF(CFRunLoopTimerCreate(0, decade, decade, 0, 0, DefaultGCActivityCallbackPlatformData::trigger, &d->context));
    69     CFRunLoopAddTimer(CFRunLoopGetCurrent(), d->timer.get(), kCFRunLoopCommonModes);
     72    CFRunLoopAddTimer(d->runLoop.get(), d->timer.get(), kCFRunLoopCommonModes);
    7073}
    7174
    7275DefaultGCActivityCallback::~DefaultGCActivityCallback()
    7376{
    74     CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), d->timer.get(), kCFRunLoopCommonModes);
     77    CFRunLoopRemoveTimer(d->runLoop.get(), d->timer.get(), kCFRunLoopCommonModes);
    7578    CFRunLoopTimerInvalidate(d->timer.get());
    7679    d->context.info = 0;
     80    d->runLoop = 0;
    7781    d->timer = 0;
    7882}
     
    8084void DefaultGCActivityCallback::operator()()
    8185{
    82     CFRunLoopTimerSetNextFireDate(d->timer.get(), CFAbsoluteTimeGetCurrent() + 2);
     86    CFRunLoopTimerSetNextFireDate(d->timer.get(), CFAbsoluteTimeGetCurrent() + triggerInterval);
     87}
     88
     89void DefaultGCActivityCallback::synchronize()
     90{
     91    if (CFRunLoopGetCurrent() == d->runLoop.get())
     92        return;
     93    CFRunLoopRemoveTimer(d->runLoop.get(), d->timer.get(), kCFRunLoopCommonModes);
     94    d->runLoop = CFRunLoopGetCurrent();
     95    CFRunLoopAddTimer(d->runLoop.get(), d->timer.get(), kCFRunLoopCommonModes);
    8396}
    8497
Note: See TracChangeset for help on using the changeset viewer.