Changeset 148639 in webkit
- Timestamp:
- Apr 17, 2013 3:37:45 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 added
- 1 deleted
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSContextRef.cpp
r147858 r148639 78 78 79 79 wtfThreadData().setCurrentIdentifierTable(savedIdentifierTable); 80 } 81 82 static bool internalScriptTimeoutCallback(ExecState* exec, void* callbackPtr, void* callbackData) 83 { 84 JSShouldTerminateCallback callback = reinterpret_cast<JSShouldTerminateCallback>(callbackPtr); 85 JSContextRef contextRef = toRef(exec); 86 return callback(contextRef, callbackData); 87 } 88 89 void JSContextGroupSetExecutionTimeLimit(JSContextGroupRef group, double limit, JSShouldTerminateCallback callback, void* callbackData) 90 { 91 JSGlobalData& globalData = *toJS(group); 92 APIEntryShim entryShim(&globalData); 93 Watchdog& watchdog = globalData.watchdog; 94 void* callbackPtr = reinterpret_cast<void*>(callback); 95 watchdog.setTimeLimit(globalData, limit, internalScriptTimeoutCallback, callbackPtr, callbackData); 96 } 97 98 void JSContextGroupClearExecutionTimeLimit(JSContextGroupRef group) 99 { 100 JSGlobalData& globalData = *toJS(group); 101 APIEntryShim entryShim(&globalData); 102 Watchdog& watchdog = globalData.watchdog; 103 watchdog.setTimeLimit(globalData, std::numeric_limits<double>::infinity()); 80 104 } 81 105 -
trunk/Source/JavaScriptCore/API/JSContextRefPrivate.h
r95901 r148639 56 56 JS_EXPORT JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize) AVAILABLE_IN_WEBKIT_VERSION_4_0; 57 57 58 59 /*! 60 @typedef JSShouldTerminateCallback 61 @abstract The callback invoked when script execution has exceeded the allowed 62 time limit previously specified via JSContextGroupSetExecutionTimeLimit. 63 @param ctx The execution context to use. 64 @param context User specified context data previously passed to 65 JSContextGroupSetExecutionTimeLimit. 66 @discussion If you named your function Callback, you would declare it like this: 67 68 bool Callback(JSContextRef ctx, void* context); 69 70 If you return true, the timed out script will terminate. 71 If you return false, the script will run for another period of the allowed 72 time limit specified via JSContextGroupSetExecutionTimeLimit. 73 74 Within this callback function, you may call JSContextGroupSetExecutionTimeLimit 75 to set a new time limit, or JSContextGroupClearExecutionTimeLimit to cancel the 76 timeout. 77 */ 78 typedef bool 79 (*JSShouldTerminateCallback) (JSContextRef ctx, void* context); 80 81 /*! 82 @function 83 @abstract Sets the script execution time limit. 84 @param group The JavaScript context group that this time limit applies to. 85 @param limit The time limit of allowed script execution time in seconds. 86 @param callback The callback function that will be invoked when the time limit 87 has been reached. This will give you a chance to decide if you want to 88 terminate the script or not. If you pass a NULL callback, the script will be 89 terminated unconditionally when the time limit has been reached. 90 @param context User data that you can provide to be passed back to you 91 in your callback. 92 93 In order to guarantee that the execution time limit will take effect, you will 94 need to call JSContextGroupSetExecutionTimeLimit before you start executing 95 any scripts. 96 */ 97 JS_EXPORT void JSContextGroupSetExecutionTimeLimit(JSContextGroupRef, double limit, JSShouldTerminateCallback, void* context) AVAILABLE_IN_WEBKIT_VERSION_4_0; 98 99 /*! 100 @function 101 @abstract Clears the script execution time limit. 102 @param group The JavaScript context group that the time limit is cleared on. 103 */ 104 JS_EXPORT void JSContextGroupClearExecutionTimeLimit(JSContextGroupRef) AVAILABLE_IN_WEBKIT_VERSION_4_0; 105 58 106 #ifdef __cplusplus 59 107 } -
trunk/Source/JavaScriptCore/API/tests/testapi.c
r148162 r148639 34 34 #include <wtf/UnusedParam.h> 35 35 36 #if PLATFORM(MAC) || PLATFORM(IOS) 37 #include <mach/mach.h> 38 #include <mach/mach_time.h> 39 #include <sys/time.h> 40 #endif 41 36 42 #if OS(WINDOWS) 37 43 #include <windows.h> … … 1045 1051 val.name = "something"; 1046 1052 } 1053 1054 #if PLATFORM(MAC) || PLATFORM(IOS) 1055 static double currentCPUTime() 1056 { 1057 mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT; 1058 thread_basic_info_data_t info; 1059 1060 /* Get thread information */ 1061 mach_port_t threadPort = mach_thread_self(); 1062 thread_info(threadPort, THREAD_BASIC_INFO, (thread_info_t)(&info), &infoCount); 1063 mach_port_deallocate(mach_task_self(), threadPort); 1064 1065 double time = info.user_time.seconds + info.user_time.microseconds / 1000000.; 1066 time += info.system_time.seconds + info.system_time.microseconds / 1000000.; 1067 1068 return time; 1069 } 1070 1071 bool shouldTerminateCallbackWasCalled = false; 1072 static bool shouldTerminateCallback(JSContextRef ctx, void* context) 1073 { 1074 UNUSED_PARAM(ctx); 1075 UNUSED_PARAM(context); 1076 shouldTerminateCallbackWasCalled = true; 1077 return true; 1078 } 1079 1080 bool cancelTerminateCallbackWasCalled = false; 1081 static bool cancelTerminateCallback(JSContextRef ctx, void* context) 1082 { 1083 UNUSED_PARAM(ctx); 1084 UNUSED_PARAM(context); 1085 cancelTerminateCallbackWasCalled = true; 1086 return false; 1087 } 1088 1089 int extendTerminateCallbackCalled = 0; 1090 static bool extendTerminateCallback(JSContextRef ctx, void* context) 1091 { 1092 UNUSED_PARAM(context); 1093 extendTerminateCallbackCalled++; 1094 if (extendTerminateCallbackCalled == 1) { 1095 JSContextGroupRef contextGroup = JSContextGetGroup(ctx); 1096 JSContextGroupSetExecutionTimeLimit(contextGroup, 2, extendTerminateCallback, 0); 1097 return false; 1098 } 1099 return true; 1100 } 1101 #endif /* PLATFORM(MAC) || PLATFORM(IOS) */ 1102 1047 1103 1048 1104 int main(int argc, char* argv[]) … … 1693 1749 } 1694 1750 1751 #if PLATFORM(MAC) || PLATFORM(IOS) 1752 /* Test script timeout: */ 1753 JSContextGroupSetExecutionTimeLimit(contextGroup, 1, shouldTerminateCallback, 0); 1754 { 1755 const char* loopForeverScript = "startTime = Date.now(); try { while (true) { if (Date.now() - startTime > 5000) break; } } catch(e) { }"; 1756 JSStringRef script = JSStringCreateWithUTF8CString(loopForeverScript); 1757 double startTime; 1758 double endTime; 1759 exception = NULL; 1760 startTime = currentCPUTime(); 1761 v = JSEvaluateScript(context, script, NULL, NULL, 1, &exception); 1762 endTime = currentCPUTime(); 1763 1764 if (((endTime - startTime) < 2) && shouldTerminateCallbackWasCalled) 1765 printf("PASS: script timed out as expected.\n"); 1766 else { 1767 if (!((endTime - startTime) < 2)) 1768 printf("FAIL: script did not timed out as expected.\n"); 1769 if (!shouldTerminateCallbackWasCalled) 1770 printf("FAIL: script timeout callback was not called.\n"); 1771 failed = true; 1772 } 1773 1774 if (exception) 1775 printf("PASS: TerminationExecutionException was not catchable.\n"); 1776 else { 1777 printf("FAIL: TerminationExecutionException was caught.\n"); 1778 failed = true; 1779 } 1780 } 1781 1782 /* Test script timeout cancellation: */ 1783 JSContextGroupSetExecutionTimeLimit(contextGroup, 1, cancelTerminateCallback, 0); 1784 { 1785 const char* loopForeverScript = "startTime = Date.now(); try { while (true) { if (Date.now() - startTime > 5000) break; } } catch(e) { }"; 1786 JSStringRef script = JSStringCreateWithUTF8CString(loopForeverScript); 1787 double startTime; 1788 double endTime; 1789 exception = NULL; 1790 startTime = currentCPUTime(); 1791 v = JSEvaluateScript(context, script, NULL, NULL, 1, &exception); 1792 endTime = currentCPUTime(); 1793 1794 if (((endTime - startTime) >= 2) && cancelTerminateCallbackWasCalled && !exception) 1795 printf("PASS: script timeout was cancelled as expected.\n"); 1796 else { 1797 if (((endTime - startTime) < 2) || exception) 1798 printf("FAIL: script timeout was not cancelled.\n"); 1799 if (!cancelTerminateCallbackWasCalled) 1800 printf("FAIL: script timeout callback was not called.\n"); 1801 failed = true; 1802 } 1803 } 1804 1805 /* Test script timeout extension: */ 1806 JSContextGroupSetExecutionTimeLimit(contextGroup, 1, extendTerminateCallback, 0); 1807 { 1808 const char* loopForeverScript = "startTime = Date.now(); try { while (true) { if (Date.now() - startTime > 5000) break; } } catch(e) { }"; 1809 JSStringRef script = JSStringCreateWithUTF8CString(loopForeverScript); 1810 double startTime; 1811 double endTime; 1812 double deltaTime; 1813 exception = NULL; 1814 startTime = currentCPUTime(); 1815 v = JSEvaluateScript(context, script, NULL, NULL, 1, &exception); 1816 endTime = currentCPUTime(); 1817 deltaTime = endTime - startTime; 1818 1819 if ((deltaTime >= 3) && (deltaTime < 5) && (extendTerminateCallbackCalled == 2) && exception) 1820 printf("PASS: script timeout was extended as expected.\n"); 1821 else { 1822 if (deltaTime < 2) 1823 printf("FAIL: script timeout was not extended as expected.\n"); 1824 else if (deltaTime >= 5) 1825 printf("FAIL: script did not timeout.\n"); 1826 1827 if (extendTerminateCallbackCalled < 1) 1828 printf("FAIL: script timeout callback was not called.\n"); 1829 if (extendTerminateCallbackCalled < 2) 1830 printf("FAIL: script timeout callback was not called after timeout extension.\n"); 1831 1832 if (!exception) 1833 printf("FAIL: TerminationExecutionException was caught during timeout extension test.\n"); 1834 1835 failed = true; 1836 } 1837 } 1838 #endif /* PLATFORM(MAC) || PLATFORM(IOS) */ 1839 1695 1840 // Clear out local variables pointing at JSObjectRefs to allow their values to be collected 1696 1841 function = NULL; -
trunk/Source/JavaScriptCore/CMakeLists.txt
r148571 r148639 306 306 runtime/StructureChain.cpp 307 307 runtime/SymbolTable.cpp 308 runtime/Watchdog.cpp 309 runtime/WatchdogNone.cpp 308 310 309 311 tools/CodeProfile.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r148638 r148639 1 2013-04-17 Mark Lam <mark.lam@apple.com> 2 3 Add LLINT and baseline JIT support for timing out scripts. 4 https://bugs.webkit.org/show_bug.cgi?id=114577. 5 6 Reviewed by Geoffrey Garen. 7 8 Introduces the new Watchdog class which is used to track script 9 execution time, and initiate script termination if needed. 10 11 * API/JSContextRef.cpp: 12 (internalScriptTimeoutCallback): 13 (JSContextGroupSetExecutionTimeLimit): 14 (JSContextGroupClearExecutionTimeLimit): 15 * API/JSContextRefPrivate.h: 16 - Added new script execution time limit APIs. 17 * API/tests/testapi.c: 18 (currentCPUTime): 19 (shouldTerminateCallback): 20 (cancelTerminateCallback): 21 (extendTerminateCallback): 22 (main): 23 - Added new API tests for script execution time limit. 24 * CMakeLists.txt: 25 * GNUmakefile.list.am: 26 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: 27 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: 28 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: 29 * JavaScriptCore.xcodeproj/project.pbxproj: 30 * Target.pri: 31 * bytecompiler/BytecodeGenerator.cpp: 32 (JSC::BytecodeGenerator::emitLoopHint): 33 - loop hints are needed for the llint as well. Hence, it will be 34 emitted unconditionally. 35 * interpreter/Interpreter.cpp: 36 (JSC::Interpreter::addStackTraceIfNecessary): 37 (JSC::Interpreter::throwException): 38 (JSC::Interpreter::execute): 39 (JSC::Interpreter::executeCall): 40 (JSC::Interpreter::executeConstruct): 41 - Added checks for script termination before entering script code. 42 * jit/JIT.cpp: 43 (JSC::JIT::emitWatchdogTimerCheck): 44 * jit/JIT.h: 45 (JSC::JIT::emit_op_loop_hint): 46 * jit/JITStubs.cpp: 47 (JSC::DEFINE_STUB_FUNCTION(void, handle_watchdog_timer)): 48 * jit/JITStubs.h: 49 * llint/LLIntExceptions.cpp: 50 (JSC::LLInt::doThrow): 51 - Factored out some common code from returnToThrow() and callToThrow(). 52 (JSC::LLInt::returnToThrow): 53 (JSC::LLInt::callToThrow): 54 * llint/LLIntSlowPaths.cpp: 55 (JSC::LLInt::LLINT_SLOW_PATH_DECL(slow_path_handle_watchdog_timer)): 56 * llint/LLIntSlowPaths.h: 57 * llint/LowLevelInterpreter.asm: 58 * llint/LowLevelInterpreter32_64.asm: 59 * llint/LowLevelInterpreter64.asm: 60 * runtime/ExceptionHelpers.cpp: 61 (JSC::throwTerminatedExecutionException): 62 - Also removed the now unused InterruptedExecutionException. 63 * runtime/ExceptionHelpers.h: 64 * runtime/JSGlobalData.cpp: 65 (JSC::JSGlobalData::JSGlobalData): 66 * runtime/JSGlobalData.h: 67 - Added watchdog, and removed the now obsolete Terminator. 68 * runtime/Terminator.h: Removed. 69 * runtime/Watchdog.cpp: Added. 70 (JSC::Watchdog::Watchdog): 71 (JSC::Watchdog::~Watchdog): 72 (JSC::Watchdog::setTimeLimit): 73 (JSC::Watchdog::didFire): 74 (JSC::Watchdog::isEnabled): 75 (JSC::Watchdog::fire): 76 (JSC::Watchdog::arm): 77 (JSC::Watchdog::disarm): 78 (JSC::Watchdog::startCountdownIfNeeded): 79 (JSC::Watchdog::startCountdown): 80 (JSC::Watchdog::stopCountdown): 81 (JSC::Watchdog::Scope::Scope): 82 (JSC::Watchdog::Scope::~Scope): 83 * runtime/Watchdog.h: Added. 84 (Watchdog): 85 (JSC::Watchdog::didFire): 86 (JSC::Watchdog::timerDidFireAddress): 87 (JSC::Watchdog::isArmed): 88 (Watchdog::Scope): 89 * runtime/WatchdogMac.cpp: Added. 90 (JSC::Watchdog::initTimer): 91 (JSC::Watchdog::destroyTimer): 92 (JSC::Watchdog::startTimer): 93 (JSC::Watchdog::stopTimer): 94 * runtime/WatchdogNone.cpp: Added. 95 (JSC::Watchdog::initTimer): 96 (JSC::Watchdog::destroyTimer): 97 (JSC::Watchdog::startTimer): 98 (JSC::Watchdog::stopTimer): 99 1 100 2013-04-14 Roger Fong <roger_fong@apple.com> 2 101 -
trunk/Source/JavaScriptCore/GNUmakefile.list.am
r148479 r148639 783 783 Source/JavaScriptCore/runtime/SymbolTable.cpp \ 784 784 Source/JavaScriptCore/runtime/SymbolTable.h \ 785 Source/JavaScriptCore/runtime/Terminator.h \786 785 Source/JavaScriptCore/runtime/Tracing.h \ 787 786 Source/JavaScriptCore/runtime/TypedArrayDescriptor.h \ 788 787 Source/JavaScriptCore/runtime/Uint16WithFraction.h \ 788 Source/JavaScriptCore/runtime/Watchdog.cpp \ 789 Source/JavaScriptCore/runtime/Watchdog.h \ 790 Source/JavaScriptCore/runtime/WatchdogNone.cpp \ 789 791 Source/JavaScriptCore/runtime/WeakGCMap.h \ 790 792 Source/JavaScriptCore/runtime/WeakRandom.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r148479 r148639 1371 1371 </File> 1372 1372 <File 1373 RelativePath="..\..\runtime\Terminator.h"1374 >1375 </File>1376 <File1377 1373 RelativePath="..\..\runtime\TypedArrayDescriptor.h" 1374 > 1375 </File> 1376 <File 1377 RelativePath="..\..\runtime\Watchdog.cpp" 1378 > 1379 </File> 1380 <File 1381 RelativePath="..\..\runtime\Watchdog.h" 1382 > 1383 </File> 1384 <File 1385 RelativePath="..\..\runtime\WatchdogNone.cpp" 1378 1386 > 1379 1387 </File> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r148479 r148639 371 371 <ClCompile Include="..\runtime\StructureRareData.cpp" /> 372 372 <ClCompile Include="..\runtime\SymbolTable.cpp" /> 373 <ClCompile Include="..\runtime\Watchdog.cpp" /> 374 <ClCompile Include="..\runtime\WatchdogNone.cpp" /> 373 375 <ClCompile Include="..\tools\CodeProfile.cpp" /> 374 376 <ClCompile Include="..\tools\CodeProfiling.cpp" /> … … 753 755 <ClInclude Include="..\runtime\StructureTransitionTable.h" /> 754 756 <ClInclude Include="..\runtime\SymbolTable.h" /> 755 <ClInclude Include="..\runtime\Terminator.h" />756 757 <ClInclude Include="..\runtime\Tracing.h" /> 757 758 <ClInclude Include="..\runtime\TypedArrayDescriptor.h" /> 758 759 <ClInclude Include="..\runtime\Uint16WithFraction.h" /> 760 <ClInclude Include="..\runtime\Watchdog.h" /> 759 761 <ClInclude Include="..\runtime\WeakGCMap.h" /> 760 762 <ClInclude Include="..\runtime\WeakRandom.h" /> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r148479 r148639 718 718 <Filter>runtime</Filter> 719 719 </ClCompile> 720 <ClCompile Include="..\runtime\Watchdog.cpp"> 721 <Filter>runtime</Filter> 722 </ClCompile> 723 <ClCompile Include="..\runtime\WatchdogNone.cpp"> 724 <Filter>runtime</Filter> 725 </ClCompile> 720 726 <ClCompile Include="..\tools\CodeProfile.cpp"> 721 727 <Filter>tools</Filter> … … 1791 1797 <Filter>runtime</Filter> 1792 1798 </ClInclude> 1793 <ClInclude Include="..\runtime\Terminator.h">1794 <Filter>runtime</Filter>1795 </ClInclude>1796 1799 <ClInclude Include="..\runtime\Tracing.h"> 1797 1800 <Filter>runtime</Filter> … … 1801 1804 </ClInclude> 1802 1805 <ClInclude Include="..\runtime\Uint16WithFraction.h"> 1806 <Filter>runtime</Filter> 1807 </ClInclude> 1808 <ClInclude Include="..\runtime\Watchdog.h"> 1803 1809 <Filter>runtime</Filter> 1804 1810 </ClInclude> -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r148479 r148639 661 661 969A079A0ED1D3AE00F1F681 /* Opcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 969A07940ED1D3AE00F1F681 /* Opcode.cpp */; }; 662 662 969A079B0ED1D3AE00F1F681 /* Opcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 969A07950ED1D3AE00F1F681 /* Opcode.h */; settings = {ATTRIBUTES = (Private, ); }; }; 663 971EDEA61169E0D3005E4262 /* Terminator.h in Headers */ = {isa = PBXBuildFile; fileRef = 97F6903A1169DF7F00A6BB46 /* Terminator.h */; settings = {ATTRIBUTES = (Private, ); }; };664 663 978801401471AD920041B016 /* JSDateMath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9788FC221471AD0C0068CE2D /* JSDateMath.cpp */; }; 665 664 978801411471AD920041B016 /* JSDateMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9788FC231471AD0C0068CE2D /* JSDateMath.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 872 871 FE4A332015BD2E07006F54F3 /* VMInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4A331E15BD2E07006F54F3 /* VMInspector.h */; settings = {ATTRIBUTES = (Private, ); }; }; 873 872 FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */; settings = {ATTRIBUTES = (Private, ); }; }; 873 FED94F2E171E3E2300BE77A4 /* Watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */; }; 874 FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); };}; 875 FED94F30171E3E2300BE77A4 /* WatchdogMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FED94F2D171E3E2300BE77A4 /* WatchdogMac.cpp */; }; 874 876 /* End PBXBuildFile section */ 875 877 … … 1583 1585 9788FC221471AD0C0068CE2D /* JSDateMath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDateMath.cpp; sourceTree = "<group>"; }; 1584 1586 9788FC231471AD0C0068CE2D /* JSDateMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDateMath.h; sourceTree = "<group>"; }; 1585 97F6903A1169DF7F00A6BB46 /* Terminator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Terminator.h; sourceTree = "<group>"; };1586 1587 A1712B3A11C7B212007A5315 /* RegExpCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExpCache.cpp; sourceTree = "<group>"; }; 1587 1588 A1712B3E11C7B228007A5315 /* RegExpCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpCache.h; sourceTree = "<group>"; }; … … 1814 1815 FE4A331E15BD2E07006F54F3 /* VMInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMInspector.h; sourceTree = "<group>"; }; 1815 1816 FED287B115EC9A5700DA8161 /* LLIntOpcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntOpcode.h; path = llint/LLIntOpcode.h; sourceTree = "<group>"; }; 1817 FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Watchdog.cpp; sourceTree = "<group>"; }; 1818 FED94F2C171E3E2300BE77A4 /* Watchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Watchdog.h; sourceTree = "<group>"; }; 1819 FED94F2D171E3E2300BE77A4 /* WatchdogMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WatchdogMac.cpp; sourceTree = "<group>"; }; 1816 1820 /* End PBXFileReference section */ 1817 1821 … … 2595 2599 0F919D2715856770004A4E7D /* SymbolTable.cpp */, 2596 2600 14A396A60CD2933100B5B4FF /* SymbolTable.h */, 2597 97F6903A1169DF7F00A6BB46 /* Terminator.h */,2598 2601 5D53726D0E1C546B0021E549 /* Tracing.d */, 2599 2602 5D53726E0E1C54880021E549 /* Tracing.h */, 2600 2603 0FEB3ECB16237F4700AB67AD /* TypedArrayDescriptor.h */, 2601 2604 866739D113BFDE710023D87C /* Uint16WithFraction.h */, 2605 FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */, 2606 FED94F2C171E3E2300BE77A4 /* Watchdog.h */, 2607 FED94F2D171E3E2300BE77A4 /* WatchdogMac.cpp */, 2602 2608 14BFCE6810CDB1FC00364CCE /* WeakGCMap.h */, 2603 2609 1420BE7A10AA6DDB00F455D2 /* WeakRandom.h */, … … 3095 3101 0F3B3A2C15475002003ED0FF /* DFGValidate.h in Headers */, 3096 3102 0F2BDC471522802500CD8910 /* DFGValueRecoveryOverride.h in Headers */, 3103 FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */, 3097 3104 0F2BDC481522802900CD8910 /* DFGValueSource.h in Headers */, 3098 3105 0F620174143FCD330068B77C /* DFGVariableAccessData.h in Headers */, … … 3377 3384 BC18C46B0E16F5CD00B34460 /* SymbolTable.h in Headers */, 3378 3385 A784A26411D16622005776AC /* SyntaxChecker.h in Headers */, 3379 971EDEA61169E0D3005E4262 /* Terminator.h in Headers */,3380 3386 0F572D4F16879FDD00E57FBD /* ThunkGenerator.h in Headers */, 3381 3387 A7386556118697B400540279 /* ThunkGenerators.h in Headers */, … … 4024 4030 14280841107EC0930013E7B2 /* RegExp.cpp in Sources */, 4025 4031 A1712B3B11C7B212007A5315 /* RegExpCache.cpp in Sources */, 4032 FED94F30171E3E2300BE77A4 /* WatchdogMac.cpp in Sources */, 4026 4033 8642C510151C06A90046D4EF /* RegExpCachedResult.cpp in Sources */, 4027 4034 14280842107EC0930013E7B2 /* RegExpConstructor.cpp in Sources */, … … 4061 4068 A76F279415F13C9600517D67 /* UnlinkedCodeBlock.cpp in Sources */, 4062 4069 FE4A331F15BD2E07006F54F3 /* VMInspector.cpp in Sources */, 4070 FED94F2E171E3E2300BE77A4 /* Watchdog.cpp in Sources */, 4063 4071 0FC81516140511B500CFA603 /* VTableSpectrum.cpp in Sources */, 4064 4072 0F919D2515853CE0004A4E7D /* Watchpoint.cpp in Sources */, -
trunk/Source/JavaScriptCore/Target.pri
r148479 r148639 325 325 runtime/StructureRareData.cpp \ 326 326 runtime/SymbolTable.cpp \ 327 runtime/Watchdog.cpp \ 328 runtime/WatchdogNone.cpp \ 327 329 tools/CodeProfile.cpp \ 328 330 tools/CodeProfiling.cpp \ -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r147892 r148639 656 656 void BytecodeGenerator::emitLoopHint() 657 657 { 658 #if ENABLE(DFG_JIT)659 658 emitOpcode(op_loop_hint); 660 #endif661 659 } 662 660 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r147872 r148639 768 768 JSObject* errorObject = asObject(error); 769 769 JSGlobalObject* globalObject = 0; 770 if (isTerminatedExecutionException(error) || isInterruptedExecutionException(error))770 if (isTerminatedExecutionException(error)) 771 771 globalObject = globalData->dynamicGlobalObject; 772 772 else … … 789 789 { 790 790 CodeBlock* codeBlock = callFrame->codeBlock(); 791 bool is Interrupt= false;791 bool isTermination = false; 792 792 793 793 ASSERT(!exceptionValue.isEmpty()); … … 811 811 } 812 812 813 is Interrupt = isInterruptedExecutionException(exception) ||isTerminatedExecutionException(exception);813 isTermination = isTerminatedExecutionException(exception); 814 814 } else { 815 815 if (!callFrame->globalData().exceptionStack.size()) { … … 828 828 // Calculate an exception handler vPC, unwinding call frames as necessary. 829 829 HandlerInfo* handler = 0; 830 while (is Interrupt|| !(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) {830 while (isTermination || !(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) { 831 831 if (!unwindCallFrame(callFrame, exceptionValue, bytecodeOffset, codeBlock)) { 832 832 if (LegacyProfiler* profiler = callFrame->globalData().enabledProfiler()) … … 1031 1031 // Execute the code: 1032 1032 JSValue result; 1033 {1033 if (LIKELY(!globalData.watchdog.didFire(newCallFrame))) { 1034 1034 SamplingTool::CallRecord callRecord(m_sampler.get()); 1035 Watchdog::Scope watchdogScope(globalData.watchdog); 1035 1036 1036 1037 #if ENABLE(LLINT_C_LOOP) … … 1039 1040 result = program->generatedJITCode().execute(&m_stack, newCallFrame, &globalData); 1040 1041 #endif // ENABLE(JIT) 1041 } 1042 } else 1043 result = throwTerminatedExecutionException(newCallFrame); 1042 1044 1043 1045 if (LegacyProfiler* profiler = globalData.enabledProfiler()) … … 1101 1103 1102 1104 JSValue result; 1103 {1105 if (LIKELY(!globalData.watchdog.didFire(newCallFrame))) { 1104 1106 SamplingTool::CallRecord callRecord(m_sampler.get(), !isJSCall); 1107 Watchdog::Scope watchdogScope(globalData.watchdog); 1105 1108 1106 1109 // Execute the code: … … 1113 1116 } else 1114 1117 result = JSValue::decode(callData.native.function(newCallFrame)); 1115 } 1118 } else 1119 result = throwTerminatedExecutionException(newCallFrame); 1116 1120 1117 1121 if (LegacyProfiler* profiler = globalData.enabledProfiler()) … … 1176 1180 1177 1181 JSValue result; 1178 {1182 if (LIKELY(!globalData.watchdog.didFire(newCallFrame))) { 1179 1183 SamplingTool::CallRecord callRecord(m_sampler.get(), !isJSConstruct); 1184 Watchdog::Scope watchdogScope(globalData.watchdog); 1180 1185 1181 1186 // Execute the code. … … 1186 1191 result = constructData.js.functionExecutable->generatedJITCodeForConstruct().execute(&m_stack, newCallFrame, &globalData); 1187 1192 #endif // ENABLE(JIT) 1188 } else {1193 } else 1189 1194 result = JSValue::decode(constructData.native.function(newCallFrame)); 1190 }1191 }1195 } else 1196 result = throwTerminatedExecutionException(newCallFrame); 1192 1197 1193 1198 if (LegacyProfiler* profiler = globalData.enabledProfiler()) … … 1273 1278 // Execute the code: 1274 1279 JSValue result; 1275 {1280 if (LIKELY(!globalData.watchdog.didFire(closure.newCallFrame))) { 1276 1281 SamplingTool::CallRecord callRecord(m_sampler.get()); 1277 1282 Watchdog::Scope watchdogScope(globalData.watchdog); 1283 1278 1284 #if ENABLE(LLINT_C_LOOP) 1279 1285 result = LLInt::CLoop::execute(closure.newCallFrame, llint_function_for_call_prologue); … … 1281 1287 result = closure.functionExecutable->generatedJITCodeForCall().execute(&m_stack, closure.newCallFrame, &globalData); 1282 1288 #endif // ENABLE(JIT) 1283 } 1289 } else 1290 result = throwTerminatedExecutionException(closure.newCallFrame); 1284 1291 1285 1292 if (LegacyProfiler* profiler = globalData.enabledProfiler()) … … 1369 1376 // Execute the code: 1370 1377 JSValue result; 1371 {1378 if (LIKELY(!globalData.watchdog.didFire(newCallFrame))) { 1372 1379 SamplingTool::CallRecord callRecord(m_sampler.get()); 1373 1380 Watchdog::Scope watchdogScope(globalData.watchdog); 1381 1374 1382 #if ENABLE(LLINT_C_LOOP) 1375 1383 result = LLInt::CLoop::execute(newCallFrame, llint_eval_prologue); … … 1377 1385 result = eval->generatedJITCode().execute(&m_stack, newCallFrame, &globalData); 1378 1386 #endif // ENABLE(JIT) 1379 } 1387 } else 1388 result = throwTerminatedExecutionException(newCallFrame); 1380 1389 1381 1390 if (LegacyProfiler* profiler = globalData.enabledProfiler()) -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r148119 r148639 118 118 } 119 119 #endif 120 121 void JIT::emitWatchdogTimerCheck() 122 { 123 if (!m_globalData->watchdog.isEnabled()) 124 return; 125 126 Jump skipCheck = branchTest8(Zero, AbsoluteAddress(m_globalData->watchdog.timerDidFireAddress())); 127 JITStubCall stubCall(this, cti_handle_watchdog_timer); 128 stubCall.call(); 129 skipCheck.link(this); 130 } 120 131 121 132 #define NEXT_OPCODE(name) \ -
trunk/Source/JavaScriptCore/jit/JIT.h
r148119 r148639 859 859 void emitOptimizationCheck(OptimizationCheckKind) { } 860 860 #endif 861 861 void emitWatchdogTimerCheck(); 862 862 863 #ifndef NDEBUG 863 864 void printBytecodeOperandTypes(unsigned src1, unsigned src2); … … 946 947 inline void JIT::emit_op_loop_hint(Instruction*) 947 948 { 949 emitWatchdogTimerCheck(); 948 950 emitOptimizationCheck(LoopOptimizationCheck); 949 951 } -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r148474 r148639 1374 1374 CHECK_FOR_EXCEPTION_AT_END(); 1375 1375 return JSValue::encode(result); 1376 } 1377 1378 DEFINE_STUB_FUNCTION(void, handle_watchdog_timer) 1379 { 1380 STUB_INIT_STACK_FRAME(stackFrame); 1381 CallFrame* callFrame = stackFrame.callFrame; 1382 JSGlobalData* globalData = stackFrame.globalData; 1383 if (UNLIKELY(globalData->watchdog.didFire(callFrame))) { 1384 globalData->exception = createTerminatedExecutionException(globalData); 1385 VM_THROW_EXCEPTION_AT_END(); 1386 return; 1387 } 1376 1388 } 1377 1389 -
trunk/Source/JavaScriptCore/jit/JITStubs.h
r148119 r148639 407 407 int JIT_STUB cti_op_jtrue(STUB_ARGS_DECLARATION) WTF_INTERNAL; 408 408 void* JIT_STUB cti_op_load_varargs(STUB_ARGS_DECLARATION) WTF_INTERNAL; 409 void JIT_STUB cti_handle_watchdog_timer(STUB_ARGS_DECLARATION) WTF_INTERNAL; 409 410 int JIT_STUB cti_has_property(STUB_ARGS_DECLARATION) WTF_INTERNAL; 410 411 void JIT_STUB cti_op_debug(STUB_ARGS_DECLARATION) WTF_INTERNAL; -
trunk/Source/JavaScriptCore/llint/LLIntExceptions.cpp
r139541 r148639 66 66 } 67 67 68 Instruction* returnToThrow(ExecState* exec, Instruction* pc)68 static void doThrow(ExecState* exec, Instruction* pc) 69 69 { 70 70 JSGlobalData* globalData = &exec->globalData(); 71 71 NativeCallFrameTracer tracer(globalData, exec); 72 fixupPCforExceptionIfNeeded(exec); 73 genericThrow(globalData, exec, globalData->exception, pc - exec->codeBlock()->instructions().begin()); 74 } 75 76 Instruction* returnToThrow(ExecState* exec, Instruction* pc) 77 { 72 78 #if LLINT_SLOW_PATH_TRACING 79 JSGlobalData* globalData = &exec->globalData(); 73 80 dataLog("Throwing exception ", globalData->exception, " (returnToThrow).\n"); 74 81 #endif 75 fixupPCforExceptionIfNeeded(exec); 76 genericThrow(globalData, exec, globalData->exception, pc - exec->codeBlock()->instructions().begin()); 77 82 doThrow(exec, pc); 78 83 return LLInt::exceptionInstructions(); 79 84 } … … 81 86 void* callToThrow(ExecState* exec, Instruction* pc) 82 87 { 88 #if LLINT_SLOW_PATH_TRACING 83 89 JSGlobalData* globalData = &exec->globalData(); 84 NativeCallFrameTracer tracer(globalData, exec);85 #if LLINT_SLOW_PATH_TRACING86 90 dataLog("Throwing exception ", globalData->exception, " (callToThrow).\n"); 87 91 #endif 88 fixupPCforExceptionIfNeeded(exec); 89 genericThrow(globalData, exec, globalData->exception, pc - exec->codeBlock()->instructions().begin()); 90 92 doThrow(exec, pc); 91 93 return LLInt::getCodePtr(llint_throw_during_call_trampoline); 92 94 } -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r147947 r148639 1629 1629 } 1630 1630 1631 LLINT_SLOW_PATH_DECL(slow_path_handle_watchdog_timer) 1632 { 1633 LLINT_BEGIN_NO_SET_PC(); 1634 if (UNLIKELY(globalData.watchdog.didFire(exec))) 1635 LLINT_THROW(createTerminatedExecutionException(&globalData)); 1636 LLINT_RETURN_TWO(0, exec); 1637 } 1638 1631 1639 LLINT_SLOW_PATH_DECL(slow_path_debug) 1632 1640 { -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.h
r147184 r148639 205 205 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_throw); 206 206 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_throw_static_error); 207 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_handle_watchdog_timer); 207 208 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_debug); 208 209 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_profile_will_call); -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r148474 r148639 1058 1058 _llint_op_loop_hint: 1059 1059 traceExecution() 1060 loadp JITStackFrame::globalData[sp], t1 1061 loadb JSGlobalData::watchdog+Watchdog::m_timerDidFire[t1], t0 1062 btbnz t0, .handleWatchdogTimer 1063 .afterWatchdogTimerCheck: 1060 1064 checkSwitchToJITForLoop() 1061 1065 dispatch(1) 1062 1066 .handleWatchdogTimer: 1067 callWatchdogTimerHandler() 1068 jmp .afterWatchdogTimerCheck 1063 1069 1064 1070 _llint_op_switch_string: -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
r148474 r148639 184 184 move t1, cfr 185 185 action(t0) 186 end 187 188 macro callWatchdogTimerHandler() 189 storei PC, ArgumentCount + TagOffset[cfr] 190 cCall2(_llint_slow_path_handle_watchdog_timer, cfr, PC) 191 move t1, cfr 192 btpnz t0, _llint_throw_from_slow_path_trampoline 193 loadi ArgumentCount + TagOffset[cfr], PC 186 194 end 187 195 -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r147190 r148639 125 125 move t1, cfr 126 126 action(t0) 127 end 128 129 macro callWatchdogTimerHandler() 130 storei PC, ArgumentCount + TagOffset[cfr] 131 prepareStateForCCall() 132 cCall2(_llint_slow_path_handle_watchdog_timer, cfr, PC) 133 move t1, cfr 134 btpnz t0, _llint_throw_from_slow_path_trampoline 135 move t3, PB 136 loadi ArgumentCount + TagOffset[cfr], PC 127 137 end 128 138 -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
r139541 r148639 41 41 42 42 namespace JSC { 43 44 ASSERT_HAS_TRIVIAL_DESTRUCTOR(InterruptedExecutionError);45 46 const ClassInfo InterruptedExecutionError::s_info = { "InterruptedExecutionError", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(InterruptedExecutionError) };47 48 JSValue InterruptedExecutionError::defaultValue(const JSObject*, ExecState* exec, PreferredPrimitiveType hint)49 {50 if (hint == PreferString)51 return jsNontrivialString(exec, String(ASCIILiteral("JavaScript execution exceeded timeout.")));52 return JSValue(QNaN);53 }54 55 JSObject* createInterruptedExecutionException(JSGlobalData* globalData)56 {57 return InterruptedExecutionError::create(*globalData);58 }59 60 bool isInterruptedExecutionException(JSObject* object)61 {62 return object->inherits(&InterruptedExecutionError::s_info);63 }64 65 bool isInterruptedExecutionException(JSValue value)66 {67 return value.inherits(&InterruptedExecutionError::s_info);68 }69 70 43 71 44 ASSERT_HAS_TRIVIAL_DESTRUCTOR(TerminatedExecutionError); … … 169 142 } 170 143 144 JSObject* throwTerminatedExecutionException(ExecState* exec) 145 { 146 Interpreter::ErrorHandlingMode mode(exec); 147 return throwError(exec, createTerminatedExecutionException(&exec->globalData())); 148 } 149 171 150 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h
r127191 r148639 34 34 namespace JSC { 35 35 36 JS_EXPORT_PRIVATE JSObject* createInterruptedExecutionException(JSGlobalData*);37 bool isInterruptedExecutionException(JSObject*);38 bool isInterruptedExecutionException(JSValue);39 40 36 JSObject* createTerminatedExecutionException(JSGlobalData*); 41 37 bool isTerminatedExecutionException(JSObject*); … … 54 50 JSObject* throwOutOfMemoryError(ExecState*); 55 51 JSObject* throwStackOverflowError(ExecState*); 52 JSObject* throwTerminatedExecutionException(ExecState*); 56 53 57 58 class InterruptedExecutionError : public JSNonFinalObject {59 private:60 InterruptedExecutionError(JSGlobalData& globalData)61 : JSNonFinalObject(globalData, globalData.interruptedExecutionErrorStructure.get())62 {63 }64 65 static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);66 67 public:68 typedef JSNonFinalObject Base;69 70 static InterruptedExecutionError* create(JSGlobalData& globalData)71 {72 InterruptedExecutionError* error = new (NotNull, allocateCell<InterruptedExecutionError>(globalData.heap)) InterruptedExecutionError(globalData);73 error->finishCreation(globalData);74 return error;75 }76 77 static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)78 {79 return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);80 }81 82 static const ClassInfo s_info;83 };84 54 85 55 class TerminatedExecutionError : public JSNonFinalObject { -
trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp
r148616 r148639 205 205 structureRareDataStructure.set(*this, StructureRareData::createStructure(*this, 0, jsNull())); 206 206 debuggerActivationStructure.set(*this, DebuggerActivation::createStructure(*this, 0, jsNull())); 207 interruptedExecutionErrorStructure.set(*this, InterruptedExecutionError::createStructure(*this, 0, jsNull()));208 207 terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull())); 209 208 stringStructure.set(*this, JSString::createStructure(*this, 0, jsNull())); -
trunk/Source/JavaScriptCore/runtime/JSGlobalData.h
r148568 r148639 47 47 #include "SmallStrings.h" 48 48 #include "Strong.h" 49 #include "Terminator.h"50 49 #include "ThunkGenerators.h" 51 50 #include "TypedArrayDescriptor.h" 51 #include "Watchdog.h" 52 52 #include "WeakRandom.h" 53 53 #include <wtf/BumpPointerAllocator.h> … … 212 212 ClientData* clientData; 213 213 ExecState* topCallFrame; 214 Watchdog watchdog; 214 215 215 216 const HashTable* arrayConstructorTable; … … 234 235 Strong<Structure> structureRareDataStructure; 235 236 Strong<Structure> debuggerActivationStructure; 236 Strong<Structure> interruptedExecutionErrorStructure;237 237 Strong<Structure> terminatedExecutionErrorStructure; 238 238 Strong<Structure> stringStructure; … … 325 325 #endif 326 326 NativeExecutable* getHostFunction(NativeFunction, NativeFunction constructor); 327 328 Terminator terminator;329 327 330 328 JSValue exception; -
trunk/Source/WTF/ChangeLog
r148625 r148639 1 2013-04-17 Mark Lam <mark.lam@apple.com> 2 3 Added currentCPUTime() and currentCPUTimeMS(). 4 https://bugs.webkit.org/show_bug.cgi?id=114577. 5 6 Reviewed by Geoffrey Garen. 7 8 The currentCPUTime() implementation came from the old TimeoutChecker.cpp. 9 10 * wtf/CurrentTime.cpp: 11 (WTF::currentCPUTime): 12 (WTF::currentCPUTimeMS): 13 * wtf/CurrentTime.h: 14 1 15 2013-04-17 Ryosuke Niwa <rniwa@webkit.org> 2 16 -
trunk/Source/WTF/wtf/CurrentTime.cpp
r147910 r148639 1 1 /* 2 * Copyright (C) 2006, 20 10 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Google Inc. All rights reserved. 4 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. 5 * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> 5 6 * 6 7 * Redistribution and use in source and binary forms, with or without … … 35 36 36 37 #if PLATFORM(MAC) 38 #include <mach/mach.h> 37 39 #include <mach/mach_time.h> 38 40 #include <sys/time.h> … … 332 334 #endif 333 335 336 double currentCPUTime() 337 { 338 #if OS(DARWIN) 339 mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT; 340 thread_basic_info_data_t info; 341 342 // Get thread information 343 mach_port_t threadPort = mach_thread_self(); 344 thread_info(threadPort, THREAD_BASIC_INFO, reinterpret_cast<thread_info_t>(&info), &infoCount); 345 mach_port_deallocate(mach_task_self(), threadPort); 346 347 double time = info.user_time.seconds + info.user_time.microseconds / 1000000.; 348 time += info.system_time.seconds + info.system_time.microseconds / 1000000.; 349 350 return time; 351 #elif OS(WINDOWS) 352 union { 353 FILETIME fileTime; 354 unsigned long long fileTimeAsLong; 355 } userTime, kernelTime; 356 357 // GetThreadTimes won't accept null arguments so we pass these even though 358 // they're not used. 359 FILETIME creationTime, exitTime; 360 361 GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime.fileTime, &userTime.fileTime); 362 363 return userTime.fileTimeAsLong / 10000000. + kernelTime.fileTimeAsLong / 10000000.; 364 #elif OS(QNX) 365 struct timespec time; 366 if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time)) 367 CRASH(); 368 return time.tv_sec + time.tv_nsec / 1.0e9; 369 #else 370 // FIXME: We should return the time the current thread has spent executing. 371 372 // use a relative time from first call in order to avoid an overflow 373 static double firstTime = currentTime(); 374 return currentTime() - firstTime; 375 #endif 376 } 377 378 double currentCPUTimeMS() 379 { 380 return currentCPUTime() * 1000; 381 } 382 334 383 } // namespace WTF -
trunk/Source/WTF/wtf/CurrentTime.h
r124560 r148639 52 52 WTF_EXPORT_PRIVATE double monotonicallyIncreasingTime(); 53 53 54 // Returns the current CPU time of the current thread in seconds. 55 // Precision varies depending on platform but is usually as good or better 56 // than a millisecond. 57 WTF_EXPORT_PRIVATE double currentCPUTime(); 58 59 // Returns the current CPU time of the current thread in milliseconds. 60 WTF_EXPORT_PRIVATE double currentCPUTimeMS(); 61 54 62 } // namespace WTF 55 63 … … 57 65 using WTF::currentTimeMS; 58 66 using WTF::monotonicallyIncreasingTime; 67 using WTF::currentCPUTime; 59 68 60 69 #endif // CurrentTime_h -
trunk/Source/WebCore/ChangeLog
r148636 r148639 1 2013-04-17 Mark Lam <mark.lam@apple.com> 2 3 Add LLINT and baseline JIT support for timing out scripts. 4 https://bugs.webkit.org/show_bug.cgi?id=114577. 5 6 Reviewed by Geoffrey Garen. 7 8 Replaced use of the obsolete JSGlobalData.terminator methods with the 9 JSGlobalData.watchdog equivalents. 10 11 * bindings/js/JSEventListener.cpp: 12 (WebCore::JSEventListener::handleEvent): 13 * bindings/js/SerializedScriptValue.cpp: 14 (WebCore::SerializedScriptValue::maybeThrowExceptionIfSerializationFailed): 15 * bindings/js/WorkerScriptController.cpp: 16 (WebCore::WorkerScriptController::evaluate): 17 (WebCore::WorkerScriptController::scheduleExecutionTermination): 18 (WebCore::WorkerScriptController::isExecutionTerminating): 19 1 20 2013-04-16 Jer Noble <jer.noble@apple.com> 2 21 -
trunk/Source/WebCore/bindings/js/JSEventListener.cpp
r148373 r148639 137 137 if (scriptExecutionContext->isWorkerContext()) { 138 138 bool terminatorCausedException = (exec->hadException() && isTerminatedExecutionException(exec->exception())); 139 if (terminatorCausedException || globalData. terminator.shouldTerminate())139 if (terminatorCausedException || globalData.watchdog.didFire()) 140 140 static_cast<WorkerContext*>(scriptExecutionContext)->script()->forbidExecution(); 141 141 } -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r148119 r148639 1903 1903 throwError(exec, createStackOverflowError(exec)); 1904 1904 break; 1905 case InterruptedExecutionError:1906 throwError(exec, createInterruptedExecutionException(&exec->globalData()));1907 break;1908 1905 case ValidationError: 1909 1906 throwError(exec, createTypeError(exec, "Unable to deserialize data.")); -
trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp
r148119 r148639 138 138 JSC::evaluate(exec, sourceCode.jsSourceCode(), m_workerContextWrapper.get(), &evaluationException); 139 139 140 if ((evaluationException && isTerminatedExecutionException(evaluationException)) || m_workerContextWrapper->globalData(). terminator.shouldTerminate()) {140 if ((evaluationException && isTerminatedExecutionException(evaluationException)) || m_workerContextWrapper->globalData().watchdog.didFire()) { 141 141 forbidExecution(); 142 142 return; … … 165 165 // accurately reflect that state when called from another thread. 166 166 MutexLocker locker(m_scheduledTerminationMutex); 167 m_globalData-> terminator.terminateSoon();167 m_globalData->watchdog.fire(); 168 168 } 169 169 … … 172 172 // See comments in scheduleExecutionTermination regarding mutex usage. 173 173 MutexLocker locker(m_scheduledTerminationMutex); 174 return m_globalData-> terminator.shouldTerminate();174 return m_globalData->watchdog.didFire(); 175 175 } 176 176
Note: See TracChangeset
for help on using the changeset viewer.