Changeset 30849 in webkit


Ignore:
Timestamp:
Mar 6, 2008 10:55:02 AM (16 years ago)
Author:
beidson@apple.com
Message:

JavaScriptCore:

Reviewed by Darin

Add a timedWait() method to ThreadCondition

  • wtf/Threading.h:
  • wtf/ThreadingGtk.cpp: (WTF::ThreadCondition::timedWait):
  • wtf/ThreadingNone.cpp: (WTF::ThreadCondition::timedWait):
  • wtf/ThreadingPthreads.cpp: (WTF::ThreadCondition::timedWait):
  • wtf/ThreadingWin.cpp: (WTF::ThreadCondition::timedWait): Needs implementation

WebKitTools:

Reviewed by Darin

Added a cross-platform Watchdog thread to DRT.

The current watchdog in both DRTWin and DRTMac is Timer based. Therefore, deadlocks and long running
main thread hangs still affect DRT.

By placing the watchdog on a thread and having DRT "check in" after each test, long-running hangs
and true deadlocks can be caught.

There is one hook for platform specific code. As I did my development and testing on Mac, and Mac has
sample available, the Mac implementation of this hook samples the process before it is killed.

I arbitrarily chose 30 seconds as the timeout for now - this can be tweaked easily if we find a need.

  • DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
  • DumpRenderTree/mac/Configurations/Base.xcconfig: Added LINKER_DISPLAYS_MANGLED_NAMES
  • DumpRenderTree/ForwardingHeaders/wtf/Locker.h: Added.
  • DumpRenderTree/ForwardingHeaders/wtf/Threading.h: Added.
  • DumpRenderTree/Watchdog.cpp: Added. (Watchdog::Watchdog): (Watchdog::~Watchdog): (Watchdog::start): (Watchdog::stop): (Watchdog::checkIn): (Watchdog::setWatchdogInterval): (Watchdog::handleHang): (Watchdog::watchdogThreadStart): (Watchdog::watchdogThread):
  • DumpRenderTree/Watchdog.h: Added.
  • DumpRenderTree/mac/WatchdogMac.h: Added.
  • DumpRenderTree/mac/WatchdogMac.mm: Added. (WatchdogMac::handleHang): Sample the process and write it out to a file
  • DumpRenderTree/mac/DumpRenderTree.mm: (dumpRenderTree): Setup and start the watchdog before running any tests (runTest): Checkin with the watchdog after each test
Location:
trunk
Files:
6 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r30848 r30849  
     12008-03-06  Brady Eidson <beidson@apple.com>
     2
     3        Reviewed by Darin
     4
     5        Add a timedWait() method to ThreadCondition
     6
     7        * JavaScriptCore.exp:
     8
     9        * wtf/Threading.h:
     10
     11        * wtf/ThreadingGtk.cpp:
     12        (WTF::ThreadCondition::timedWait):
     13
     14        * wtf/ThreadingNone.cpp:
     15        (WTF::ThreadCondition::timedWait):
     16
     17        * wtf/ThreadingPthreads.cpp:
     18        (WTF::ThreadCondition::timedWait):
     19
     20        * wtf/ThreadingWin.cpp:
     21        (WTF::ThreadCondition::timedWait): Needs implementation
     22
    1232008-03-06  Alexey Proskuryakov  <ap@webkit.org>
    224
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r30842 r30849  
    8383__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
    8484__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
     85__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringE
    8586__ZN3KJS11Interpreter11checkSyntaxEPNS_9ExecStateERKNS_7UStringEiPKNS_5UCharEi
    8687__ZN3KJS11Interpreter21shouldPrintExceptionsEv
     
    151152__ZN3KJS6parserEv
    152153__ZN3KJS7CStringD1Ev
     154__ZN3KJS7CStringaSERKS0_
    153155__ZN3KJS7UString3Rep4nullE
    154156__ZN3KJS7UString3Rep7destroyEv
    155157__ZN3KJS7UString4fromEj
     158__ZN3KJS7UString6appendEPKc
    156159__ZN3KJS7UString6appendERKS0_
    157160__ZN3KJS7UStringC1EPKNS_5UCharEi
     
    206209__ZN3WTF15ThreadCondition6signalEv
    207210__ZN3WTF15ThreadCondition9broadcastEv
     211__ZN3WTF15ThreadCondition9timedWaitERNS_5MutexEd
    208212__ZN3WTF15ThreadConditionC1Ev
    209213__ZN3WTF15ThreadConditionD1Ev
     
    216220__ZN3WTF5MutexC1Ev
    217221__ZN3WTF5MutexD1Ev
     222__ZN3WTF8Collator18setOrderLowerFirstEb
     223__ZN3WTF8CollatorC1EPKc
     224__ZN3WTF8CollatorD1Ev
    218225__ZN3WTF8fastFreeEPv
    219226__ZNK3KJS11PropertyMap3getERKNS_10IdentifierE
     
    245252__ZNK3KJS7UString8toUInt32EPbb
    246253__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
     254__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateEj
    247255__ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE
    248256__ZNK3KJS8JSObject14implementsCallEv
     
    259267__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
    260268__ZNK3KJS9ExecState19lexicalGlobalObjectEv
     269__ZNK3WTF8Collator7collateEPKtmS2_m
    261270__ZTVN3KJS14JSGlobalObjectE
    262271__ZTVN3KJS14StringInstanceE
     
    269278_kJSClassDefinitionEmpty
    270279_kjs_strtod
    271 __ZN3WTF8Collator18setOrderLowerFirstEb
    272 __ZN3WTF8CollatorC1EPKc
    273 __ZN3WTF8CollatorD1Ev
    274 __ZNK3WTF8Collator7collateEPKtmS2_m
    275 __ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringE
    276 __ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateEj
    277 __ZN3KJS7UString6appendEPKc
    278 __ZN3KJS7CStringaSERKS0_
  • trunk/JavaScriptCore/wtf/Threading.h

    r30842 r30849  
    159159   
    160160    void wait(Mutex& mutex);
     161    // Returns true if the condition was signaled before the timeout, false if the timeout was reached
     162    bool timedWait(Mutex&, double interval);
    161163    void signal();
    162164    void broadcast();
  • trunk/JavaScriptCore/wtf/ThreadingGtk.cpp

    r30842 r30849  
    177177}
    178178
     179bool ThreadCondition::timedWait(Mutex& mutex, double interval)
     180{
     181    if (interval < 0.0) {
     182        wait(mutex);
     183        return true;
     184    }
     185   
     186    int intervalSeconds = static_cast<int>(interval);
     187    int intervalMicroseconds = static_cast<int>((interval - intervalSeconds) * 1000000.0);
     188   
     189    GTimeVal targetTime;
     190    g_get_current_time(&targetTime);
     191       
     192    targetTime.tv_sec += intervalSeconds;
     193    targetTime.tv_usec += intervalMicroseconds;
     194    if (targetTime.tv_usec > 1000000) {
     195        targetTime.tv_usec -= 1000000;
     196        targetTime.tv_sec++;
     197    }
     198
     199    return g_cond_timedwait(m_condition, mutex.impl(), &targetTime);
     200}
     201
    179202void ThreadCondition::signal()
    180203{
  • trunk/JavaScriptCore/wtf/ThreadingNone.cpp

    r30842 r30849  
    4848ThreadCondition::~ThreadCondition() {}
    4949void ThreadCondition::wait(Mutex& mutex) {}
     50bool ThreadCondition::timedWait(Mutex& mutex, double interval) { return false; }
    5051void ThreadCondition::signal() {}
    5152void ThreadCondition::broadcast() {}
  • trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp

    r30842 r30849  
    3333
    3434#include <errno.h>
     35#include <time.h>
    3536
    3637namespace WTF {
     
    185186        ASSERT(false);
    186187}
    187    
     188
     189bool ThreadCondition::timedWait(Mutex& mutex, double interval)
     190{
     191    if (interval < 0.0) {
     192        wait(mutex);
     193        return true;
     194    }
     195   
     196    int intervalSeconds = static_cast<int>(interval);
     197    int intervalMicroseconds = static_cast<int>((interval - intervalSeconds) * 1000000.0);
     198   
     199    // Current time comes in sec/microsec
     200    timeval currentTime;
     201    gettimeofday(&currentTime, NULL);
     202   
     203    // Target time comes in sec/nanosec
     204    timespec targetTime;
     205    targetTime.tv_sec = currentTime.tv_sec + intervalSeconds;
     206    targetTime.tv_nsec = (currentTime.tv_usec + intervalMicroseconds) * 1000;
     207    if (targetTime.tv_nsec > 1000000000) {
     208        targetTime.tv_nsec -= 1000000000;
     209        targetTime.tv_sec++;
     210    }
     211
     212    return pthread_cond_timedwait(&m_condition, &mutex.impl(), &targetTime) == 0;
     213}
     214
    188215void ThreadCondition::signal()
    189216{
  • trunk/JavaScriptCore/wtf/ThreadingWin.cpp

    r30842 r30849  
    284284
    285285    ::EnterCriticalSection (&cs.m_internalMutex);
     286}
     287
     288bool ThreadCondition::timedWait(Mutex& mutex, double interval)
     289{
     290    // Empty for now
     291    ASSERT(false);
    286292}
    287293
  • trunk/WebKitTools/ChangeLog

    r30818 r30849  
     12008-03-06  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Darin
     4
     5        Added a cross-platform Watchdog thread to DRT.
     6
     7        The current watchdog in both DRTWin and DRTMac is Timer based.  Therefore, deadlocks and long running
     8        main thread hangs still affect DRT.
     9
     10        By placing the watchdog on a thread and having DRT "check in" after each test, long-running hangs
     11        and true deadlocks can be caught.
     12
     13        There is one hook for platform specific code.  As I did my development and testing on Mac, and Mac has
     14        `sample` available, the Mac implementation of this hook samples the process before it is killed.
     15
     16        I arbitrarily chose 30 seconds as the timeout for now - this can be tweaked easily if we find a need.
     17
     18        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
     19        * DumpRenderTree/mac/Configurations/Base.xcconfig: Added LINKER_DISPLAYS_MANGLED_NAMES
     20
     21        * DumpRenderTree/ForwardingHeaders/wtf/Locker.h: Added.
     22        * DumpRenderTree/ForwardingHeaders/wtf/Threading.h: Added.
     23
     24        * DumpRenderTree/Watchdog.cpp: Added.
     25        (Watchdog::Watchdog):
     26        (Watchdog::~Watchdog):
     27        (Watchdog::start):
     28        (Watchdog::stop):
     29        (Watchdog::checkIn):
     30        (Watchdog::setWatchdogInterval):
     31        (Watchdog::handleHang):
     32        (Watchdog::watchdogThreadStart):
     33        (Watchdog::watchdogThread):
     34        * DumpRenderTree/Watchdog.h: Added.
     35
     36        * DumpRenderTree/mac/WatchdogMac.h: Added.
     37        * DumpRenderTree/mac/WatchdogMac.mm: Added.
     38        (WatchdogMac::handleHang): Sample the process and write it out to a file
     39
     40        * DumpRenderTree/mac/DumpRenderTree.mm:
     41        (dumpRenderTree): Setup and start the watchdog before running any tests
     42        (runTest): Checkin with the watchdog after each test
     43
    1442008-03-05  Alp Toker  <alp@atoker.com>
    245
  • trunk/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj

    r29396 r30849  
    3535                1AC6C84A0D07638600CD3161 /* PluginObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C7800D07589B00CD3161 /* PluginObject.cpp */; };
    3636                1AC6C84B0D07638600CD3161 /* TestObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C7810D07589B00CD3161 /* TestObject.cpp */; };
     37                5199B2DA0D7F8A5200CFE8D7 /* WatchdogMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5199B2D90D7F8A5200CFE8D7 /* WatchdogMac.mm */; };
     38                5199B2DF0D7F8A9A00CFE8D7 /* Watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5199B2DD0D7F8A9A00CFE8D7 /* Watchdog.cpp */; };
     39                5199B2E00D7F8A9A00CFE8D7 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = 5199B2DE0D7F8A9A00CFE8D7 /* Watchdog.h */; };
    3740                9340994C08540CAE007F3BC8 /* DumpRenderTreePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = 32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */; };
    3841                9340995108540CAE007F3BC8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9335435F03D75502008635CE /* WebKit.framework */; };
     
    129132                1AC6C7810D07589B00CD3161 /* TestObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestObject.cpp; sourceTree = "<group>"; };
    130133                32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTreePrefix.h; sourceTree = "<group>"; };
     134                5199B2C80D7F876F00CFE8D7 /* WatchdogMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WatchdogMac.h; path = mac/WatchdogMac.h; sourceTree = "<group>"; };
     135                5199B2D90D7F8A5200CFE8D7 /* WatchdogMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WatchdogMac.mm; path = mac/WatchdogMac.mm; sourceTree = "<group>"; };
     136                5199B2DD0D7F8A9A00CFE8D7 /* Watchdog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Watchdog.cpp; sourceTree = "<group>"; };
     137                5199B2DE0D7F8A9A00CFE8D7 /* Watchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Watchdog.h; sourceTree = "<group>"; };
    131138                9335435F03D75502008635CE /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    132139                9340995408540CAF007F3BC8 /* DumpRenderTree */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DumpRenderTree; sourceTree = BUILT_PRODUCTS_DIR; };
     
    248255                                BCA18B730C9B08F100114369 /* DumpRenderTreeDraggingInfo.h */,
    249256                                BCA18B740C9B08F100114369 /* DumpRenderTreeDraggingInfo.mm */,
     257                                5199B2DE0D7F8A9A00CFE8D7 /* Watchdog.h */,
     258                                5199B2DD0D7F8A9A00CFE8D7 /* Watchdog.cpp */,
     259                                5199B2C80D7F876F00CFE8D7 /* WatchdogMac.h */,
     260                                5199B2D90D7F8A5200CFE8D7 /* WatchdogMac.mm */,
    250261                                BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */,
    251262                                BC9D90220C97472E0099A4A3 /* WorkQueue.h */,
     
    434445                                BCB284D00CFA83CC007E533E /* PixelDumpSupportCG.h in Headers */,
    435446                                BC47412A0D038A4C0072B006 /* JavaScriptThreading.h in Headers */,
     447                                5199B2E00D7F8A9A00CFE8D7 /* Watchdog.h in Headers */,
    436448                        );
    437449                        runOnlyForDeploymentPostprocessing = 0;
     
    574586                                BCB284D60CFA83D1007E533E /* PixelDumpSupportMac.mm in Sources */,
    575587                                BC4741410D038A570072B006 /* JavaScriptThreadingPthreads.cpp in Sources */,
     588                                5199B2DA0D7F8A5200CFE8D7 /* WatchdogMac.mm in Sources */,
     589                                5199B2DF0D7F8A9A00CFE8D7 /* Watchdog.cpp in Sources */,
    576590                        );
    577591                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKitTools/DumpRenderTree/mac/Configurations/Base.xcconfig

    r30701 r30849  
    1515WARNING_CFLAGS = -Wall -W -Wno-unused-parameter
    1616VALID_ARCHS = ppc7400 ppc970 i386 ppc
     17LINKER_DISPLAYS_MANGLED_NAMES = YES;
  • trunk/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm

    r30666 r30849  
    4545#import "ResourceLoadDelegate.h"
    4646#import "UIDelegate.h"
     47#import "WatchdogMac.h"
    4748#import "WorkQueue.h"
    4849#import "WorkQueueItem.h"
     
    7071#import <wtf/Assertions.h>
    7172#import <wtf/RetainPtr.h>
     73#import <wtf/OwnPtr.h>
    7274
    7375@interface DumpRenderTreeEvent : NSEvent
     
    98100CFMutableSetRef disallowedURLs = 0;
    99101CFRunLoopTimerRef waitToDumpWatchdog = 0;
     102OwnPtr<Watchdog> watchdog;
    100103
    101104// Delegates
     
    409412        startJavaScriptThreads();
    410413
     414    watchdog.set(new WatchdogMac());
     415    watchdog->start();
     416
    411417    if (useLongRunningServerMode(argc, argv)) {
    412418        printSeparators = YES;
     
    417423            runTest(argv[i]);
    418424    }
     425    watchdog->stop();
     426    watchdog.clear();
    419427
    420428    if (threaded)
     
    910918    if (_shouldIgnoreWebCoreNodeLeaks)
    911919        [WebCoreStatistics stopIgnoringWebCoreNodeLeaks];
     920       
     921    // Check-in with the watchdog after every test is complete
     922    watchdog->checkIn();
    912923}
    913924
Note: See TracChangeset for help on using the changeset viewer.