Changeset 105270 in webkit
- Timestamp:
- Jan 18, 2012 6:15:05 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r105267 r105270 1 2012-01-18 Roland Takacs <takacs.roland@stud.u-szeged.hu> 2 3 Cross-platform processor core counter 4 https://bugs.webkit.org/show_bug.cgi?id=76530 5 6 Reviewed by Zoltan Herczeg. 7 8 Two files have been created that include the processor core counter function. 9 It used to be in ParallelJobsGeneric.h/cpp before. 10 11 * GNUmakefile.list.am: 12 * JavaScriptCore.gypi: 13 * JavaScriptCore.vcproj/WTF/WTF.vcproj: 14 * JavaScriptCore.xcodeproj/project.pbxproj: 15 * runtime/Options.cpp: 16 (JSC::Options::initializeOptions): 17 * wtf/CMakeLists.txt: 18 * wtf/NumberOfCores.cpp: Added. 19 (WTF::numberOfProcessorCores): 20 * wtf/NumberOfCores.h: Added. 21 * wtf/ParallelJobsGeneric.cpp: 22 (WTF::ParallelEnvironment::ParallelEnvironment): 23 * wtf/ParallelJobsGeneric.h: 24 1 25 2012-01-18 Balazs Kelemen <kbalazs@webkit.org> 2 26 -
trunk/Source/JavaScriptCore/GNUmakefile.list.am
r105217 r105270 619 619 Source/JavaScriptCore/wtf/NotFound.h \ 620 620 Source/JavaScriptCore/wtf/NullPtr.h \ 621 Source/JavaScriptCore/wtf/NumberOfCores.cpp \ 622 Source/JavaScriptCore/wtf/NumberOfCores.h \ 621 623 Source/JavaScriptCore/wtf/OSAllocator.h \ 622 624 Source/JavaScriptCore/wtf/OSRandomSource.cpp \ -
trunk/Source/JavaScriptCore/JavaScriptCore.gypi
r105028 r105270 572 572 'wtf/MallocZoneSupport.h', 573 573 'wtf/NullPtr.cpp', 574 'wtf/NumberOfCores.cpp', 575 'wtf/NumberOfCores.h', 574 576 'wtf/OSAllocatorPosix.cpp', 575 577 'wtf/OSAllocatorWin.cpp', -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
r104315 r105270 950 950 </File> 951 951 <File 952 RelativePath="..\..\wtf\NumberOfCores.cpp" 953 > 954 </File> 955 <File 956 RelativePath="..\..\wtf\NumberOfCores.h" 957 > 958 </File> 959 <File 952 960 RelativePath="..\..\wtf\OSAllocatorWin.cpp" 953 961 > -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r105217 r105270 732 732 E4D8CEFB12FC439600BC9F5A /* BloomFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D8CE9B12FC42E100BC9F5A /* BloomFilter.h */; settings = {ATTRIBUTES = (Private, ); }; }; 733 733 F3BD31ED126735770065467F /* TextPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BD31D0126730180065467F /* TextPosition.h */; settings = {ATTRIBUTES = (Private, ); }; }; 734 F69E86C314C6E551002C2C62 /* NumberOfCores.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F69E86C114C6E551002C2C62 /* NumberOfCores.cpp */; }; 735 F69E86C414C6E551002C2C62 /* NumberOfCores.h in Headers */ = {isa = PBXBuildFile; fileRef = F69E86C214C6E551002C2C62 /* NumberOfCores.h */; }; 734 736 FDA15C1E12B0305C003A583A /* Complex.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA15C1612B03028003A583A /* Complex.h */; settings = {ATTRIBUTES = (Private, ); }; }; 735 737 FE1B447A0ECCD73B004F4DD1 /* StdLibExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1B44790ECCD73B004F4DD1 /* StdLibExtras.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1543 1545 F692A8860255597D01FF60F7 /* UString.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = UString.h; sourceTree = "<group>"; tabWidth = 8; }; 1544 1546 F692A8870255597D01FF60F7 /* JSValue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSValue.cpp; sourceTree = "<group>"; tabWidth = 8; }; 1547 F69E86C114C6E551002C2C62 /* NumberOfCores.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NumberOfCores.cpp; path = wtf/NumberOfCores.cpp; sourceTree = "<group>"; }; 1548 F69E86C214C6E551002C2C62 /* NumberOfCores.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NumberOfCores.h; path = wtf/NumberOfCores.h; sourceTree = "<group>"; }; 1545 1549 FDA15C1612B03028003A583A /* Complex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Complex.h; sourceTree = "<group>"; }; 1546 1550 FE1B44790ECCD73B004F4DD1 /* StdLibExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdLibExtras.h; sourceTree = "<group>"; }; … … 1623 1627 isa = PBXGroup; 1624 1628 children = ( 1629 F69E86C114C6E551002C2C62 /* NumberOfCores.cpp */, 1630 F69E86C214C6E551002C2C62 /* NumberOfCores.h */, 1625 1631 8604F4F2143A6C4400B295F5 /* ChangeLog */, 1626 1632 A718F8211178EB4B002465A7 /* create_regex_tables */, … … 3040 3046 0F7B294D14C3CD4C007C3DB1 /* DFGCommon.h in Headers */, 3041 3047 91A3905614C0F47200F67901 /* Uint8ClampedArray.h in Headers */, 3048 F69E86C414C6E551002C2C62 /* NumberOfCores.h in Headers */, 3042 3049 ); 3043 3050 runOnlyForDeploymentPostprocessing = 0; … … 3577 3584 0F0B83B014BCF71600885B4F /* CallLinkInfo.cpp in Sources */, 3578 3585 0F0B83B414BCF86000885B4F /* MethodCallLinkInfo.cpp in Sources */, 3586 F69E86C314C6E551002C2C62 /* NumberOfCores.cpp in Sources */, 3579 3587 ); 3580 3588 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r103286 r105270 28 28 29 29 #include <limits> 30 #include <wtf/NumberOfCores.h> 30 31 #include <wtf/PageBlock.h> 31 32 … … 175 176 176 177 int cpusToUse = 1; 177 #if OS(DARWIN) && ENABLE(PARALLEL_GC) 178 int name[2]; 179 size_t valueSize = sizeof(cpusToUse); 180 name[0] = CTL_HW; 181 name[1] = HW_AVAILCPU; 182 sysctl(name, 2, &cpusToUse, &valueSize, 0, 0); 178 #if ENABLE(PARALLEL_GC) 179 cpusToUse = WTF::numberOfProcessorCores(); 183 180 #endif 184 181 // We don't scale so well beyond 4. -
trunk/Source/JavaScriptCore/wtf/CMakeLists.txt
r104468 r105270 54 54 NotFound.h 55 55 NullPtr.h 56 NumberOfCores.h 56 57 OSAllocator.h 57 58 OSRandomSource.h … … 147 148 MD5.cpp 148 149 OSRandomSource.cpp 150 NumberOfCores.cpp 149 151 PageAllocationAligned.cpp 150 152 PageBlock.cpp -
trunk/Source/JavaScriptCore/wtf/ParallelJobsGeneric.cpp
r103003 r105270 32 32 #include "ParallelJobs.h" 33 33 #include "UnusedParam.h" 34 #include <wtf/NumberOfCores.h> 34 35 35 36 #if OS(DARWIN) || OS(OPENBSD) || OS(NETBSD) … … 46 47 Vector< RefPtr<ParallelEnvironment::ThreadPrivate> >* ParallelEnvironment::s_threadPool = 0; 47 48 48 int ParallelEnvironment::s_maxNumberOfParallelThreads = -1;49 50 49 ParallelEnvironment::ParallelEnvironment(ThreadFunction threadFunction, size_t sizeOfParameter, int requestedJobNumber) : 51 50 m_threadFunction(threadFunction), … … 54 53 ASSERT_ARG(requestedJobNumber, requestedJobNumber >= 1); 55 54 56 if (s_maxNumberOfParallelThreads == -1) 57 determineMaxNumberOfParallelThreads(); 55 int maxNumberOfCores = numberOfProcessorCores(); 58 56 59 if (!requestedJobNumber || requestedJobNumber > s_maxNumberOfParallelThreads)60 requestedJobNumber = static_cast<unsigned>( s_maxNumberOfParallelThreads);57 if (!requestedJobNumber || requestedJobNumber > maxNumberOfCores) 58 requestedJobNumber = static_cast<unsigned>(maxNumberOfCores); 61 59 62 60 if (!s_threadPool) … … 66 64 int maxNumberOfNewThreads = requestedJobNumber - 1; 67 65 68 for (int i = 0; i < s_maxNumberOfParallelThreads && m_threads.size() < static_cast<unsigned>(maxNumberOfNewThreads); ++i) {66 for (int i = 0; i < maxNumberOfCores && m_threads.size() < static_cast<unsigned>(maxNumberOfNewThreads); ++i) { 69 67 if (s_threadPool->size() < static_cast<unsigned>(i) + 1U) 70 68 s_threadPool->append(ThreadPrivate::create()); … … 92 90 for (i = 0; i < m_threads.size(); ++i) 93 91 m_threads[i]->waitForFinish(); 94 }95 96 void ParallelEnvironment::determineMaxNumberOfParallelThreads()97 {98 const int defaultIfUnavailable = 2;99 #if OS(DARWIN) || OS(OPENBSD) || OS(NETBSD)100 unsigned result;101 size_t length = sizeof(result);102 int name[] = {103 CTL_HW,104 HW_NCPU105 };106 int sysctlResult = sysctl(name, sizeof(name) / sizeof(int), &result, &length, 0, 0);107 s_maxNumberOfParallelThreads = sysctlResult < 0 ? defaultIfUnavailable : result;108 #elif OS(LINUX) || OS(AIX) || OS(SOLARIS)109 long sysconfResult = sysconf(_SC_NPROCESSORS_ONLN);110 s_maxNumberOfParallelThreads = sysconfResult < 0 ? defaultIfUnavailable : static_cast<int>(sysconfResult);111 #elif OS(WINDOWS)112 UNUSED_PARAM(defaultIfUnavailable);113 114 SYSTEM_INFO sysInfo;115 GetSystemInfo(&sysInfo);116 s_maxNumberOfParallelThreads = sysInfo.dwNumberOfProcessors;117 #else118 s_maxNumberOfParallelThreads = defaultIfUnavailable;119 #endif120 92 } 121 93 -
trunk/Source/JavaScriptCore/wtf/ParallelJobsGeneric.h
r102132 r105270 85 85 86 86 private: 87 static void determineMaxNumberOfParallelThreads();88 89 87 ThreadFunction m_threadFunction; 90 88 size_t m_sizeOfParameter; … … 93 91 Vector< RefPtr<ThreadPrivate> > m_threads; 94 92 static Vector< RefPtr<ThreadPrivate> >* s_threadPool; 95 static int s_maxNumberOfParallelThreads;96 93 }; 97 94 -
trunk/Source/WTF/ChangeLog
r105217 r105270 1 2012-01-18 Roland Takacs <takacs.roland@stud.u-szeged.hu> 2 3 Cross-platform processor core counter 4 https://bugs.webkit.org/show_bug.cgi?id=76530 5 6 Reviewed by Zoltan Herczeg. 7 8 Two files have been added to the project, namely NumberOfCores.h/cpp, 9 that include a CPU core number determining function. 10 11 * WTF.pro: 12 1 13 2012-01-17 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> 2 14 -
trunk/Source/WTF/WTF.pro
r105217 r105270 83 83 NotFound.h \ 84 84 NullPtr.h \ 85 NumberOfCores.h \ 85 86 OSAllocator.h \ 86 87 OSRandomSource.h \ … … 189 190 MetaAllocator.cpp \ 190 191 NullPtr.cpp \ 192 NumberOfCores.cpp \ 191 193 OSRandomSource.cpp \ 192 194 qt/MainThreadQt.cpp \
Note: See TracChangeset
for help on using the changeset viewer.