Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (105269 => 105270)
--- trunk/Source/_javascript_Core/ChangeLog 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-01-18 14:15:05 UTC (rev 105270)
@@ -1,3 +1,27 @@
+2012-01-18 Roland Takacs <takacs.rol...@stud.u-szeged.hu>
+
+ Cross-platform processor core counter
+ https://bugs.webkit.org/show_bug.cgi?id=76530
+
+ Reviewed by Zoltan Herczeg.
+
+ Two files have been created that include the processor core counter function.
+ It used to be in ParallelJobsGeneric.h/cpp before.
+
+ * GNUmakefile.list.am:
+ * _javascript_Core.gypi:
+ * _javascript_Core.vcproj/WTF/WTF.vcproj:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * runtime/Options.cpp:
+ (JSC::Options::initializeOptions):
+ * wtf/CMakeLists.txt:
+ * wtf/NumberOfCores.cpp: Added.
+ (WTF::numberOfProcessorCores):
+ * wtf/NumberOfCores.h: Added.
+ * wtf/ParallelJobsGeneric.cpp:
+ (WTF::ParallelEnvironment::ParallelEnvironment):
+ * wtf/ParallelJobsGeneric.h:
+
2012-01-18 Balazs Kelemen <kbal...@webkit.org>
[Qt] Consolidate layout test crash logging
Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (105269 => 105270)
--- trunk/Source/_javascript_Core/GNUmakefile.list.am 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am 2012-01-18 14:15:05 UTC (rev 105270)
@@ -618,6 +618,8 @@
Source/_javascript_Core/wtf/NonCopyingSort.h \
Source/_javascript_Core/wtf/NotFound.h \
Source/_javascript_Core/wtf/NullPtr.h \
+ Source/_javascript_Core/wtf/NumberOfCores.cpp \
+ Source/_javascript_Core/wtf/NumberOfCores.h \
Source/_javascript_Core/wtf/OSAllocator.h \
Source/_javascript_Core/wtf/OSRandomSource.cpp \
Source/_javascript_Core/wtf/OSRandomSource.h \
Modified: trunk/Source/_javascript_Core/_javascript_Core.gypi (105269 => 105270)
--- trunk/Source/_javascript_Core/_javascript_Core.gypi 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/_javascript_Core/_javascript_Core.gypi 2012-01-18 14:15:05 UTC (rev 105270)
@@ -571,6 +571,8 @@
'wtf/MainThread.cpp',
'wtf/MallocZoneSupport.h',
'wtf/NullPtr.cpp',
+ 'wtf/NumberOfCores.cpp',
+ 'wtf/NumberOfCores.h',
'wtf/OSAllocatorPosix.cpp',
'wtf/OSAllocatorWin.cpp',
'wtf/OSRandomSource.cpp',
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/WTF/WTF.vcproj (105269 => 105270)
--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/WTF/WTF.vcproj 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/WTF/WTF.vcproj 2012-01-18 14:15:05 UTC (rev 105270)
@@ -949,6 +949,14 @@
>
</File>
<File
+ RelativePath="..\..\wtf\NumberOfCores.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\wtf\NumberOfCores.h"
+ >
+ </File>
+ <File
RelativePath="..\..\wtf\OSAllocatorWin.cpp"
>
</File>
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (105269 => 105270)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2012-01-18 14:15:05 UTC (rev 105270)
@@ -731,6 +731,8 @@
E49DC16D12EF295300184A1F /* SourceProviderCacheItem.h in Headers */ = {isa = PBXBuildFile; fileRef = E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
E4D8CEFB12FC439600BC9F5A /* BloomFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D8CE9B12FC42E100BC9F5A /* BloomFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
F3BD31ED126735770065467F /* TextPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BD31D0126730180065467F /* TextPosition.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ F69E86C314C6E551002C2C62 /* NumberOfCores.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F69E86C114C6E551002C2C62 /* NumberOfCores.cpp */; };
+ F69E86C414C6E551002C2C62 /* NumberOfCores.h in Headers */ = {isa = PBXBuildFile; fileRef = F69E86C214C6E551002C2C62 /* NumberOfCores.h */; };
FDA15C1E12B0305C003A583A /* Complex.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA15C1612B03028003A583A /* Complex.h */; settings = {ATTRIBUTES = (Private, ); }; };
FE1B447A0ECCD73B004F4DD1 /* StdLibExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1B44790ECCD73B004F4DD1 /* StdLibExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
/* End PBXBuildFile section */
@@ -1542,6 +1544,8 @@
F692A8850255597D01FF60F7 /* UString.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UString.cpp; sourceTree = "<group>"; tabWidth = 8; };
F692A8860255597D01FF60F7 /* UString.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = UString.h; sourceTree = "<group>"; tabWidth = 8; };
F692A8870255597D01FF60F7 /* JSValue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSValue.cpp; sourceTree = "<group>"; tabWidth = 8; };
+ F69E86C114C6E551002C2C62 /* NumberOfCores.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NumberOfCores.cpp; path = wtf/NumberOfCores.cpp; sourceTree = "<group>"; };
+ F69E86C214C6E551002C2C62 /* NumberOfCores.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NumberOfCores.h; path = wtf/NumberOfCores.h; sourceTree = "<group>"; };
FDA15C1612B03028003A583A /* Complex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Complex.h; sourceTree = "<group>"; };
FE1B44790ECCD73B004F4DD1 /* StdLibExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdLibExtras.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -1622,6 +1626,8 @@
0867D691FE84028FC02AAC07 /* _javascript_Core */ = {
isa = PBXGroup;
children = (
+ F69E86C114C6E551002C2C62 /* NumberOfCores.cpp */,
+ F69E86C214C6E551002C2C62 /* NumberOfCores.h */,
8604F4F2143A6C4400B295F5 /* ChangeLog */,
A718F8211178EB4B002465A7 /* create_regex_tables */,
937B63CC09E766D200A671DD /* DerivedSources.make */,
@@ -3039,6 +3045,7 @@
0F7B294C14C3CD43007C3DB1 /* DFGByteCodeCache.h in Headers */,
0F7B294D14C3CD4C007C3DB1 /* DFGCommon.h in Headers */,
91A3905614C0F47200F67901 /* Uint8ClampedArray.h in Headers */,
+ F69E86C414C6E551002C2C62 /* NumberOfCores.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -3576,6 +3583,7 @@
0F46808314BA573100BFE272 /* JITExceptions.cpp in Sources */,
0F0B83B014BCF71600885B4F /* CallLinkInfo.cpp in Sources */,
0F0B83B414BCF86000885B4F /* MethodCallLinkInfo.cpp in Sources */,
+ F69E86C314C6E551002C2C62 /* NumberOfCores.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (105269 => 105270)
--- trunk/Source/_javascript_Core/runtime/Options.cpp 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp 2012-01-18 14:15:05 UTC (rev 105270)
@@ -27,6 +27,7 @@
#include "Options.h"
#include <limits>
+#include <wtf/NumberOfCores.h>
#include <wtf/PageBlock.h>
#if OS(DARWIN) && ENABLE(PARALLEL_GC)
@@ -174,12 +175,8 @@
SET(opaqueRootMergeThreshold, 1000);
int cpusToUse = 1;
-#if OS(DARWIN) && ENABLE(PARALLEL_GC)
- int name[2];
- size_t valueSize = sizeof(cpusToUse);
- name[0] = CTL_HW;
- name[1] = HW_AVAILCPU;
- sysctl(name, 2, &cpusToUse, &valueSize, 0, 0);
+#if ENABLE(PARALLEL_GC)
+ cpusToUse = WTF::numberOfProcessorCores();
#endif
// We don't scale so well beyond 4.
if (cpusToUse > 4)
Modified: trunk/Source/_javascript_Core/wtf/CMakeLists.txt (105269 => 105270)
--- trunk/Source/_javascript_Core/wtf/CMakeLists.txt 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/_javascript_Core/wtf/CMakeLists.txt 2012-01-18 14:15:05 UTC (rev 105270)
@@ -53,6 +53,7 @@
Noncopyable.h
NotFound.h
NullPtr.h
+ NumberOfCores.h
OSAllocator.h
OSRandomSource.h
OwnArrayPtr.h
@@ -146,6 +147,7 @@
MainThread.cpp
MD5.cpp
OSRandomSource.cpp
+ NumberOfCores.cpp
PageAllocationAligned.cpp
PageBlock.cpp
ParallelJobsGeneric.cpp
Added: trunk/Source/_javascript_Core/wtf/NumberOfCores.cpp (0 => 105270)
--- trunk/Source/_javascript_Core/wtf/NumberOfCores.cpp (rev 0)
+++ trunk/Source/_javascript_Core/wtf/NumberOfCores.cpp 2012-01-18 14:15:05 UTC (rev 105270)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2012 University of Szeged. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NumberOfCores.h"
+
+#if OS(DARWIN) || OS(OPENBSD) || OS(NETBSD)
+#include <sys/sysctl.h>
+#include <sys/types.h>
+#elif OS(LINUX) || OS(AIX) || OS(SOLARIS)
+#include <unistd.h>
+#elif OS(WINDOWS)
+#include <Windows.h>
+#include <wtf/UnusedParam.h>
+#endif
+
+namespace WTF {
+
+int numberOfProcessorCores()
+{
+ const int defaultIfUnavailable = 1;
+ static int s_numberOfCores = -1;
+
+ if (s_numberOfCores > 0)
+ return s_numberOfCores;
+
+#if OS(DARWIN) || OS(OPENBSD) || OS(NETBSD) || OS(FREEBSD)
+ unsigned result;
+ size_t length = sizeof(result);
+ int name[] = {
+ CTL_HW,
+ HW_NCPU
+ };
+ int sysctlResult = sysctl(name, sizeof(name) / sizeof(int), &result, &length, 0, 0);
+
+ s_numberOfCores = sysctlResult < 0 ? defaultIfUnavailable : result;
+#elif OS(LINUX) || OS(AIX) || OS(SOLARIS)
+ long sysconfResult = sysconf(_SC_NPROCESSORS_ONLN);
+
+ s_numberOfCores = sysconfResult < 0 ? defaultIfUnavailable : static_cast<int>(sysconfResult);
+#elif OS(WINDOWS)
+ UNUSED_PARAM(defaultIfUnavailable);
+ SYSTEM_INFO sysInfo;
+ GetSystemInfo(&sysInfo);
+
+ s_numberOfCores = sysInfo.dwNumberOfProcessors;
+#else
+ s_numberOfCores = defaultIfUnavailable;
+#endif
+ return s_numberOfCores;
+}
+
+}
Added: trunk/Source/_javascript_Core/wtf/NumberOfCores.h (0 => 105270)
--- trunk/Source/_javascript_Core/wtf/NumberOfCores.h (rev 0)
+++ trunk/Source/_javascript_Core/wtf/NumberOfCores.h 2012-01-18 14:15:05 UTC (rev 105270)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012 University of Szeged. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef NumberOfCores_h
+#define NumberOfCores_h
+
+namespace WTF {
+
+int numberOfProcessorCores();
+
+}
+
+#endif
Modified: trunk/Source/_javascript_Core/wtf/ParallelJobsGeneric.cpp (105269 => 105270)
--- trunk/Source/_javascript_Core/wtf/ParallelJobsGeneric.cpp 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/_javascript_Core/wtf/ParallelJobsGeneric.cpp 2012-01-18 14:15:05 UTC (rev 105270)
@@ -31,6 +31,7 @@
#include "ParallelJobs.h"
#include "UnusedParam.h"
+#include <wtf/NumberOfCores.h>
#if OS(DARWIN) || OS(OPENBSD) || OS(NETBSD)
#include <sys/sysctl.h>
@@ -45,19 +46,16 @@
Vector< RefPtr<ParallelEnvironment::ThreadPrivate> >* ParallelEnvironment::s_threadPool = 0;
-int ParallelEnvironment::s_maxNumberOfParallelThreads = -1;
-
ParallelEnvironment::ParallelEnvironment(ThreadFunction threadFunction, size_t sizeOfParameter, int requestedJobNumber) :
m_threadFunction(threadFunction),
m_sizeOfParameter(sizeOfParameter)
{
ASSERT_ARG(requestedJobNumber, requestedJobNumber >= 1);
- if (s_maxNumberOfParallelThreads == -1)
- determineMaxNumberOfParallelThreads();
+ int maxNumberOfCores = numberOfProcessorCores();
- if (!requestedJobNumber || requestedJobNumber > s_maxNumberOfParallelThreads)
- requestedJobNumber = static_cast<unsigned>(s_maxNumberOfParallelThreads);
+ if (!requestedJobNumber || requestedJobNumber > maxNumberOfCores)
+ requestedJobNumber = static_cast<unsigned>(maxNumberOfCores);
if (!s_threadPool)
s_threadPool = new Vector< RefPtr<ThreadPrivate> >();
@@ -65,7 +63,7 @@
// The main thread should be also a worker.
int maxNumberOfNewThreads = requestedJobNumber - 1;
- for (int i = 0; i < s_maxNumberOfParallelThreads && m_threads.size() < static_cast<unsigned>(maxNumberOfNewThreads); ++i) {
+ for (int i = 0; i < maxNumberOfCores && m_threads.size() < static_cast<unsigned>(maxNumberOfNewThreads); ++i) {
if (s_threadPool->size() < static_cast<unsigned>(i) + 1U)
s_threadPool->append(ThreadPrivate::create());
@@ -93,32 +91,6 @@
m_threads[i]->waitForFinish();
}
-void ParallelEnvironment::determineMaxNumberOfParallelThreads()
-{
- const int defaultIfUnavailable = 2;
-#if OS(DARWIN) || OS(OPENBSD) || OS(NETBSD)
- unsigned result;
- size_t length = sizeof(result);
- int name[] = {
- CTL_HW,
- HW_NCPU
- };
- int sysctlResult = sysctl(name, sizeof(name) / sizeof(int), &result, &length, 0, 0);
- s_maxNumberOfParallelThreads = sysctlResult < 0 ? defaultIfUnavailable : result;
-#elif OS(LINUX) || OS(AIX) || OS(SOLARIS)
- long sysconfResult = sysconf(_SC_NPROCESSORS_ONLN);
- s_maxNumberOfParallelThreads = sysconfResult < 0 ? defaultIfUnavailable : static_cast<int>(sysconfResult);
-#elif OS(WINDOWS)
- UNUSED_PARAM(defaultIfUnavailable);
-
- SYSTEM_INFO sysInfo;
- GetSystemInfo(&sysInfo);
- s_maxNumberOfParallelThreads = sysInfo.dwNumberOfProcessors;
-#else
- s_maxNumberOfParallelThreads = defaultIfUnavailable;
-#endif
-}
-
bool ParallelEnvironment::ThreadPrivate::tryLockFor(ParallelEnvironment* parent)
{
bool locked = m_mutex.tryLock();
Modified: trunk/Source/_javascript_Core/wtf/ParallelJobsGeneric.h (105269 => 105270)
--- trunk/Source/_javascript_Core/wtf/ParallelJobsGeneric.h 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/_javascript_Core/wtf/ParallelJobsGeneric.h 2012-01-18 14:15:05 UTC (rev 105270)
@@ -84,15 +84,12 @@
};
private:
- static void determineMaxNumberOfParallelThreads();
-
ThreadFunction m_threadFunction;
size_t m_sizeOfParameter;
int m_numberOfJobs;
Vector< RefPtr<ThreadPrivate> > m_threads;
static Vector< RefPtr<ThreadPrivate> >* s_threadPool;
- static int s_maxNumberOfParallelThreads;
};
} // namespace WTF
Modified: trunk/Source/WTF/ChangeLog (105269 => 105270)
--- trunk/Source/WTF/ChangeLog 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/WTF/ChangeLog 2012-01-18 14:15:05 UTC (rev 105270)
@@ -1,3 +1,15 @@
+2012-01-18 Roland Takacs <takacs.rol...@stud.u-szeged.hu>
+
+ Cross-platform processor core counter
+ https://bugs.webkit.org/show_bug.cgi?id=76530
+
+ Reviewed by Zoltan Herczeg.
+
+ Two files have been added to the project, namely NumberOfCores.h/cpp,
+ that include a CPU core number determining function.
+
+ * WTF.pro:
+
2012-01-17 Caio Marcelo de Oliveira Filho <caio.olive...@openbossa.org>
Uint8ClampedArray support
Modified: trunk/Source/WTF/WTF.pro (105269 => 105270)
--- trunk/Source/WTF/WTF.pro 2012-01-18 13:57:05 UTC (rev 105269)
+++ trunk/Source/WTF/WTF.pro 2012-01-18 14:15:05 UTC (rev 105270)
@@ -82,6 +82,7 @@
NonCopyingSort.h \
NotFound.h \
NullPtr.h \
+ NumberOfCores.h \
OSAllocator.h \
OSRandomSource.h \
OwnArrayPtr.h \
@@ -188,6 +189,7 @@
MainThread.cpp \
MetaAllocator.cpp \
NullPtr.cpp \
+ NumberOfCores.cpp \
OSRandomSource.cpp \
qt/MainThreadQt.cpp \
qt/StringQt.cpp \