summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/wtf
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/JavaScriptCore/wtf
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/JavaScriptCore/wtf')
-rw-r--r--Source/JavaScriptCore/wtf/ASCIICType.h20
-rw-r--r--Source/JavaScriptCore/wtf/Alignment.h2
-rw-r--r--Source/JavaScriptCore/wtf/ArrayBufferView.h7
-rw-r--r--Source/JavaScriptCore/wtf/Assertions.cpp41
-rw-r--r--Source/JavaScriptCore/wtf/Assertions.h6
-rw-r--r--Source/JavaScriptCore/wtf/ByteArray.h2
-rw-r--r--Source/JavaScriptCore/wtf/CMakeLists.txt2
-rw-r--r--Source/JavaScriptCore/wtf/CheckedBoolean.h61
-rw-r--r--Source/JavaScriptCore/wtf/Compiler.h12
-rw-r--r--Source/JavaScriptCore/wtf/CryptographicallyRandomNumber.h4
-rw-r--r--Source/JavaScriptCore/wtf/CurrentTime.h4
-rw-r--r--Source/JavaScriptCore/wtf/DateMath.h16
-rw-r--r--Source/JavaScriptCore/wtf/DecimalNumber.h8
-rw-r--r--Source/JavaScriptCore/wtf/DoublyLinkedList.h19
-rw-r--r--Source/JavaScriptCore/wtf/FastMalloc.cpp4
-rw-r--r--Source/JavaScriptCore/wtf/FastMalloc.h24
-rw-r--r--Source/JavaScriptCore/wtf/Forward.h2
-rw-r--r--Source/JavaScriptCore/wtf/InlineASM.h2
-rw-r--r--Source/JavaScriptCore/wtf/MD5.h6
-rw-r--r--Source/JavaScriptCore/wtf/MainThread.h18
-rw-r--r--Source/JavaScriptCore/wtf/MetaAllocator.cpp107
-rw-r--r--Source/JavaScriptCore/wtf/MetaAllocator.h59
-rw-r--r--Source/JavaScriptCore/wtf/MetaAllocatorHandle.h33
-rw-r--r--Source/JavaScriptCore/wtf/NumberOfCores.cpp75
-rw-r--r--Source/JavaScriptCore/wtf/NumberOfCores.h30
-rw-r--r--Source/JavaScriptCore/wtf/OSAllocator.h20
-rw-r--r--Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp12
-rw-r--r--Source/JavaScriptCore/wtf/OwnPtrCommon.h6
-rw-r--r--Source/JavaScriptCore/wtf/PageBlock.h2
-rw-r--r--Source/JavaScriptCore/wtf/ParallelJobsGeneric.cpp48
-rw-r--r--Source/JavaScriptCore/wtf/ParallelJobsGeneric.h3
-rw-r--r--Source/JavaScriptCore/wtf/Platform.h12
-rw-r--r--Source/JavaScriptCore/wtf/PlatformEfl.cmake1
-rw-r--r--Source/JavaScriptCore/wtf/RandomNumber.h2
-rw-r--r--Source/JavaScriptCore/wtf/RedBlackTree.h135
-rw-r--r--Source/JavaScriptCore/wtf/RefCountedLeakCounter.h12
-rw-r--r--Source/JavaScriptCore/wtf/SHA1.h6
-rw-r--r--Source/JavaScriptCore/wtf/StdLibExtras.h9
-rw-r--r--Source/JavaScriptCore/wtf/Threading.cpp2
-rw-r--r--Source/JavaScriptCore/wtf/Threading.h16
-rw-r--r--Source/JavaScriptCore/wtf/ThreadingPrimitives.h22
-rw-r--r--Source/JavaScriptCore/wtf/Uint8Array.h2
-rw-r--r--Source/JavaScriptCore/wtf/Uint8ClampedArray.h104
-rw-r--r--Source/JavaScriptCore/wtf/Vector.h2
-rw-r--r--Source/JavaScriptCore/wtf/WTFThreadData.h4
-rw-r--r--Source/JavaScriptCore/wtf/dtoa.h10
-rw-r--r--Source/JavaScriptCore/wtf/efl/OwnPtrEfl.cpp7
-rw-r--r--Source/JavaScriptCore/wtf/gobject/GOwnPtr.cpp12
-rw-r--r--Source/JavaScriptCore/wtf/gobject/GOwnPtr.h2
-rw-r--r--Source/JavaScriptCore/wtf/gobject/GTypedefs.h2
-rw-r--r--Source/JavaScriptCore/wtf/text/AtomicString.cpp48
-rw-r--r--Source/JavaScriptCore/wtf/text/AtomicString.h22
-rw-r--r--Source/JavaScriptCore/wtf/text/CString.h10
-rw-r--r--Source/JavaScriptCore/wtf/text/StringBuilder.cpp14
-rw-r--r--Source/JavaScriptCore/wtf/text/StringBuilder.h147
-rw-r--r--Source/JavaScriptCore/wtf/text/StringHash.h4
-rw-r--r--Source/JavaScriptCore/wtf/text/StringImpl.cpp184
-rw-r--r--Source/JavaScriptCore/wtf/text/StringImpl.h83
-rw-r--r--Source/JavaScriptCore/wtf/text/WTFString.cpp7
-rw-r--r--Source/JavaScriptCore/wtf/text/WTFString.h14
-rw-r--r--Source/JavaScriptCore/wtf/unicode/CharacterNames.h1
-rw-r--r--Source/JavaScriptCore/wtf/unicode/Collator.h8
-rw-r--r--Source/JavaScriptCore/wtf/unicode/UTF8.h4
-rw-r--r--Source/JavaScriptCore/wtf/wtf.pri42
-rw-r--r--Source/JavaScriptCore/wtf/wtf.pro252
65 files changed, 1123 insertions, 734 deletions
diff --git a/Source/JavaScriptCore/wtf/ASCIICType.h b/Source/JavaScriptCore/wtf/ASCIICType.h
index 17006ae2d..18e108e1b 100644
--- a/Source/JavaScriptCore/wtf/ASCIICType.h
+++ b/Source/JavaScriptCore/wtf/ASCIICType.h
@@ -111,6 +111,16 @@ template<typename CharType> inline CharType toASCIILower(CharType c)
return c | ((c >= 'A' && c <= 'Z') << 5);
}
+template<typename CharType> inline CharType toASCIILowerUnchecked(CharType character)
+{
+ // This function can be used for comparing any input character
+ // to a lowercase English character. The isASCIIAlphaCaselessEqual
+ // below should be used for regular comparison of ASCII alpha
+ // characters, but switch statements in CSS tokenizer require
+ // direct use of this function.
+ return character | 0x20;
+}
+
template<typename CharType> inline CharType toASCIIUpper(CharType c)
{
return c & ~((c >= 'a' && c <= 'z') << 5);
@@ -140,6 +150,14 @@ inline char upperNibbleToASCIIHexDigit(char c)
return nibble < 10 ? '0' + nibble : 'A' + nibble - 10;
}
+template<typename CharType> inline bool isASCIIAlphaCaselessEqual(CharType cssCharacter, char character)
+{
+ // This function compares a (preferrably) constant ASCII
+ // lowercase letter to any input character.
+ ASSERT(character >= 'a' && character <= 'z');
+ return LIKELY(toASCIILowerUnchecked(cssCharacter) == character);
+}
+
}
using WTF::isASCII;
@@ -154,8 +172,10 @@ using WTF::isASCIISpace;
using WTF::isASCIIUpper;
using WTF::toASCIIHexValue;
using WTF::toASCIILower;
+using WTF::toASCIILowerUnchecked;
using WTF::toASCIIUpper;
using WTF::lowerNibbleToASCIIHexDigit;
using WTF::upperNibbleToASCIIHexDigit;
+using WTF::isASCIIAlphaCaselessEqual;
#endif
diff --git a/Source/JavaScriptCore/wtf/Alignment.h b/Source/JavaScriptCore/wtf/Alignment.h
index d42b307ed..9b443efc6 100644
--- a/Source/JavaScriptCore/wtf/Alignment.h
+++ b/Source/JavaScriptCore/wtf/Alignment.h
@@ -26,7 +26,7 @@
namespace WTF {
-#if COMPILER(GCC) || COMPILER(MINGW) || COMPILER(RVCT) || COMPILER(GCCE)
+#if COMPILER(GCC) || COMPILER(MINGW) || COMPILER(RVCT) || COMPILER(GCCE) || (COMPILER(SUNCC) && __SUNPRO_CC > 0x590)
#define WTF_ALIGN_OF(type) __alignof__(type)
#define WTF_ALIGNED(variable_type, variable, n) variable_type variable __attribute__((__aligned__(n)))
#elif COMPILER(MSVC)
diff --git a/Source/JavaScriptCore/wtf/ArrayBufferView.h b/Source/JavaScriptCore/wtf/ArrayBufferView.h
index ccb7fd348..24ce25a5e 100644
--- a/Source/JavaScriptCore/wtf/ArrayBufferView.h
+++ b/Source/JavaScriptCore/wtf/ArrayBufferView.h
@@ -40,6 +40,7 @@ class ArrayBufferView : public RefCounted<ArrayBufferView> {
public:
virtual bool isByteArray() const { return false; }
virtual bool isUnsignedByteArray() const { return false; }
+ virtual bool isUnsignedByteClampedArray() const { return false; }
virtual bool isShortArray() const { return false; }
virtual bool isUnsignedShortArray() const { return false; }
virtual bool isIntArray() const { return false; }
@@ -65,10 +66,10 @@ class ArrayBufferView : public RefCounted<ArrayBufferView> {
virtual unsigned byteLength() const = 0;
- virtual ~ArrayBufferView();
+ WTF_EXPORT_PRIVATE virtual ~ArrayBufferView();
protected:
- ArrayBufferView(PassRefPtr<ArrayBuffer>, unsigned byteOffset);
+ WTF_EXPORT_PRIVATE ArrayBufferView(PassRefPtr<ArrayBuffer>, unsigned byteOffset);
inline bool setImpl(ArrayBufferView*, unsigned byteOffset);
@@ -118,7 +119,7 @@ class ArrayBufferView : public RefCounted<ArrayBufferView> {
*numElements = std::min(remainingElements, *numElements);
}
- virtual void neuter();
+ WTF_EXPORT_PRIVATE virtual void neuter();
// This is the address of the ArrayBuffer's storage, plus the byte offset.
void* m_baseAddress;
diff --git a/Source/JavaScriptCore/wtf/Assertions.cpp b/Source/JavaScriptCore/wtf/Assertions.cpp
index 3da67effe..80afcf414 100644
--- a/Source/JavaScriptCore/wtf/Assertions.cpp
+++ b/Source/JavaScriptCore/wtf/Assertions.cpp
@@ -272,6 +272,16 @@ void WTFGetBacktrace(void** stack, int* size)
#endif
}
+#if OS(DARWIN) || OS(LINUX)
+# if PLATFORM(QT) || PLATFORM(GTK)
+# if defined(__GLIBC__) && !defined(__UCLIBC__)
+# define WTF_USE_BACKTRACE_SYMBOLS 1
+# endif
+# else
+# define WTF_USE_DLADDR 1
+# endif
+#endif
+
void WTFReportBacktrace()
{
static const int framesToShow = 31;
@@ -281,11 +291,18 @@ void WTFReportBacktrace()
WTFGetBacktrace(samples, &frames);
+#if USE(BACKTRACE_SYMBOLS)
+ char** symbols = backtrace_symbols(samples, frames);
+ if (!symbols)
+ return;
+#endif
+
for (int i = framesToSkip; i < frames; ++i) {
const char* mangledName = 0;
char* cxaDemangled = 0;
-
-#if !PLATFORM(GTK) && !PLATFORM(QT) && (OS(DARWIN) || OS(LINUX))
+#if USE(BACKTRACE_SYMBOLS)
+ mangledName = symbols[i];
+#elif USE(DLADDR)
Dl_info info;
if (dladdr(samples[i], &info) && info.dli_sname)
mangledName = info.dli_sname;
@@ -299,6 +316,26 @@ void WTFReportBacktrace()
printf_stderr_common("%-3d %p\n", frameNumber, samples[i]);
free(cxaDemangled);
}
+
+#if USE(BACKTRACE_SYMBOLS)
+ free(symbols);
+#endif
+}
+
+#undef WTF_USE_BACKTRACE_SYMBOLS
+#undef WTF_USE_DLADDR
+
+static WTFCrashHookFunction globalHook = 0;
+
+void WTFSetCrashHook(WTFCrashHookFunction function)
+{
+ globalHook = function;
+}
+
+void WTFInvokeCrashHook()
+{
+ if (globalHook)
+ globalHook();
}
void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...)
diff --git a/Source/JavaScriptCore/wtf/Assertions.h b/Source/JavaScriptCore/wtf/Assertions.h
index 2b3d794a4..42dc0bd35 100644
--- a/Source/JavaScriptCore/wtf/Assertions.h
+++ b/Source/JavaScriptCore/wtf/Assertions.h
@@ -147,6 +147,10 @@ WTF_EXPORT_PRIVATE void WTFLogVerbose(const char* file, int line, const char* fu
WTF_EXPORT_PRIVATE void WTFGetBacktrace(void** stack, int* size);
WTF_EXPORT_PRIVATE void WTFReportBacktrace();
+typedef void (*WTFCrashHookFunction)();
+WTF_EXPORT_PRIVATE void WTFSetCrashHook(WTFCrashHookFunction);
+WTF_EXPORT_PRIVATE void WTFInvokeCrashHook();
+
#ifdef __cplusplus
}
#endif
@@ -163,12 +167,14 @@ WTF_EXPORT_PRIVATE void WTFReportBacktrace();
#if COMPILER(CLANG)
#define CRASH() do { \
WTFReportBacktrace(); \
+ WTFInvokeCrashHook(); \
*(int *)(uintptr_t)0xbbadbeef = 0; \
__builtin_trap(); \
} while (false)
#else
#define CRASH() do { \
WTFReportBacktrace(); \
+ WTFInvokeCrashHook(); \
*(int *)(uintptr_t)0xbbadbeef = 0; \
((void(*)())0)(); /* More reliable, but doesn't say BBADBEEF */ \
} while (false)
diff --git a/Source/JavaScriptCore/wtf/ByteArray.h b/Source/JavaScriptCore/wtf/ByteArray.h
index 6964a33df..f68d032fd 100644
--- a/Source/JavaScriptCore/wtf/ByteArray.h
+++ b/Source/JavaScriptCore/wtf/ByteArray.h
@@ -83,7 +83,7 @@ namespace WTF {
}
}
- static PassRefPtr<ByteArray> create(size_t size);
+ WTF_EXPORT_PRIVATE static PassRefPtr<ByteArray> create(size_t size);
static size_t offsetOfSize() { return OBJECT_OFFSETOF(ByteArray, m_size); }
static size_t offsetOfData() { return OBJECT_OFFSETOF(ByteArray, m_data); }
diff --git a/Source/JavaScriptCore/wtf/CMakeLists.txt b/Source/JavaScriptCore/wtf/CMakeLists.txt
index 52d3e3c4d..c22ae5185 100644
--- a/Source/JavaScriptCore/wtf/CMakeLists.txt
+++ b/Source/JavaScriptCore/wtf/CMakeLists.txt
@@ -53,6 +53,7 @@ SET(WTF_HEADERS
Noncopyable.h
NotFound.h
NullPtr.h
+ NumberOfCores.h
OSAllocator.h
OSRandomSource.h
OwnArrayPtr.h
@@ -146,6 +147,7 @@ SET(WTF_SOURCES
MainThread.cpp
MD5.cpp
OSRandomSource.cpp
+ NumberOfCores.cpp
PageAllocationAligned.cpp
PageBlock.cpp
ParallelJobsGeneric.cpp
diff --git a/Source/JavaScriptCore/wtf/CheckedBoolean.h b/Source/JavaScriptCore/wtf/CheckedBoolean.h
new file mode 100644
index 000000000..c65c70ef8
--- /dev/null
+++ b/Source/JavaScriptCore/wtf/CheckedBoolean.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 Apple Inc. 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 APPLE INC. ``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 APPLE INC. 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.
+ */
+
+#ifndef CheckedBoolean_h
+#define CheckedBoolean_h
+
+#include <wtf/Assertions.h>
+
+class CheckedBoolean {
+public:
+ CheckedBoolean(bool value)
+ : m_value(value)
+#if !ASSERT_DISABLED
+ , m_checked(false)
+#endif
+ {
+ }
+
+ ~CheckedBoolean()
+ {
+ ASSERT(m_checked);
+ }
+
+ operator bool()
+ {
+#if !ASSERT_DISABLED
+ m_checked = true;
+#endif
+ return m_value;
+ }
+
+private:
+ bool m_value;
+#if !ASSERT_DISABLED
+ bool m_checked;
+#endif
+};
+
+#endif
diff --git a/Source/JavaScriptCore/wtf/Compiler.h b/Source/JavaScriptCore/wtf/Compiler.h
index 93d3316bf..96ad6e40e 100644
--- a/Source/JavaScriptCore/wtf/Compiler.h
+++ b/Source/JavaScriptCore/wtf/Compiler.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -239,4 +239,14 @@
#define FINAL
#endif
+/* OBJC_CLASS */
+
+#ifndef OBJC_CLASS
+#ifdef __OBJC__
+#define OBJC_CLASS @class
+#else
+#define OBJC_CLASS class
+#endif
+#endif
+
#endif /* WTF_Compiler_h */
diff --git a/Source/JavaScriptCore/wtf/CryptographicallyRandomNumber.h b/Source/JavaScriptCore/wtf/CryptographicallyRandomNumber.h
index 348242e25..2262b6c3b 100644
--- a/Source/JavaScriptCore/wtf/CryptographicallyRandomNumber.h
+++ b/Source/JavaScriptCore/wtf/CryptographicallyRandomNumber.h
@@ -31,8 +31,8 @@
namespace WTF {
#if USE(OS_RANDOMNESS)
-uint32_t cryptographicallyRandomNumber();
-void cryptographicallyRandomValues(void* buffer, size_t length);
+WTF_EXPORT_PRIVATE uint32_t cryptographicallyRandomNumber();
+WTF_EXPORT_PRIVATE void cryptographicallyRandomValues(void* buffer, size_t length);
#endif
}
diff --git a/Source/JavaScriptCore/wtf/CurrentTime.h b/Source/JavaScriptCore/wtf/CurrentTime.h
index 71775c273..ee49f8d25 100644
--- a/Source/JavaScriptCore/wtf/CurrentTime.h
+++ b/Source/JavaScriptCore/wtf/CurrentTime.h
@@ -39,7 +39,7 @@ namespace WTF {
// Returns the current UTC time in seconds, counted from January 1, 1970.
// Precision varies depending on platform but is usually as good or better
// than a millisecond.
-double currentTime();
+WTF_EXPORT_PRIVATE double currentTime();
// Same thing, in milliseconds.
inline double currentTimeMS()
@@ -60,7 +60,7 @@ inline void getLocalTime(const time_t* localTime, struct tm* localTM)
// Provides a monotonically increasing time in seconds since an arbitrary point in the past.
// On unsupported platforms, this function only guarantees the result will be non-decreasing.
-double monotonicallyIncreasingTime();
+WTF_EXPORT_PRIVATE double monotonicallyIncreasingTime();
} // namespace WTF
diff --git a/Source/JavaScriptCore/wtf/DateMath.h b/Source/JavaScriptCore/wtf/DateMath.h
index 114acf8a8..fc1a8d8e4 100644
--- a/Source/JavaScriptCore/wtf/DateMath.h
+++ b/Source/JavaScriptCore/wtf/DateMath.h
@@ -61,7 +61,7 @@ int equivalentYearForDST(int year);
// Not really math related, but this is currently the only shared place to put these.
double parseES5DateFromNullTerminatedCharacters(const char* dateString);
-double parseDateFromNullTerminatedCharacters(const char* dateString);
+WTF_EXPORT_PRIVATE double parseDateFromNullTerminatedCharacters(const char* dateString);
double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveTZ, int& offset);
double timeClip(double);
// dayOfWeek: [0, 6] 0 being Monday, day: [1, 31], month: [0, 11], year: ex: 2011, hours: [0, 23], minutes: [0, 59], seconds: [0, 59], utcOffset: [-720,720].
@@ -89,18 +89,18 @@ const double msPerMonth = 2592000000.0;
bool isLeapYear(int year);
// Returns the number of days from 1970-01-01 to the specified date.
-double dateToDaysFrom1970(int year, int month, int day);
-int msToYear(double ms);
+WTF_EXPORT_PRIVATE double dateToDaysFrom1970(int year, int month, int day);
+WTF_EXPORT_PRIVATE int msToYear(double ms);
double msToDays(double ms);
int msToMinutes(double ms);
int msToHours(double ms);
-int dayInYear(double ms, int year);
-int monthFromDayInYear(int dayInYear, bool leapYear);
-int dayInMonthFromDayInYear(int dayInYear, bool leapYear);
+WTF_EXPORT_PRIVATE int dayInYear(double ms, int year);
+WTF_EXPORT_PRIVATE int monthFromDayInYear(int dayInYear, bool leapYear);
+WTF_EXPORT_PRIVATE int dayInMonthFromDayInYear(int dayInYear, bool leapYear);
// Returns offset milliseconds for UTC and DST.
-int32_t calculateUTCOffset();
-double calculateDSTOffset(double ms, double utcOffset);
+WTF_EXPORT_PRIVATE int32_t calculateUTCOffset();
+WTF_EXPORT_PRIVATE double calculateDSTOffset(double ms, double utcOffset);
} // namespace WTF
diff --git a/Source/JavaScriptCore/wtf/DecimalNumber.h b/Source/JavaScriptCore/wtf/DecimalNumber.h
index ac7b80058..61effcdd3 100644
--- a/Source/JavaScriptCore/wtf/DecimalNumber.h
+++ b/Source/JavaScriptCore/wtf/DecimalNumber.h
@@ -81,11 +81,11 @@ public:
ASSERT(m_significand[0] != '0' || !m_exponent);
}
- unsigned bufferLengthForStringDecimal() const;
- unsigned bufferLengthForStringExponential() const;
+ WTF_EXPORT_PRIVATE unsigned bufferLengthForStringDecimal() const;
+ WTF_EXPORT_PRIVATE unsigned bufferLengthForStringExponential() const;
- unsigned toStringDecimal(UChar* buffer, unsigned bufferLength) const;
- unsigned toStringExponential(UChar* buffer, unsigned bufferLength) const;
+ WTF_EXPORT_PRIVATE unsigned toStringDecimal(UChar* buffer, unsigned bufferLength) const;
+ WTF_EXPORT_PRIVATE unsigned toStringExponential(UChar* buffer, unsigned bufferLength) const;
bool sign() const { return m_sign; }
int exponent() const { return m_exponent; }
diff --git a/Source/JavaScriptCore/wtf/DoublyLinkedList.h b/Source/JavaScriptCore/wtf/DoublyLinkedList.h
index 18aa00e17..361d71d7b 100644
--- a/Source/JavaScriptCore/wtf/DoublyLinkedList.h
+++ b/Source/JavaScriptCore/wtf/DoublyLinkedList.h
@@ -77,6 +77,7 @@ public:
T* head() const;
T* removeHead();
+ void push(T*);
void append(T*);
void remove(T*);
@@ -115,6 +116,24 @@ template<typename T> inline T* DoublyLinkedList<T>::head() const
return m_head;
}
+template<typename T> inline void DoublyLinkedList<T>::push(T* node)
+{
+ if (!m_head) {
+ ASSERT(!m_tail);
+ m_head = node;
+ m_tail = node;
+ node->setPrev(0);
+ node->setNext(0);
+ return;
+ }
+
+ ASSERT(m_tail);
+ m_head->setPrev(node);
+ node->setNext(m_head);
+ node->setPrev(0);
+ m_head = node;
+}
+
template<typename T> inline void DoublyLinkedList<T>::append(T* node)
{
if (!m_tail) {
diff --git a/Source/JavaScriptCore/wtf/FastMalloc.cpp b/Source/JavaScriptCore/wtf/FastMalloc.cpp
index 5c684500f..6b92f5542 100644
--- a/Source/JavaScriptCore/wtf/FastMalloc.cpp
+++ b/Source/JavaScriptCore/wtf/FastMalloc.cpp
@@ -182,7 +182,7 @@ namespace WTF {
namespace Internal {
#if !ENABLE(WTF_MALLOC_VALIDATION)
-void fastMallocMatchFailed(void*);
+WTF_EXPORT_PRIVATE void fastMallocMatchFailed(void*);
#else
COMPILE_ASSERT(((sizeof(ValidationHeader) % sizeof(AllocAlignmentInteger)) == 0), ValidationHeader_must_produce_correct_alignment);
#endif
@@ -400,7 +400,7 @@ size_t fastMallocSize(const void* p)
#if OS(DARWIN)
// This symbol is present in the JavaScriptCore exports file even when FastMalloc is disabled.
// It will never be used in this case, so it's type and value are less interesting than its presence.
-extern "C" const int jscore_fastmalloc_introspection = 0;
+extern "C" WTF_EXPORT_PRIVATE const int jscore_fastmalloc_introspection = 0;
#endif
#else // FORCE_SYSTEM_MALLOC
diff --git a/Source/JavaScriptCore/wtf/FastMalloc.h b/Source/JavaScriptCore/wtf/FastMalloc.h
index b4f74e47b..b115908ba 100644
--- a/Source/JavaScriptCore/wtf/FastMalloc.h
+++ b/Source/JavaScriptCore/wtf/FastMalloc.h
@@ -29,12 +29,12 @@
namespace WTF {
// These functions call CRASH() if an allocation fails.
- void* fastMalloc(size_t);
- void* fastZeroedMalloc(size_t);
- void* fastCalloc(size_t numElements, size_t elementSize);
- void* fastRealloc(void*, size_t);
- char* fastStrDup(const char*);
- size_t fastMallocSize(const void*);
+ WTF_EXPORT_PRIVATE void* fastMalloc(size_t);
+ WTF_EXPORT_PRIVATE void* fastZeroedMalloc(size_t);
+ WTF_EXPORT_PRIVATE void* fastCalloc(size_t numElements, size_t elementSize);
+ WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t);
+ WTF_EXPORT_PRIVATE char* fastStrDup(const char*);
+ WTF_EXPORT_PRIVATE size_t fastMallocSize(const void*);
struct TryMallocReturnValue {
TryMallocReturnValue(void* data)
@@ -68,26 +68,26 @@ namespace WTF {
return returnValue;
}
- TryMallocReturnValue tryFastMalloc(size_t n);
+ WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastMalloc(size_t n);
TryMallocReturnValue tryFastZeroedMalloc(size_t n);
- TryMallocReturnValue tryFastCalloc(size_t n_elements, size_t element_size);
- TryMallocReturnValue tryFastRealloc(void* p, size_t n);
+ WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastCalloc(size_t n_elements, size_t element_size);
+ WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastRealloc(void* p, size_t n);
- void fastFree(void*);
+ WTF_EXPORT_PRIVATE void fastFree(void*);
#ifndef NDEBUG
void fastMallocForbid();
void fastMallocAllow();
#endif
- void releaseFastMallocFreeMemory();
+ WTF_EXPORT_PRIVATE void releaseFastMallocFreeMemory();
struct FastMallocStatistics {
size_t reservedVMBytes;
size_t committedVMBytes;
size_t freeListBytes;
};
- FastMallocStatistics fastMallocStatistics();
+ WTF_EXPORT_PRIVATE FastMallocStatistics fastMallocStatistics();
// This defines a type which holds an unsigned integer and is the same
// size as the minimally aligned memory allocation.
diff --git a/Source/JavaScriptCore/wtf/Forward.h b/Source/JavaScriptCore/wtf/Forward.h
index 3c97849cc..b81ab2580 100644
--- a/Source/JavaScriptCore/wtf/Forward.h
+++ b/Source/JavaScriptCore/wtf/Forward.h
@@ -51,6 +51,7 @@ namespace WTF {
class StringBuilder;
class StringImpl;
class Uint8Array;
+ class Uint8ClampedArray;
class Uint16Array;
class Uint32Array;
}
@@ -82,6 +83,7 @@ using WTF::StringBuffer;
using WTF::StringBuilder;
using WTF::StringImpl;
using WTF::Uint8Array;
+using WTF::Uint8ClampedArray;
using WTF::Uint16Array;
using WTF::Uint32Array;
diff --git a/Source/JavaScriptCore/wtf/InlineASM.h b/Source/JavaScriptCore/wtf/InlineASM.h
index c8a93f99c..379ebd364 100644
--- a/Source/JavaScriptCore/wtf/InlineASM.h
+++ b/Source/JavaScriptCore/wtf/InlineASM.h
@@ -44,6 +44,8 @@
#if (OS(LINUX) || OS(FREEBSD)) && CPU(X86_64)
#define SYMBOL_STRING_RELOCATION(name) #name "@plt"
+#elif OS(DARWIN) || (CPU(X86_64) && COMPILER(MINGW) && !GCC_VERSION_AT_LEAST(4, 5, 0))
+#define SYMBOL_STRING_RELOCATION(name) "_" #name
#elif CPU(X86) && COMPILER(MINGW)
#define SYMBOL_STRING_RELOCATION(name) "@" #name "@4"
#else
diff --git a/Source/JavaScriptCore/wtf/MD5.h b/Source/JavaScriptCore/wtf/MD5.h
index 3caa810ba..ef027ccad 100644
--- a/Source/JavaScriptCore/wtf/MD5.h
+++ b/Source/JavaScriptCore/wtf/MD5.h
@@ -37,16 +37,16 @@ namespace WTF {
class MD5 {
public:
- MD5();
+ WTF_EXPORT_PRIVATE MD5();
void addBytes(const Vector<uint8_t>& input)
{
addBytes(input.data(), input.size());
}
- void addBytes(const uint8_t* input, size_t length);
+ WTF_EXPORT_PRIVATE void addBytes(const uint8_t* input, size_t length);
// checksum has a side effect of resetting the state of the object.
- void checksum(Vector<uint8_t, 16>&);
+ WTF_EXPORT_PRIVATE void checksum(Vector<uint8_t, 16>&);
private:
uint32_t m_buf[4];
diff --git a/Source/JavaScriptCore/wtf/MainThread.h b/Source/JavaScriptCore/wtf/MainThread.h
index c153d1eba..ff76a5fd3 100644
--- a/Source/JavaScriptCore/wtf/MainThread.h
+++ b/Source/JavaScriptCore/wtf/MainThread.h
@@ -40,21 +40,21 @@ typedef uint32_t ThreadIdentifier;
typedef void MainThreadFunction(void*);
// Must be called from the main thread.
-void initializeMainThread();
+WTF_EXPORT_PRIVATE void initializeMainThread();
-void callOnMainThread(MainThreadFunction*, void* context);
-void callOnMainThreadAndWait(MainThreadFunction*, void* context);
-void cancelCallOnMainThread(MainThreadFunction*, void* context);
+WTF_EXPORT_PRIVATE void callOnMainThread(MainThreadFunction*, void* context);
+WTF_EXPORT_PRIVATE void callOnMainThreadAndWait(MainThreadFunction*, void* context);
+WTF_EXPORT_PRIVATE void cancelCallOnMainThread(MainThreadFunction*, void* context);
template<typename> class Function;
-void callOnMainThread(const Function<void ()>&);
+WTF_EXPORT_PRIVATE void callOnMainThread(const Function<void ()>&);
-void setMainThreadCallbacksPaused(bool paused);
+WTF_EXPORT_PRIVATE void setMainThreadCallbacksPaused(bool paused);
-bool isMainThread();
+WTF_EXPORT_PRIVATE bool isMainThread();
#if ENABLE(PARALLEL_GC)
void registerGCThread();
-bool isMainThreadOrGCThread();
+WTF_EXPORT_PRIVATE bool isMainThreadOrGCThread();
#elif PLATFORM(MAC)
bool isMainThreadOrGCThread();
#else
@@ -70,7 +70,7 @@ void dispatchFunctionsFromMainThread();
// This version of initializeMainThread sets up the main thread as corresponding
// to the process's main thread, and not necessarily the thread that calls this
// function. It should only be used as a legacy aid for Mac WebKit.
-void initializeMainThreadToProcessMainThread();
+WTF_EXPORT_PRIVATE void initializeMainThreadToProcessMainThread();
void initializeMainThreadToProcessMainThreadPlatform();
#endif
diff --git a/Source/JavaScriptCore/wtf/MetaAllocator.cpp b/Source/JavaScriptCore/wtf/MetaAllocator.cpp
index 92205a5d8..d153faab7 100644
--- a/Source/JavaScriptCore/wtf/MetaAllocator.cpp
+++ b/Source/JavaScriptCore/wtf/MetaAllocator.cpp
@@ -33,10 +33,33 @@
namespace WTF {
-MetaAllocatorHandle::MetaAllocatorHandle(MetaAllocator* allocator, void* start, size_t sizeInBytes)
+void MetaAllocatorTracker::notify(MetaAllocatorHandle* handle)
+{
+ m_allocations.insert(handle);
+}
+
+void MetaAllocatorTracker::release(MetaAllocatorHandle* handle)
+{
+ m_allocations.remove(handle);
+}
+
+ALWAYS_INLINE void MetaAllocator::release(MetaAllocatorHandle* handle)
+{
+ SpinLockHolder locker(&m_lock);
+ if (handle->sizeInBytes()) {
+ decrementPageOccupancy(handle->start(), handle->sizeInBytes());
+ addFreeSpaceFromReleasedHandle(handle->start(), handle->sizeInBytes());
+ }
+
+ if (UNLIKELY(!!m_tracker))
+ m_tracker->release(handle);
+}
+
+MetaAllocatorHandle::MetaAllocatorHandle(MetaAllocator* allocator, void* start, size_t sizeInBytes, void* ownerUID)
: m_allocator(allocator)
, m_start(start)
, m_sizeInBytes(sizeInBytes)
+ , m_ownerUID(ownerUID)
{
ASSERT(allocator);
ASSERT(start);
@@ -45,24 +68,14 @@ MetaAllocatorHandle::MetaAllocatorHandle(MetaAllocator* allocator, void* start,
MetaAllocatorHandle::~MetaAllocatorHandle()
{
- if (!m_allocator)
- return;
- SpinLockHolder locker(&m_allocator->m_lock);
- if (m_sizeInBytes) {
- m_allocator->decrementPageOccupancy(m_start, m_sizeInBytes);
- m_allocator->addFreeSpaceFromReleasedHandle(m_start, m_sizeInBytes);
- }
+ ASSERT(m_allocator);
+ m_allocator->release(this);
}
void MetaAllocatorHandle::shrink(size_t newSizeInBytes)
{
ASSERT(newSizeInBytes <= m_sizeInBytes);
- if (!m_allocator) {
- m_sizeInBytes = newSizeInBytes;
- return;
- }
-
SpinLockHolder locker(&m_allocator->m_lock);
newSizeInBytes = m_allocator->roundUp(newSizeInBytes);
@@ -91,6 +104,7 @@ MetaAllocator::MetaAllocator(size_t allocationGranule)
, m_bytesAllocated(0)
, m_bytesReserved(0)
, m_bytesCommitted(0)
+ , m_tracker(0)
#ifndef NDEBUG
, m_mallocBalance(0)
#endif
@@ -116,7 +130,7 @@ MetaAllocator::MetaAllocator(size_t allocationGranule)
ASSERT(static_cast<size_t>(1) << m_logAllocationGranule == m_allocationGranule);
}
-PassRefPtr<MetaAllocatorHandle> MetaAllocator::allocate(size_t sizeInBytes)
+PassRefPtr<MetaAllocatorHandle> MetaAllocator::allocate(size_t sizeInBytes, void* ownerUID)
{
SpinLockHolder locker(&m_lock);
@@ -154,10 +168,13 @@ PassRefPtr<MetaAllocatorHandle> MetaAllocator::allocate(size_t sizeInBytes)
m_numAllocations++;
#endif
- MetaAllocatorHandle* handle = new MetaAllocatorHandle(this, start, sizeInBytes);
+ MetaAllocatorHandle* handle = new MetaAllocatorHandle(this, start, sizeInBytes, ownerUID);
// FIXME: Implement a verifier scheme that groks MetaAllocatorHandles
handle->deprecatedTurnOffVerifier();
+ if (UNLIKELY(!!m_tracker))
+ m_tracker->notify(handle);
+
return adoptRef(handle);
}
@@ -178,18 +195,18 @@ void* MetaAllocator::findAndRemoveFreeSpace(size_t sizeInBytes)
if (!node)
return 0;
- ASSERT(node->m_key >= sizeInBytes);
+ ASSERT(node->m_sizeInBytes >= sizeInBytes);
m_freeSpaceSizeMap.remove(node);
void* result;
- if (node->m_key == sizeInBytes) {
+ if (node->m_sizeInBytes == sizeInBytes) {
// Easy case: perfect fit, so just remove the node entirely.
- result = node->m_value;
+ result = node->m_start;
- m_freeSpaceStartAddressMap.remove(node->m_value);
- m_freeSpaceEndAddressMap.remove(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(node->m_value) + node->m_key));
+ m_freeSpaceStartAddressMap.remove(node->m_start);
+ m_freeSpaceEndAddressMap.remove(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(node->m_start) + node->m_sizeInBytes));
freeFreeSpaceNode(node);
} else {
// Try to be a good citizen and ensure that the returned chunk of memory
@@ -199,31 +216,31 @@ void* MetaAllocator::findAndRemoveFreeSpace(size_t sizeInBytes)
// of committed pages, since in the long run, smaller fragmentation means
// fewer committed pages and fewer failures in general.
- uintptr_t firstPage = reinterpret_cast<uintptr_t>(node->m_value) >> m_logPageSize;
- uintptr_t lastPage = (reinterpret_cast<uintptr_t>(node->m_value) + node->m_key - 1) >> m_logPageSize;
+ uintptr_t firstPage = reinterpret_cast<uintptr_t>(node->m_start) >> m_logPageSize;
+ uintptr_t lastPage = (reinterpret_cast<uintptr_t>(node->m_start) + node->m_sizeInBytes - 1) >> m_logPageSize;
- uintptr_t lastPageForLeftAllocation = (reinterpret_cast<uintptr_t>(node->m_value) + sizeInBytes - 1) >> m_logPageSize;
- uintptr_t firstPageForRightAllocation = (reinterpret_cast<uintptr_t>(node->m_value) + node->m_key - sizeInBytes) >> m_logPageSize;
+ uintptr_t lastPageForLeftAllocation = (reinterpret_cast<uintptr_t>(node->m_start) + sizeInBytes - 1) >> m_logPageSize;
+ uintptr_t firstPageForRightAllocation = (reinterpret_cast<uintptr_t>(node->m_start) + node->m_sizeInBytes - sizeInBytes) >> m_logPageSize;
if (lastPageForLeftAllocation - firstPage + 1 <= lastPage - firstPageForRightAllocation + 1) {
// Allocate in the left side of the returned chunk, and slide the node to the right.
- result = node->m_value;
+ result = node->m_start;
- m_freeSpaceStartAddressMap.remove(node->m_value);
+ m_freeSpaceStartAddressMap.remove(node->m_start);
- node->m_key -= sizeInBytes;
- node->m_value = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(node->m_value) + sizeInBytes);
+ node->m_sizeInBytes -= sizeInBytes;
+ node->m_start = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(node->m_start) + sizeInBytes);
m_freeSpaceSizeMap.insert(node);
- m_freeSpaceStartAddressMap.add(node->m_value, node);
+ m_freeSpaceStartAddressMap.add(node->m_start, node);
} else {
// Allocate in the right size of the returned chunk, and slide the node to the left;
- result = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(node->m_value) + node->m_key - sizeInBytes);
+ result = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(node->m_start) + node->m_sizeInBytes - sizeInBytes);
- m_freeSpaceEndAddressMap.remove(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(node->m_value) + node->m_key));
+ m_freeSpaceEndAddressMap.remove(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(node->m_start) + node->m_sizeInBytes));
- node->m_key -= sizeInBytes;
+ node->m_sizeInBytes -= sizeInBytes;
m_freeSpaceSizeMap.insert(node);
m_freeSpaceEndAddressMap.add(result, node);
@@ -255,7 +272,7 @@ size_t MetaAllocator::debugFreeSpaceSize()
SpinLockHolder locker(&m_lock);
size_t result = 0;
for (FreeSpaceNode* node = m_freeSpaceSizeMap.first(); node; node = node->successor())
- result += node->m_key;
+ result += node->m_sizeInBytes;
return result;
#else
CRASH();
@@ -274,12 +291,12 @@ void MetaAllocator::addFreeSpace(void* start, size_t sizeInBytes)
// We have something we can coalesce with on the left. Remove it from the tree, and
// remove its end from the end address map.
- ASSERT(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(leftNeighbor->second->m_value) + leftNeighbor->second->m_key) == leftNeighbor->first);
+ ASSERT(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(leftNeighbor->second->m_start) + leftNeighbor->second->m_sizeInBytes) == leftNeighbor->first);
FreeSpaceNode* leftNode = leftNeighbor->second;
- void* leftStart = leftNode->m_value;
- size_t leftSize = leftNode->m_key;
+ void* leftStart = leftNode->m_start;
+ size_t leftSize = leftNode->m_sizeInBytes;
void* leftEnd = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(leftStart) + leftSize);
ASSERT(leftEnd == start);
@@ -292,11 +309,11 @@ void MetaAllocator::addFreeSpace(void* start, size_t sizeInBytes)
// Freeing something in the middle of free blocks. Coalesce both left and
// right, whilst removing the right neighbor from the maps.
- ASSERT(rightNeighbor->second->m_value == rightNeighbor->first);
+ ASSERT(rightNeighbor->second->m_start == rightNeighbor->first);
FreeSpaceNode* rightNode = rightNeighbor->second;
void* rightStart = rightNeighbor->first;
- size_t rightSize = rightNode->m_key;
+ size_t rightSize = rightNode->m_sizeInBytes;
void* rightEnd = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(rightStart) + rightSize);
ASSERT(rightStart == end);
@@ -308,12 +325,12 @@ void MetaAllocator::addFreeSpace(void* start, size_t sizeInBytes)
freeFreeSpaceNode(rightNode);
- leftNode->m_key += sizeInBytes + rightSize;
+ leftNode->m_sizeInBytes += sizeInBytes + rightSize;
m_freeSpaceSizeMap.insert(leftNode);
m_freeSpaceEndAddressMap.add(rightEnd, leftNode);
} else {
- leftNode->m_key += sizeInBytes;
+ leftNode->m_sizeInBytes += sizeInBytes;
m_freeSpaceSizeMap.insert(leftNode);
m_freeSpaceEndAddressMap.add(end, leftNode);
@@ -324,7 +341,7 @@ void MetaAllocator::addFreeSpace(void* start, size_t sizeInBytes)
if (rightNeighbor != m_freeSpaceStartAddressMap.end()) {
FreeSpaceNode* rightNode = rightNeighbor->second;
void* rightStart = rightNeighbor->first;
- size_t rightSize = rightNode->m_key;
+ size_t rightSize = rightNode->m_sizeInBytes;
void* rightEnd = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(rightStart) + rightSize);
ASSERT(rightStart == end);
@@ -333,8 +350,8 @@ void MetaAllocator::addFreeSpace(void* start, size_t sizeInBytes)
m_freeSpaceSizeMap.remove(rightNode);
m_freeSpaceStartAddressMap.remove(rightStart);
- rightNode->m_key += sizeInBytes;
- rightNode->m_value = start;
+ rightNode->m_sizeInBytes += sizeInBytes;
+ rightNode->m_start = start;
m_freeSpaceSizeMap.insert(rightNode);
m_freeSpaceStartAddressMap.add(start, rightNode);
@@ -343,8 +360,8 @@ void MetaAllocator::addFreeSpace(void* start, size_t sizeInBytes)
FreeSpaceNode* node = allocFreeSpaceNode();
- node->m_key = sizeInBytes;
- node->m_value = start;
+ node->m_sizeInBytes = sizeInBytes;
+ node->m_start = start;
m_freeSpaceSizeMap.insert(node);
m_freeSpaceStartAddressMap.add(start, node);
diff --git a/Source/JavaScriptCore/wtf/MetaAllocator.h b/Source/JavaScriptCore/wtf/MetaAllocator.h
index cf971b720..ffd55667e 100644
--- a/Source/JavaScriptCore/wtf/MetaAllocator.h
+++ b/Source/JavaScriptCore/wtf/MetaAllocator.h
@@ -43,15 +43,36 @@ namespace WTF {
#define ENABLE_META_ALLOCATOR_PROFILE 0
+class MetaAllocatorTracker {
+public:
+ void notify(MetaAllocatorHandle*);
+ void release(MetaAllocatorHandle*);
+
+ MetaAllocatorHandle* find(void* address)
+ {
+ MetaAllocatorHandle* handle = m_allocations.findGreatestLessThanOrEqual(address);
+ if (handle && address < handle->end())
+ return handle;
+ return 0;
+ }
+
+ RedBlackTree<MetaAllocatorHandle, void*> m_allocations;
+};
+
class MetaAllocator {
WTF_MAKE_NONCOPYABLE(MetaAllocator);
+
public:
-
- MetaAllocator(size_t allocationGranule);
+ WTF_EXPORT_PRIVATE MetaAllocator(size_t allocationGranule);
virtual ~MetaAllocator();
- PassRefPtr<MetaAllocatorHandle> allocate(size_t sizeInBytes);
+ WTF_EXPORT_PRIVATE PassRefPtr<MetaAllocatorHandle> allocate(size_t sizeInBytes, void* ownerUID);
+
+ void trackAllocations(MetaAllocatorTracker* tracker)
+ {
+ m_tracker = tracker;
+ }
// Non-atomic methods for getting allocator statistics.
size_t bytesAllocated() { return m_bytesAllocated; }
@@ -69,11 +90,11 @@ public:
// Add more free space to the allocator. Call this directly from
// the constructor if you wish to operate the allocator within a
// fixed pool.
- void addFreshFreeSpace(void* start, size_t sizeInBytes);
+ WTF_EXPORT_PRIVATE void addFreshFreeSpace(void* start, size_t sizeInBytes);
// This is meant only for implementing tests. Never call this in release
// builds.
- size_t debugFreeSpaceSize();
+ WTF_EXPORT_PRIVATE size_t debugFreeSpaceSize();
#if ENABLE(META_ALLOCATOR_PROFILE)
void dumpProfile();
@@ -101,8 +122,26 @@ private:
friend class MetaAllocatorHandle;
- typedef RedBlackTree<size_t, void*> Tree;
- typedef Tree::Node FreeSpaceNode;
+ class FreeSpaceNode : public RedBlackTree<FreeSpaceNode, size_t>::Node {
+ public:
+ FreeSpaceNode(void* start, size_t sizeInBytes)
+ : m_start(start)
+ , m_sizeInBytes(sizeInBytes)
+ {
+ }
+
+ size_t key()
+ {
+ return m_sizeInBytes;
+ }
+
+ void* m_start;
+ size_t m_sizeInBytes;
+ };
+ typedef RedBlackTree<FreeSpaceNode, size_t> Tree;
+
+ // Release a MetaAllocatorHandle.
+ void release(MetaAllocatorHandle*);
// Remove free space from the allocator. This is effectively
// the allocate() function, except that it does not mark the
@@ -121,13 +160,13 @@ private:
void incrementPageOccupancy(void* address, size_t sizeInBytes);
void decrementPageOccupancy(void* address, size_t sizeInBytes);
-
+
// Utilities.
size_t roundUp(size_t sizeInBytes);
FreeSpaceNode* allocFreeSpaceNode();
- void freeFreeSpaceNode(FreeSpaceNode*);
+ WTF_EXPORT_PRIVATE void freeFreeSpaceNode(FreeSpaceNode*);
size_t m_allocationGranule;
unsigned m_logAllocationGranule;
@@ -145,6 +184,8 @@ private:
SpinLock m_lock;
+ MetaAllocatorTracker* m_tracker;
+
#ifndef NDEBUG
size_t m_mallocBalance;
#endif
diff --git a/Source/JavaScriptCore/wtf/MetaAllocatorHandle.h b/Source/JavaScriptCore/wtf/MetaAllocatorHandle.h
index 5a32081d4..c43f491f3 100644
--- a/Source/JavaScriptCore/wtf/MetaAllocatorHandle.h
+++ b/Source/JavaScriptCore/wtf/MetaAllocatorHandle.h
@@ -30,6 +30,7 @@
#define WTF_MetaAllocatorHandle_h
#include <wtf/Assertions.h>
+#include <wtf/RedBlackTree.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -37,25 +38,12 @@ namespace WTF {
class MetaAllocator;
-class MetaAllocatorHandle : public RefCounted<MetaAllocatorHandle> {
+class MetaAllocatorHandle : public RefCounted<MetaAllocatorHandle>, public RedBlackTree<MetaAllocatorHandle, void*>::Node {
private:
- MetaAllocatorHandle(MetaAllocator*, void* start, size_t sizeInBytes);
-
- MetaAllocatorHandle(void* start, size_t sizeInBytes)
- : m_allocator(0)
- , m_start(start)
- , m_sizeInBytes(sizeInBytes)
- {
- ASSERT(start);
- }
+ MetaAllocatorHandle(MetaAllocator*, void* start, size_t sizeInBytes, void* ownerUID);
public:
- ~MetaAllocatorHandle();
-
- static PassRefPtr<MetaAllocatorHandle> createSelfManagedHandle(void* start, size_t sizeInBytes)
- {
- return adoptRef(new MetaAllocatorHandle(start, sizeInBytes));
- }
+ WTF_EXPORT_PRIVATE ~MetaAllocatorHandle();
void* start()
{
@@ -72,7 +60,7 @@ public:
return m_sizeInBytes;
}
- void shrink(size_t newSizeInBytes);
+ WTF_EXPORT_PRIVATE void shrink(size_t newSizeInBytes);
bool isManaged()
{
@@ -84,6 +72,16 @@ public:
ASSERT(m_allocator);
return m_allocator;
}
+
+ void* ownerUID()
+ {
+ return m_ownerUID;
+ }
+
+ void* key()
+ {
+ return m_start;
+ }
private:
friend class MetaAllocator;
@@ -91,6 +89,7 @@ private:
MetaAllocator* m_allocator;
void* m_start;
size_t m_sizeInBytes;
+ void* m_ownerUID;
};
}
diff --git a/Source/JavaScriptCore/wtf/NumberOfCores.cpp b/Source/JavaScriptCore/wtf/NumberOfCores.cpp
new file mode 100644
index 000000000..1e7f45f5c
--- /dev/null
+++ b/Source/JavaScriptCore/wtf/NumberOfCores.cpp
@@ -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) || OS(FREEBSD)
+#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;
+}
+
+}
diff --git a/Source/JavaScriptCore/wtf/NumberOfCores.h b/Source/JavaScriptCore/wtf/NumberOfCores.h
new file mode 100644
index 000000000..8bc8d9455
--- /dev/null
+++ b/Source/JavaScriptCore/wtf/NumberOfCores.h
@@ -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
diff --git a/Source/JavaScriptCore/wtf/OSAllocator.h b/Source/JavaScriptCore/wtf/OSAllocator.h
index bf9f04968..9ea4f6b51 100644
--- a/Source/JavaScriptCore/wtf/OSAllocator.h
+++ b/Source/JavaScriptCore/wtf/OSAllocator.h
@@ -26,6 +26,7 @@
#ifndef OSAllocator_h
#define OSAllocator_h
+#include <algorithm>
#include <wtf/UnusedParam.h>
#include <wtf/VMTags.h>
#include <wtf/VMTags.h>
@@ -46,7 +47,7 @@ public:
// releaseDecommitted should be called on a region of VM allocated by a single reservation,
// the memory must all currently be in a decommitted state.
static void* reserveUncommitted(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false, bool includesGuardPages = false);
- static void releaseDecommitted(void*, size_t);
+ WTF_EXPORT_PRIVATE static void releaseDecommitted(void*, size_t);
// These methods are symmetric; they commit or decommit a region of VM (uncommitted VM should
// never be accessed, since the OS may not have attached physical memory for these regions).
@@ -57,7 +58,7 @@ public:
// These methods are symmetric; reserveAndCommit allocates VM in an committed state,
// decommitAndRelease should be called on a region of VM allocated by a single reservation,
// the memory must all currently be in a committed state.
- static void* reserveAndCommit(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false, bool includesGuardPages = false);
+ WTF_EXPORT_PRIVATE static void* reserveAndCommit(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false, bool includesGuardPages = false);
static void decommitAndRelease(void* base, size_t size);
// These methods are akin to reserveAndCommit/decommitAndRelease, above - however rather than
@@ -65,6 +66,12 @@ public:
// specified.
static void* reserveAndCommit(size_t reserveSize, size_t commitSize, Usage = UnknownUsage, bool writable = true, bool executable = false);
static void decommitAndRelease(void* releaseBase, size_t releaseSize, void* decommitBase, size_t decommitSize);
+
+ // Reallocate an existing, committed allocation.
+ // The prior allocation must be fully comitted, and the new size will also be fully committed.
+ // This interface is provided since it may be possible to optimize this operation on some platforms.
+ template<typename T>
+ static T* reallocateCommitted(T*, size_t oldSize, size_t newSize, Usage = UnknownUsage, bool writable = true, bool executable = false);
};
inline void* OSAllocator::reserveAndCommit(size_t reserveSize, size_t commitSize, Usage usage, bool writable, bool executable)
@@ -93,6 +100,15 @@ inline void OSAllocator::decommitAndRelease(void* base, size_t size)
decommitAndRelease(base, size, base, size);
}
+template<typename T>
+inline T* OSAllocator::reallocateCommitted(T* oldBase, size_t oldSize, size_t newSize, Usage usage, bool writable, bool executable)
+{
+ void* newBase = reserveAndCommit(newSize, usage, writable, executable);
+ memcpy(newBase, oldBase, std::min(oldSize, newSize));
+ decommitAndRelease(oldBase, oldSize);
+ return static_cast<T*>(newBase);
+}
+
} // namespace WTF
using WTF::OSAllocator;
diff --git a/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp b/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp
index b264f685a..56c6089ff 100644
--- a/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp
+++ b/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp
@@ -37,7 +37,9 @@ namespace WTF {
void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages)
{
void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages);
-#if HAVE(MADV_FREE_REUSE)
+#if OS(QNX)
+ posix_madvise(result, bytes, POSIX_MADV_DONTNEED);
+#elif HAVE(MADV_FREE_REUSE)
// To support the "reserve then commit" model, we have to initially decommit.
while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
#endif
@@ -120,7 +122,9 @@ void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bo
void OSAllocator::commit(void* address, size_t bytes, bool, bool)
{
-#if HAVE(MADV_FREE_REUSE)
+#if OS(QNX)
+ posix_madvise(address, bytes, POSIX_MADV_WILLNEED);
+#elif HAVE(MADV_FREE_REUSE)
while (madvise(address, bytes, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { }
#else
// Non-MADV_FREE_REUSE reservations automatically commit on demand.
@@ -131,7 +135,9 @@ void OSAllocator::commit(void* address, size_t bytes, bool, bool)
void OSAllocator::decommit(void* address, size_t bytes)
{
-#if HAVE(MADV_FREE_REUSE)
+#if OS(QNX)
+ posix_madvise(address, bytes, POSIX_MADV_DONTNEED);
+#elif HAVE(MADV_FREE_REUSE)
while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
#elif HAVE(MADV_FREE)
while (madvise(address, bytes, MADV_FREE) == -1 && errno == EAGAIN) { }
diff --git a/Source/JavaScriptCore/wtf/OwnPtrCommon.h b/Source/JavaScriptCore/wtf/OwnPtrCommon.h
index 16283aed2..315db8954 100644
--- a/Source/JavaScriptCore/wtf/OwnPtrCommon.h
+++ b/Source/JavaScriptCore/wtf/OwnPtrCommon.h
@@ -28,7 +28,7 @@
#ifndef WTF_OwnPtrCommon_h
#define WTF_OwnPtrCommon_h
-#if PLATFORM(WIN)
+#if OS(WINDOWS)
typedef struct HBITMAP__* HBITMAP;
typedef struct HBRUSH__* HBRUSH;
typedef struct HDC__* HDC;
@@ -41,6 +41,7 @@ typedef struct HRGN__* HRGN;
#if PLATFORM(EFL)
typedef struct _Ecore_Evas Ecore_Evas;
typedef struct _Ecore_Pipe Ecore_Pipe;
+typedef struct _Eina_Module Eina_Module;
typedef struct _Evas_Object Evas_Object;
#endif
@@ -53,7 +54,7 @@ namespace WTF {
delete ptr;
}
-#if PLATFORM(WIN)
+#if OS(WINDOWS)
void deleteOwnedPtr(HBITMAP);
void deleteOwnedPtr(HBRUSH);
void deleteOwnedPtr(HDC);
@@ -66,6 +67,7 @@ namespace WTF {
#if PLATFORM(EFL)
void deleteOwnedPtr(Ecore_Evas*);
void deleteOwnedPtr(Ecore_Pipe*);
+ void deleteOwnedPtr(Eina_Module*);
void deleteOwnedPtr(Evas_Object*);
#endif
diff --git a/Source/JavaScriptCore/wtf/PageBlock.h b/Source/JavaScriptCore/wtf/PageBlock.h
index e17c5460a..3c348a0e3 100644
--- a/Source/JavaScriptCore/wtf/PageBlock.h
+++ b/Source/JavaScriptCore/wtf/PageBlock.h
@@ -28,7 +28,7 @@
namespace WTF {
-size_t pageSize();
+WTF_EXPORT_PRIVATE size_t pageSize();
inline bool isPageAligned(void* address) { return !(reinterpret_cast<intptr_t>(address) & (pageSize() - 1)); }
inline bool isPageAligned(size_t size) { return !(size & (pageSize() - 1)); }
inline bool isPowerOfTwo(size_t size) { return !(size & (size - 1)); }
diff --git a/Source/JavaScriptCore/wtf/ParallelJobsGeneric.cpp b/Source/JavaScriptCore/wtf/ParallelJobsGeneric.cpp
index b6207dc88..fd5b1f847 100644
--- a/Source/JavaScriptCore/wtf/ParallelJobsGeneric.cpp
+++ b/Source/JavaScriptCore/wtf/ParallelJobsGeneric.cpp
@@ -30,34 +30,22 @@
#if ENABLE(THREADING_GENERIC)
#include "ParallelJobs.h"
-#include "UnusedParam.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>
-#endif
+#include <wtf/NumberOfCores.h>
namespace WTF {
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 +53,7 @@ ParallelEnvironment::ParallelEnvironment(ThreadFunction threadFunction, size_t s
// 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 +81,6 @@ void ParallelEnvironment::execute(void* parameters)
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();
diff --git a/Source/JavaScriptCore/wtf/ParallelJobsGeneric.h b/Source/JavaScriptCore/wtf/ParallelJobsGeneric.h
index dab6dd9fb..1c7d63c16 100644
--- a/Source/JavaScriptCore/wtf/ParallelJobsGeneric.h
+++ b/Source/JavaScriptCore/wtf/ParallelJobsGeneric.h
@@ -84,15 +84,12 @@ public:
};
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
diff --git a/Source/JavaScriptCore/wtf/Platform.h b/Source/JavaScriptCore/wtf/Platform.h
index bb1462e1e..cecd5ddcd 100644
--- a/Source/JavaScriptCore/wtf/Platform.h
+++ b/Source/JavaScriptCore/wtf/Platform.h
@@ -386,6 +386,9 @@
#define WTF_OS_WINDOWS 1
#endif
+#define WTF_OS_WIN ERROR "USE WINDOWS WITH OS NOT WIN"
+#define WTF_OS_MAC ERROR "USE MAC_OS_X WITH OS NOT MAC"
+
/* OS(UNIX) - Any Unix-like system */
#if OS(AIX) \
|| OS(ANDROID) \
@@ -543,7 +546,9 @@
#define ENABLE_SMOOTH_SCROLLING 1
#define ENABLE_WEB_ARCHIVE 1
#define ENABLE_WEB_AUDIO 1
+#if defined(ENABLE_VIDEO)
#define ENABLE_VIDEO_TRACK 1
+#endif
#endif /* PLATFORM(MAC) && !PLATFORM(IOS) */
#if PLATFORM(CHROMIUM) && OS(DARWIN)
@@ -667,7 +672,7 @@
#endif
#endif
-#if !OS(WINDOWS) && !OS(SOLARIS) && !OS(QNX) \
+#if !OS(WINDOWS) && !OS(SOLARIS) \
&& !OS(RVCT) \
&& !OS(ANDROID)
#define HAVE_TM_GMTOFF 1
@@ -721,6 +726,8 @@
#define HAVE_ERRNO_H 1
#define HAVE_MMAP 1
+#define HAVE_MADV_FREE_REUSE 1
+#define HAVE_MADV_FREE 1
#define HAVE_SBRK 1
#define HAVE_STRINGS_H 1
#define HAVE_SYS_PARAM_H 1
@@ -1159,5 +1166,8 @@
/* Using V8 implies not using JSC and vice versa */
#define WTF_USE_JSC !WTF_USE_V8
+#if ENABLE(NOTIFICATIONS) && PLATFORM(MAC)
+#define ENABLE_TEXT_NOTIFICATIONS_ONLY 1
+#endif
#endif /* WTF_Platform_h */
diff --git a/Source/JavaScriptCore/wtf/PlatformEfl.cmake b/Source/JavaScriptCore/wtf/PlatformEfl.cmake
index 5805c4180..3887ead8c 100644
--- a/Source/JavaScriptCore/wtf/PlatformEfl.cmake
+++ b/Source/JavaScriptCore/wtf/PlatformEfl.cmake
@@ -31,6 +31,7 @@ LIST(APPEND WTF_LIBRARIES
${ICU_I18N_LIBRARIES}
${ECORE_LIBRARIES}
${ECORE_EVAS_LIBRARIES}
+ ${EINA_LIBRARIES}
${EVAS_LIBRARIES}
${CMAKE_DL_LIBS}
)
diff --git a/Source/JavaScriptCore/wtf/RandomNumber.h b/Source/JavaScriptCore/wtf/RandomNumber.h
index f2e7e8f50..76b223582 100644
--- a/Source/JavaScriptCore/wtf/RandomNumber.h
+++ b/Source/JavaScriptCore/wtf/RandomNumber.h
@@ -30,7 +30,7 @@ namespace WTF {
// Returns a pseudo-random number in the range [0, 1), attempts to be
// cryptographically secure if possible on the target platform
- double randomNumber();
+ WTF_EXPORT_PRIVATE double randomNumber();
}
diff --git a/Source/JavaScriptCore/wtf/RedBlackTree.h b/Source/JavaScriptCore/wtf/RedBlackTree.h
index af4e5c88a..19460c141 100644
--- a/Source/JavaScriptCore/wtf/RedBlackTree.h
+++ b/Source/JavaScriptCore/wtf/RedBlackTree.h
@@ -41,7 +41,7 @@ namespace WTF {
// reference to this node.
// - The key type must implement operator< and ==.
-template<typename KeyType, typename ValueType>
+template<class NodeType, typename KeyType>
class RedBlackTree {
WTF_MAKE_NONCOPYABLE(RedBlackTree);
private:
@@ -55,18 +55,12 @@ public:
friend class RedBlackTree;
public:
- Node(KeyType key, ValueType value)
- : m_key(key)
- , m_value(value)
- {
- }
-
- const Node* successor() const
+ const NodeType* successor() const
{
const Node* x = this;
if (x->right())
return treeMinimum(x->right());
- const Node* y = x->parent();
+ const NodeType* y = x->parent();
while (y && x == y->right()) {
x = y;
y = y->parent();
@@ -74,12 +68,12 @@ public:
return y;
}
- const Node* predecessor() const
+ const NodeType* predecessor() const
{
const Node* x = this;
if (x->left())
return treeMaximum(x->left());
- const Node* y = x->parent();
+ const NodeType* y = x->parent();
while (y && x == y->left()) {
x = y;
y = y->parent();
@@ -87,18 +81,15 @@ public:
return y;
}
- Node* successor()
+ NodeType* successor()
{
- return const_cast<Node*>(const_cast<const Node*>(this)->successor());
+ return const_cast<NodeType*>(const_cast<const Node*>(this)->successor());
}
-
- Node* predecessor()
+
+ NodeType* predecessor()
{
- return const_cast<Node*>(const_cast<const Node*>(this)->predecessor());
+ return const_cast<NodeType*>(const_cast<const Node*>(this)->predecessor());
}
-
- KeyType m_key;
- ValueType m_value;
private:
void reset()
@@ -110,32 +101,32 @@ public:
// NOTE: these methods should pack the parent and red into a single
// word. But doing so appears to reveal a bug in the compiler.
- Node* parent() const
+ NodeType* parent() const
{
- return reinterpret_cast<Node*>(m_parentAndRed & ~static_cast<uintptr_t>(1));
+ return reinterpret_cast<NodeType*>(m_parentAndRed & ~static_cast<uintptr_t>(1));
}
- void setParent(Node* newParent)
+ void setParent(NodeType* newParent)
{
m_parentAndRed = reinterpret_cast<uintptr_t>(newParent) | (m_parentAndRed & 1);
}
- Node* left() const
+ NodeType* left() const
{
return m_left;
}
- void setLeft(Node* node)
+ void setLeft(NodeType* node)
{
m_left = node;
}
- Node* right() const
+ NodeType* right() const
{
return m_right;
}
- void setRight(Node* node)
+ void setRight(NodeType* node)
{
m_right = node;
}
@@ -155,17 +146,17 @@ public:
m_parentAndRed &= ~static_cast<uintptr_t>(1);
}
- Node* m_left;
- Node* m_right;
+ NodeType* m_left;
+ NodeType* m_right;
uintptr_t m_parentAndRed;
};
-
+
RedBlackTree()
: m_root(0)
{
}
- void insert(Node* x)
+ void insert(NodeType* x)
{
x->reset();
treeInsert(x);
@@ -173,7 +164,7 @@ public:
while (x != m_root && x->parent()->color() == Red) {
if (x->parent() == x->parent()->parent()->left()) {
- Node* y = x->parent()->parent()->right();
+ NodeType* y = x->parent()->parent()->right();
if (y && y->color() == Red) {
// Case 1
x->parent()->setColor(Black);
@@ -193,7 +184,7 @@ public:
}
} else {
// Same as "then" clause with "right" and "left" exchanged.
- Node* y = x->parent()->parent()->left();
+ NodeType* y = x->parent()->parent()->left();
if (y && y->color() == Red) {
// Case 1
x->parent()->setColor(Black);
@@ -217,20 +208,20 @@ public:
m_root->setColor(Black);
}
- Node* remove(Node* z)
+ NodeType* remove(NodeType* z)
{
ASSERT(z);
ASSERT(z->parent() || z == m_root);
// Y is the node to be unlinked from the tree.
- Node* y;
+ NodeType* y;
if (!z->left() || !z->right())
y = z;
else
y = z->successor();
// Y is guaranteed to be non-null at this point.
- Node* x;
+ NodeType* x;
if (y->left())
x = y->left();
else
@@ -238,7 +229,7 @@ public:
// X is the child of y which might potentially replace y in
// the tree. X might be null at this point.
- Node* xParent;
+ NodeType* xParent;
if (x) {
x->setParent(y->parent());
xParent = x->parent();
@@ -281,20 +272,20 @@ public:
return z;
}
- Node* remove(const KeyType& key)
+ NodeType* remove(const KeyType& key)
{
- Node* result = findExact(key);
+ NodeType* result = findExact(key);
if (!result)
return 0;
return remove(result);
}
- Node* findExact(const KeyType& key) const
+ NodeType* findExact(const KeyType& key) const
{
- for (Node* current = m_root; current;) {
- if (current->m_key == key)
+ for (NodeType* current = m_root; current;) {
+ if (current->key() == key)
return current;
- if (key < current->m_key)
+ if (key < current->key())
current = current->left();
else
current = current->right();
@@ -302,13 +293,13 @@ public:
return 0;
}
- Node* findLeastGreaterThanOrEqual(const KeyType& key) const
+ NodeType* findLeastGreaterThanOrEqual(const KeyType& key) const
{
- Node* best = 0;
- for (Node* current = m_root; current;) {
- if (current->m_key == key)
+ NodeType* best = 0;
+ for (NodeType* current = m_root; current;) {
+ if (current->key() == key)
return current;
- if (current->m_key < key)
+ if (current->key() < key)
current = current->right();
else {
best = current;
@@ -318,13 +309,13 @@ public:
return best;
}
- Node* findGreatestLessThanOrEqual(const KeyType& key) const
+ NodeType* findGreatestLessThanOrEqual(const KeyType& key) const
{
- Node* best = 0;
- for (Node* current = m_root; current;) {
- if (current->m_key == key)
+ NodeType* best = 0;
+ for (NodeType* current = m_root; current;) {
+ if (current->key() == key)
return current;
- if (current->m_key > key)
+ if (current->key() > key)
current = current->left();
else {
best = current;
@@ -334,14 +325,14 @@ public:
return best;
}
- Node* first() const
+ NodeType* first() const
{
if (!m_root)
return 0;
return treeMinimum(m_root);
}
- Node* last() const
+ NodeType* last() const
{
if (!m_root)
return 0;
@@ -352,7 +343,7 @@ public:
size_t size()
{
size_t result = 0;
- for (Node* current = first(); current; current = current->successor())
+ for (NodeType* current = first(); current; current = current->successor())
result++;
return result;
}
@@ -366,46 +357,46 @@ public:
private:
// Finds the minimum element in the sub-tree rooted at the given
// node.
- static Node* treeMinimum(Node* x)
+ static NodeType* treeMinimum(NodeType* x)
{
while (x->left())
x = x->left();
return x;
}
- static Node* treeMaximum(Node* x)
+ static NodeType* treeMaximum(NodeType* x)
{
while (x->right())
x = x->right();
return x;
}
- static const Node* treeMinimum(const Node* x)
+ static const NodeType* treeMinimum(const NodeType* x)
{
while (x->left())
x = x->left();
return x;
}
- static const Node* treeMaximum(const Node* x)
+ static const NodeType* treeMaximum(const NodeType* x)
{
while (x->right())
x = x->right();
return x;
}
- void treeInsert(Node* z)
+ void treeInsert(NodeType* z)
{
ASSERT(!z->left());
ASSERT(!z->right());
ASSERT(!z->parent());
ASSERT(z->color() == Red);
- Node* y = 0;
- Node* x = m_root;
+ NodeType* y = 0;
+ NodeType* x = m_root;
while (x) {
y = x;
- if (z->m_key < x->m_key)
+ if (z->key() < x->key())
x = x->left();
else
x = x->right();
@@ -414,7 +405,7 @@ private:
if (!y)
m_root = z;
else {
- if (z->m_key < y->m_key)
+ if (z->key() < y->key())
y->setLeft(z);
else
y->setRight(z);
@@ -427,10 +418,10 @@ private:
// Left-rotates the subtree rooted at x.
// Returns the new root of the subtree (x's right child).
- Node* leftRotate(Node* x)
+ NodeType* leftRotate(NodeType* x)
{
// Set y.
- Node* y = x->right();
+ NodeType* y = x->right();
// Turn y's left subtree into x's right subtree.
x->setRight(y->left());
@@ -457,10 +448,10 @@ private:
// Right-rotates the subtree rooted at y.
// Returns the new root of the subtree (y's left child).
- Node* rightRotate(Node* y)
+ NodeType* rightRotate(NodeType* y)
{
// Set x.
- Node* x = y->left();
+ NodeType* x = y->left();
// Turn x's right subtree into y's left subtree.
y->setLeft(x->right());
@@ -488,7 +479,7 @@ private:
// Restores the red-black property to the tree after splicing out
// a node. Note that x may be null, which is why xParent must be
// supplied.
- void removeFixup(Node* x, Node* xParent)
+ void removeFixup(NodeType* x, NodeType* xParent)
{
while (x != m_root && (!x || x->color() == Black)) {
if (x == xParent->left()) {
@@ -496,7 +487,7 @@ private:
// The reason is not obvious from simply looking at
// the code; it comes about from the properties of the
// red-black tree.
- Node* w = xParent->right();
+ NodeType* w = xParent->right();
ASSERT(w); // x's sibling should not be null.
if (w->color() == Red) {
// Case 1
@@ -536,7 +527,7 @@ private:
// The reason is not obvious from simply looking at
// the code; it comes about from the properties of the
// red-black tree.
- Node* w = xParent->left();
+ NodeType* w = xParent->left();
ASSERT(w); // x's sibling should not be null.
if (w->color() == Red) {
// Case 1
@@ -574,7 +565,7 @@ private:
x->setColor(Black);
}
- Node* m_root;
+ NodeType* m_root;
};
}
diff --git a/Source/JavaScriptCore/wtf/RefCountedLeakCounter.h b/Source/JavaScriptCore/wtf/RefCountedLeakCounter.h
index 22c7506ac..476b1735a 100644
--- a/Source/JavaScriptCore/wtf/RefCountedLeakCounter.h
+++ b/Source/JavaScriptCore/wtf/RefCountedLeakCounter.h
@@ -27,14 +27,14 @@
namespace WTF {
struct RefCountedLeakCounter {
- static void suppressMessages(const char*);
- static void cancelMessageSuppression(const char*);
+ WTF_EXPORT_PRIVATE static void suppressMessages(const char*);
+ WTF_EXPORT_PRIVATE static void cancelMessageSuppression(const char*);
- explicit RefCountedLeakCounter(const char* description);
- ~RefCountedLeakCounter();
+ WTF_EXPORT_PRIVATE explicit RefCountedLeakCounter(const char* description);
+ WTF_EXPORT_PRIVATE ~RefCountedLeakCounter();
- void increment();
- void decrement();
+ WTF_EXPORT_PRIVATE void increment();
+ WTF_EXPORT_PRIVATE void decrement();
#ifndef NDEBUG
private:
diff --git a/Source/JavaScriptCore/wtf/SHA1.h b/Source/JavaScriptCore/wtf/SHA1.h
index dad6dc867..e8cc802e9 100644
--- a/Source/JavaScriptCore/wtf/SHA1.h
+++ b/Source/JavaScriptCore/wtf/SHA1.h
@@ -37,16 +37,16 @@ namespace WTF {
class SHA1 {
public:
- SHA1();
+ WTF_EXPORT_PRIVATE SHA1();
void addBytes(const Vector<uint8_t>& input)
{
addBytes(input.data(), input.size());
}
- void addBytes(const uint8_t* input, size_t length);
+ WTF_EXPORT_PRIVATE void addBytes(const uint8_t* input, size_t length);
// computeHash has a side effect of resetting the state of the object.
- void computeHash(Vector<uint8_t, 20>&);
+ WTF_EXPORT_PRIVATE void computeHash(Vector<uint8_t, 20>&);
private:
void finalize();
diff --git a/Source/JavaScriptCore/wtf/StdLibExtras.h b/Source/JavaScriptCore/wtf/StdLibExtras.h
index 3f99c4d3f..e4d7c8fc0 100644
--- a/Source/JavaScriptCore/wtf/StdLibExtras.h
+++ b/Source/JavaScriptCore/wtf/StdLibExtras.h
@@ -107,6 +107,13 @@ TypePtr reinterpret_cast_ptr(const void* ptr)
namespace WTF {
+static const size_t KB = 1024;
+
+inline bool isPointerAligned(void* p)
+{
+ return !((intptr_t)(p) & (sizeof(char*) - 1));
+}
+
/*
* C++'s idea of a reinterpret_cast lacks sufficient cojones.
*/
@@ -283,6 +290,8 @@ inline void* operator new(size_t, NotNullTag, void* location)
return location;
}
+using WTF::KB;
+using WTF::isPointerAligned;
using WTF::binarySearch;
using WTF::bitwise_cast;
using WTF::safeCast;
diff --git a/Source/JavaScriptCore/wtf/Threading.cpp b/Source/JavaScriptCore/wtf/Threading.cpp
index f2e0565e9..d8dbbae4f 100644
--- a/Source/JavaScriptCore/wtf/Threading.cpp
+++ b/Source/JavaScriptCore/wtf/Threading.cpp
@@ -89,7 +89,7 @@ ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char*
// This function is deprecated but needs to be kept around for backward
// compatibility. Use the 3-argument version of createThread above.
-ThreadIdentifier createThread(ThreadFunction entryPoint, void* data);
+WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunction entryPoint, void* data);
ThreadIdentifier createThread(ThreadFunction entryPoint, void* data)
{
diff --git a/Source/JavaScriptCore/wtf/Threading.h b/Source/JavaScriptCore/wtf/Threading.h
index 3a89757a9..1dee5da1c 100644
--- a/Source/JavaScriptCore/wtf/Threading.h
+++ b/Source/JavaScriptCore/wtf/Threading.h
@@ -83,11 +83,11 @@ typedef void* (*ThreadFunction)(void* argument);
// This function must be called from the main thread. It is safe to call it repeatedly.
// Darwin is an exception to this rule: it is OK to call it from any thread, the only
// requirement is that the calls are not reentrant.
-void initializeThreading();
+WTF_EXPORT_PRIVATE void initializeThreading();
// Returns 0 if thread creation failed.
// The thread name must be a literal since on some platforms it's passed in to the thread.
-ThreadIdentifier createThread(ThreadFunction, void*, const char* threadName);
+WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunction, void*, const char* threadName);
// Internal platform-specific createThread implementation.
ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char* threadName);
@@ -96,14 +96,14 @@ ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char* threadN
// Helpful for platforms where the thread name must be set from within the thread.
void initializeCurrentThreadInternal(const char* threadName);
-ThreadIdentifier currentThread();
-int waitForThreadCompletion(ThreadIdentifier, void**);
-void detachThread(ThreadIdentifier);
+WTF_EXPORT_PRIVATE ThreadIdentifier currentThread();
+WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier, void**);
+WTF_EXPORT_PRIVATE void detachThread(ThreadIdentifier);
-void yield();
+WTF_EXPORT_PRIVATE void yield();
-void lockAtomicallyInitializedStaticMutex();
-void unlockAtomicallyInitializedStaticMutex();
+WTF_EXPORT_PRIVATE void lockAtomicallyInitializedStaticMutex();
+WTF_EXPORT_PRIVATE void unlockAtomicallyInitializedStaticMutex();
} // namespace WTF
diff --git a/Source/JavaScriptCore/wtf/ThreadingPrimitives.h b/Source/JavaScriptCore/wtf/ThreadingPrimitives.h
index 1bed5d3ae..2ac42c8f1 100644
--- a/Source/JavaScriptCore/wtf/ThreadingPrimitives.h
+++ b/Source/JavaScriptCore/wtf/ThreadingPrimitives.h
@@ -82,12 +82,12 @@ typedef void* PlatformCondition;
class Mutex {
WTF_MAKE_NONCOPYABLE(Mutex); WTF_MAKE_FAST_ALLOCATED;
public:
- Mutex();
- ~Mutex();
+ WTF_EXPORT_PRIVATE Mutex();
+ WTF_EXPORT_PRIVATE ~Mutex();
- void lock();
- bool tryLock();
- void unlock();
+ WTF_EXPORT_PRIVATE void lock();
+ WTF_EXPORT_PRIVATE bool tryLock();
+ WTF_EXPORT_PRIVATE void unlock();
public:
PlatformMutex& impl() { return m_mutex; }
@@ -118,15 +118,15 @@ private:
class ThreadCondition {
WTF_MAKE_NONCOPYABLE(ThreadCondition);
public:
- ThreadCondition();
- ~ThreadCondition();
+ WTF_EXPORT_PRIVATE ThreadCondition();
+ WTF_EXPORT_PRIVATE ~ThreadCondition();
- void wait(Mutex& mutex);
+ WTF_EXPORT_PRIVATE void wait(Mutex& mutex);
// Returns true if the condition was signaled before absoluteTime, false if the absoluteTime was reached or is in the past.
// The absoluteTime is in seconds, starting on January 1, 1970. The time is assumed to use the same time zone as WTF::currentTime().
- bool timedWait(Mutex&, double absoluteTime);
- void signal();
- void broadcast();
+ WTF_EXPORT_PRIVATE bool timedWait(Mutex&, double absoluteTime);
+ WTF_EXPORT_PRIVATE void signal();
+ WTF_EXPORT_PRIVATE void broadcast();
private:
PlatformCondition m_condition;
diff --git a/Source/JavaScriptCore/wtf/Uint8Array.h b/Source/JavaScriptCore/wtf/Uint8Array.h
index 58fdb842b..a0959706c 100644
--- a/Source/JavaScriptCore/wtf/Uint8Array.h
+++ b/Source/JavaScriptCore/wtf/Uint8Array.h
@@ -46,7 +46,7 @@ public:
inline PassRefPtr<Uint8Array> subarray(int start) const;
inline PassRefPtr<Uint8Array> subarray(int start, int end) const;
-private:
+protected:
inline Uint8Array(PassRefPtr<ArrayBuffer>,
unsigned byteOffset,
unsigned length);
diff --git a/Source/JavaScriptCore/wtf/Uint8ClampedArray.h b/Source/JavaScriptCore/wtf/Uint8ClampedArray.h
new file mode 100644
index 000000000..f1044091b
--- /dev/null
+++ b/Source/JavaScriptCore/wtf/Uint8ClampedArray.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+ */
+
+#ifndef Uint8ClampedArray_h
+#define Uint8ClampedArray_h
+
+#include "Uint8Array.h"
+
+namespace WTF {
+
+class Uint8ClampedArray : public Uint8Array {
+public:
+ static inline PassRefPtr<Uint8ClampedArray> create(unsigned length);
+ static inline PassRefPtr<Uint8ClampedArray> create(unsigned char* array, unsigned length);
+ static inline PassRefPtr<Uint8ClampedArray> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length);
+
+ // Can’t use "using" here due to a bug in the RVCT compiler.
+ bool set(TypedArrayBase<unsigned char>* array, unsigned offset) { return TypedArrayBase<unsigned char>::set(array, offset); }
+ inline void set(unsigned index, double value);
+
+ inline PassRefPtr<Uint8ClampedArray> subarray(int start) const;
+ inline PassRefPtr<Uint8ClampedArray> subarray(int start, int end) const;
+
+private:
+ inline Uint8ClampedArray(PassRefPtr<ArrayBuffer>,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<unsigned char>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isUnsignedByteClampedArray() const { return true; }
+};
+
+PassRefPtr<Uint8ClampedArray> Uint8ClampedArray::create(unsigned length)
+{
+ return TypedArrayBase<unsigned char>::create<Uint8ClampedArray>(length);
+}
+
+PassRefPtr<Uint8ClampedArray> Uint8ClampedArray::create(unsigned char* array, unsigned length)
+{
+ return TypedArrayBase<unsigned char>::create<Uint8ClampedArray>(array, length);
+}
+
+PassRefPtr<Uint8ClampedArray> Uint8ClampedArray::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<unsigned char>::create<Uint8ClampedArray>(buffer, byteOffset, length);
+}
+
+void Uint8ClampedArray::set(unsigned index, double value)
+{
+ if (index >= m_length)
+ return;
+ if (isnan(value) || value < 0)
+ value = 0;
+ else if (value > 255)
+ value = 255;
+ data()[index] = static_cast<unsigned char>(value + 0.5);
+}
+
+Uint8ClampedArray::Uint8ClampedArray(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+: Uint8Array(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<Uint8ClampedArray> Uint8ClampedArray::subarray(int start) const
+{
+ return subarray(start, length());
+}
+
+PassRefPtr<Uint8ClampedArray> Uint8ClampedArray::subarray(int start, int end) const
+{
+ return subarrayImpl<Uint8ClampedArray>(start, end);
+}
+
+} // namespace WTF
+
+using WTF::Uint8ClampedArray;
+
+#endif // Uint8ClampedArray_h
diff --git a/Source/JavaScriptCore/wtf/Vector.h b/Source/JavaScriptCore/wtf/Vector.h
index 1368ac99b..175f1a582 100644
--- a/Source/JavaScriptCore/wtf/Vector.h
+++ b/Source/JavaScriptCore/wtf/Vector.h
@@ -194,7 +194,7 @@ namespace WTF {
static bool compare(const T* a, const T* b, size_t size)
{
for (size_t i = 0; i < size; ++i)
- if (a[i] != b[i])
+ if (!(a[i] == b[i]))
return false;
return true;
}
diff --git a/Source/JavaScriptCore/wtf/WTFThreadData.h b/Source/JavaScriptCore/wtf/WTFThreadData.h
index 81b817f6f..b02d10d7c 100644
--- a/Source/JavaScriptCore/wtf/WTFThreadData.h
+++ b/Source/JavaScriptCore/wtf/WTFThreadData.h
@@ -78,8 +78,8 @@ typedef void (*AtomicStringTableDestructor)(AtomicStringTable*);
class WTFThreadData {
WTF_MAKE_NONCOPYABLE(WTFThreadData);
public:
- WTFThreadData();
- ~WTFThreadData();
+ WTF_EXPORT_PRIVATE WTFThreadData();
+ WTF_EXPORT_PRIVATE ~WTFThreadData();
AtomicStringTable* atomicStringTable()
{
diff --git a/Source/JavaScriptCore/wtf/dtoa.h b/Source/JavaScriptCore/wtf/dtoa.h
index df33e2cdc..d27c59206 100644
--- a/Source/JavaScriptCore/wtf/dtoa.h
+++ b/Source/JavaScriptCore/wtf/dtoa.h
@@ -31,19 +31,19 @@ extern WTF::Mutex* s_dtoaP5Mutex;
typedef char DtoaBuffer[80];
-void dtoa(DtoaBuffer result, double dd, bool& sign, int& exponent, unsigned& precision);
-void dtoaRoundSF(DtoaBuffer result, double dd, int ndigits, bool& sign, int& exponent, unsigned& precision);
-void dtoaRoundDP(DtoaBuffer result, double dd, int ndigits, bool& sign, int& exponent, unsigned& precision);
+WTF_EXPORT_PRIVATE void dtoa(DtoaBuffer result, double dd, bool& sign, int& exponent, unsigned& precision);
+WTF_EXPORT_PRIVATE void dtoaRoundSF(DtoaBuffer result, double dd, int ndigits, bool& sign, int& exponent, unsigned& precision);
+WTF_EXPORT_PRIVATE void dtoaRoundDP(DtoaBuffer result, double dd, int ndigits, bool& sign, int& exponent, unsigned& precision);
// s00: input string. Must not be 0 and must be terminated by 0.
// se: *se will have the last consumed character position + 1.
-double strtod(const char* s00, char** se);
+WTF_EXPORT_PRIVATE double strtod(const char* s00, char** se);
// Size = 80 for sizeof(DtoaBuffer) + some sign bits, decimal point, 'e', exponent digits.
const unsigned NumberToStringBufferLength = 96;
typedef char NumberToStringBuffer[NumberToStringBufferLength];
typedef UChar NumberToUStringBuffer[NumberToStringBufferLength];
-const char* numberToString(double, NumberToStringBuffer);
+WTF_EXPORT_PRIVATE const char* numberToString(double, NumberToStringBuffer);
const char* numberToFixedPrecisionString(double, unsigned significantFigures, NumberToStringBuffer, bool truncateTrailingZeros = false);
const char* numberToFixedWidthString(double, unsigned decimalPlaces, NumberToStringBuffer);
diff --git a/Source/JavaScriptCore/wtf/efl/OwnPtrEfl.cpp b/Source/JavaScriptCore/wtf/efl/OwnPtrEfl.cpp
index 7ec517029..3f3ad6420 100644
--- a/Source/JavaScriptCore/wtf/efl/OwnPtrEfl.cpp
+++ b/Source/JavaScriptCore/wtf/efl/OwnPtrEfl.cpp
@@ -29,6 +29,7 @@
#include <Ecore.h>
#include <Ecore_Evas.h>
+#include <Eina.h>
#include <Evas.h>
namespace WTF {
@@ -50,4 +51,10 @@ void deleteOwnedPtr(Ecore_Pipe* ptr)
ecore_pipe_del(ptr);
}
+void deleteOwnedPtr(Eina_Module* ptr)
+{
+ if (ptr)
+ eina_module_free(ptr); // If module wasn't unloaded, eina_module_free() calls eina_module_unload().
+}
+
}
diff --git a/Source/JavaScriptCore/wtf/gobject/GOwnPtr.cpp b/Source/JavaScriptCore/wtf/gobject/GOwnPtr.cpp
index 50c7b9ffc..c727956ce 100644
--- a/Source/JavaScriptCore/wtf/gobject/GOwnPtr.cpp
+++ b/Source/JavaScriptCore/wtf/gobject/GOwnPtr.cpp
@@ -49,6 +49,18 @@ template <> void freeOwnedGPtr<GDir>(GDir* ptr)
g_dir_close(ptr);
}
+template <> void freeOwnedGPtr<GTimer>(GTimer* ptr)
+{
+ if (ptr)
+ g_timer_destroy(ptr);
+}
+
+template <> void freeOwnedGPtr<GKeyFile>(GKeyFile* ptr)
+{
+ if (ptr)
+ g_key_file_free(ptr);
+}
+
} // namespace WTF
#endif // ENABLE(GLIB_SUPPORT)
diff --git a/Source/JavaScriptCore/wtf/gobject/GOwnPtr.h b/Source/JavaScriptCore/wtf/gobject/GOwnPtr.h
index 9ff85c5a4..221971f97 100644
--- a/Source/JavaScriptCore/wtf/gobject/GOwnPtr.h
+++ b/Source/JavaScriptCore/wtf/gobject/GOwnPtr.h
@@ -37,6 +37,8 @@ template<> void freeOwnedGPtr<GError>(GError*);
template<> void freeOwnedGPtr<GList>(GList*);
template<> void freeOwnedGPtr<GPatternSpec>(GPatternSpec*);
template<> void freeOwnedGPtr<GDir>(GDir*);
+template<> void freeOwnedGPtr<GTimer>(GTimer*);
+template<> void freeOwnedGPtr<GKeyFile>(GKeyFile*);
template <typename T> class GOwnPtr {
WTF_MAKE_NONCOPYABLE(GOwnPtr);
diff --git a/Source/JavaScriptCore/wtf/gobject/GTypedefs.h b/Source/JavaScriptCore/wtf/gobject/GTypedefs.h
index 66cedd6d2..e2b2ba6b8 100644
--- a/Source/JavaScriptCore/wtf/gobject/GTypedefs.h
+++ b/Source/JavaScriptCore/wtf/gobject/GTypedefs.h
@@ -58,6 +58,8 @@ typedef struct _GSocketConnection GSocketConnection;
typedef struct _GSource GSource;
typedef struct _GVariant GVariant;
typedef union _GdkEvent GdkEvent;
+typedef struct _GTimer GTimer;
+typedef struct _GKeyFile GKeyFile;
#if USE(CAIRO)
typedef struct _cairo_surface cairo_surface_t;
diff --git a/Source/JavaScriptCore/wtf/text/AtomicString.cpp b/Source/JavaScriptCore/wtf/text/AtomicString.cpp
index 966879827..d775e7bb9 100644
--- a/Source/JavaScriptCore/wtf/text/AtomicString.cpp
+++ b/Source/JavaScriptCore/wtf/text/AtomicString.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
+ * Copyright (C) 2012 Google Inc. 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
@@ -250,11 +251,52 @@ PassRefPtr<StringImpl> AtomicString::add(const UChar* s)
return addToStringTable<UCharBuffer, UCharBufferTranslator>(buffer);
}
-PassRefPtr<StringImpl> AtomicString::addSlowCase(StringImpl* r)
+struct SubstringLocation {
+ StringImpl* baseString;
+ unsigned start;
+ unsigned length;
+};
+
+struct SubstringTranslator {
+ static unsigned hash(const SubstringLocation& buffer)
+ {
+ return StringHasher::computeHash(buffer.baseString->characters() + buffer.start, buffer.length);
+ }
+
+ static bool equal(StringImpl* const& string, const SubstringLocation& buffer)
+ {
+ return WTF::equal(string, buffer.baseString->characters() + buffer.start, buffer.length);
+ }
+
+ static void translate(StringImpl*& location, const SubstringLocation& buffer, unsigned hash)
+ {
+ location = StringImpl::create(buffer.baseString, buffer.start, buffer.length).leakRef();
+ location->setHash(hash);
+ location->setIsAtomic(true);
+ }
+};
+
+PassRefPtr<StringImpl> AtomicString::add(StringImpl* baseString, unsigned start, unsigned length)
{
- if (!r || r->isAtomic())
- return r;
+ if (!baseString)
+ return 0;
+
+ if (!length || start >= baseString->length())
+ return StringImpl::empty();
+ unsigned maxLength = baseString->length() - start;
+ if (length >= maxLength) {
+ if (!start)
+ return add(baseString);
+ length = maxLength;
+ }
+
+ SubstringLocation buffer = { baseString, start, length };
+ return addToStringTable<SubstringLocation, SubstringTranslator>(buffer);
+}
+
+PassRefPtr<StringImpl> AtomicString::addSlowCase(StringImpl* r)
+{
if (!r->length())
return StringImpl::empty();
diff --git a/Source/JavaScriptCore/wtf/text/AtomicString.h b/Source/JavaScriptCore/wtf/text/AtomicString.h
index 43b38d179..b135845fe 100644
--- a/Source/JavaScriptCore/wtf/text/AtomicString.h
+++ b/Source/JavaScriptCore/wtf/text/AtomicString.h
@@ -38,7 +38,7 @@ struct AtomicStringHash;
class AtomicString {
public:
- static void init();
+ WTF_EXPORT_PRIVATE static void init();
AtomicString() { }
AtomicString(const LChar* s) : m_string(add(s)) { }
@@ -49,12 +49,13 @@ public:
ATOMICSTRING_CONVERSION AtomicString(StringImpl* imp) : m_string(add(imp)) { }
AtomicString(AtomicStringImpl* imp) : m_string(imp) { }
ATOMICSTRING_CONVERSION AtomicString(const String& s) : m_string(add(s.impl())) { }
+ AtomicString(StringImpl* baseString, unsigned start, unsigned length) : m_string(add(baseString, start, length)) { }
// Hash table deleted values, which are only constructed and never copied or destroyed.
AtomicString(WTF::HashTableDeletedValueType) : m_string(WTF::HashTableDeletedValue) { }
bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedValue(); }
- static AtomicStringImpl* find(const UChar* s, unsigned length, unsigned existingHash);
+ WTF_EXPORT_PRIVATE static AtomicStringImpl* find(const UChar* s, unsigned length, unsigned existingHash);
operator const String&() const { return m_string; }
const String& string() const { return m_string; };
@@ -83,7 +84,7 @@ public:
bool endsWith(const String& s, bool caseSensitive = true) const
{ return m_string.endsWith(s, caseSensitive); }
- AtomicString lower() const;
+ WTF_EXPORT_PRIVATE AtomicString lower() const;
AtomicString upper() const { return AtomicString(impl()->upper()); }
int toInt(bool* ok = 0) const { return m_string.toInt(ok); }
@@ -120,20 +121,21 @@ public:
private:
String m_string;
- static PassRefPtr<StringImpl> add(const LChar*);
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> add(const LChar*);
ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s) { return add(reinterpret_cast<const LChar*>(s)); };
- static PassRefPtr<StringImpl> add(const UChar*, unsigned length);
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> add(const UChar*, unsigned length);
ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s, unsigned length) { return add(reinterpret_cast<const char*>(s), length); };
- static PassRefPtr<StringImpl> add(const UChar*, unsigned length, unsigned existingHash);
- static PassRefPtr<StringImpl> add(const UChar*);
- ALWAYS_INLINE PassRefPtr<StringImpl> add(StringImpl* r)
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> add(const UChar*, unsigned length, unsigned existingHash);
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> add(const UChar*);
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> add(StringImpl*, unsigned offset, unsigned length);
+ ALWAYS_INLINE static PassRefPtr<StringImpl> add(StringImpl* r)
{
if (!r || r->isAtomic())
return r;
return addSlowCase(r);
}
- static PassRefPtr<StringImpl> addSlowCase(StringImpl*);
- static AtomicString fromUTF8Internal(const char*, const char*);
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> addSlowCase(StringImpl*);
+ WTF_EXPORT_PRIVATE static AtomicString fromUTF8Internal(const char*, const char*);
};
inline bool operator==(const AtomicString& a, const AtomicString& b) { return a.impl() == b.impl(); }
diff --git a/Source/JavaScriptCore/wtf/text/CString.h b/Source/JavaScriptCore/wtf/text/CString.h
index 343a7a525..d43ad4bd7 100644
--- a/Source/JavaScriptCore/wtf/text/CString.h
+++ b/Source/JavaScriptCore/wtf/text/CString.h
@@ -52,16 +52,16 @@ private:
class CString {
public:
CString() { }
- CString(const char*);
- CString(const char*, size_t length);
+ WTF_EXPORT_PRIVATE CString(const char*);
+ WTF_EXPORT_PRIVATE CString(const char*, size_t length);
CString(CStringBuffer* buffer) : m_buffer(buffer) { }
- static CString newUninitialized(size_t length, char*& characterBuffer);
+ WTF_EXPORT_PRIVATE static CString newUninitialized(size_t length, char*& characterBuffer);
const char* data() const
{
return m_buffer ? m_buffer->data() : 0;
}
- char* mutableData();
+ WTF_EXPORT_PRIVATE char* mutableData();
size_t length() const
{
return m_buffer ? m_buffer->length() - 1 : 0;
@@ -77,7 +77,7 @@ private:
RefPtr<CStringBuffer> m_buffer;
};
-bool operator==(const CString& a, const CString& b);
+WTF_EXPORT_PRIVATE bool operator==(const CString& a, const CString& b);
inline bool operator!=(const CString& a, const CString& b) { return !(a == b); }
} // namespace WTF
diff --git a/Source/JavaScriptCore/wtf/text/StringBuilder.cpp b/Source/JavaScriptCore/wtf/text/StringBuilder.cpp
index 6d3c310e6..4eac75649 100644
--- a/Source/JavaScriptCore/wtf/text/StringBuilder.cpp
+++ b/Source/JavaScriptCore/wtf/text/StringBuilder.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,7 +33,7 @@ namespace WTF {
static const unsigned minimumCapacity = 16;
-void StringBuilder::reifyString()
+void StringBuilder::reifyString() const
{
// Check if the string already exists.
if (!m_string.isNull()) {
@@ -68,6 +69,7 @@ void StringBuilder::resize(unsigned newSize)
// If there is a buffer, we only need to duplicate it if it has more than one ref.
if (m_buffer) {
+ m_string = String(); // Clear the string to remove the reference to m_buffer if any before checking the reference count of m_buffer.
if (!m_buffer->hasOneRef()) {
if (m_buffer->is8Bit())
allocateBuffer(m_buffer->characters8(), m_buffer->length());
@@ -75,7 +77,6 @@ void StringBuilder::resize(unsigned newSize)
allocateBuffer(m_buffer->characters16(), m_buffer->length());
}
m_length = newSize;
- m_string = String();
return;
}
@@ -285,10 +286,15 @@ void StringBuilder::append(const LChar* characters, unsigned length)
}
}
+bool StringBuilder::canShrink() const
+{
+ // Only shrink the buffer if it's less than 80% full. Need to tune this heuristic!
+ return m_buffer && m_buffer->length() > (m_length + (m_length >> 2));
+}
+
void StringBuilder::shrinkToFit()
{
- // If the buffer is at least 80% full, don't bother copying. Need to tune this heuristic!
- if (m_buffer && m_buffer->length() > (m_length + (m_length >> 2))) {
+ if (canShrink()) {
if (m_is8Bit)
reallocateBuffer<LChar>(m_length);
else
diff --git a/Source/JavaScriptCore/wtf/text/StringBuilder.h b/Source/JavaScriptCore/wtf/text/StringBuilder.h
index da1e8320d..d896d17b1 100644
--- a/Source/JavaScriptCore/wtf/text/StringBuilder.h
+++ b/Source/JavaScriptCore/wtf/text/StringBuilder.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,12 +27,15 @@
#ifndef StringBuilder_h
#define StringBuilder_h
-#include <wtf/Vector.h>
+#include <wtf/text/AtomicString.h>
#include <wtf/text/WTFString.h>
namespace WTF {
class StringBuilder {
+ // Disallow copying since it's expensive and we don't want code to do it by accident.
+ WTF_MAKE_NONCOPYABLE(StringBuilder);
+
public:
StringBuilder()
: m_length(0)
@@ -41,8 +45,8 @@ public:
{
}
- void append(const UChar*, unsigned);
- void append(const LChar*, unsigned);
+ WTF_EXPORT_PRIVATE void append(const UChar*, unsigned);
+ WTF_EXPORT_PRIVATE void append(const LChar*, unsigned);
ALWAYS_INLINE void append(const char* characters, unsigned length) { append(reinterpret_cast<const LChar*>(characters), length); }
@@ -51,9 +55,8 @@ public:
if (!string.length())
return;
- // If we're appending to an empty string, and there is not buffer
- // (in case reserveCapacity has been called) then just retain the
- // string.
+ // If we're appending to an empty string, and there is not a buffer (reserveCapacity has not been called)
+ // then just retain the string.
if (!m_length && !m_buffer) {
m_string = string;
m_length = string.length();
@@ -67,6 +70,36 @@ public:
append(string.characters16(), string.length());
}
+ void append(const StringBuilder& other)
+ {
+ if (!other.m_length)
+ return;
+
+ // If we're appending to an empty string, and there is not a buffer (reserveCapacity has not been called)
+ // then just retain the string.
+ if (!m_length && !m_buffer && !other.m_string.isNull()) {
+ m_string = other.m_string;
+ m_length = other.m_length;
+ return;
+ }
+
+ append(other.characters(), other.m_length);
+ }
+
+ void append(const String& string, unsigned offset, unsigned length)
+ {
+ if (!string.length())
+ return;
+
+ if ((offset + length) > string.length())
+ return;
+
+ if (string.is8Bit())
+ append(string.characters8() + offset, length);
+ else
+ append(string.characters16() + offset, length);
+ }
+
void append(const char* characters)
{
if (characters)
@@ -94,44 +127,59 @@ public:
void append(char c)
{
- if (m_buffer && m_length < m_buffer->length() && m_string.isNull()) {
- if (m_is8Bit)
- m_bufferCharacters8[m_length++] = (LChar)c;
- else
- m_bufferCharacters16[m_length++] = (LChar)c;
- }
- else
- append(&c, 1);
+ append(static_cast<LChar>(c));
}
String toString()
{
- if (m_string.isNull()) {
- shrinkToFit();
+ shrinkToFit();
+ if (m_string.isNull())
reifyString();
- }
return m_string;
}
- String toStringPreserveCapacity()
+ const String& toStringPreserveCapacity() const
{
if (m_string.isNull())
reifyString();
return m_string;
}
+ AtomicString toAtomicString() const
+ {
+ if (!m_length)
+ return AtomicString();
+
+ // If the buffer is sufficiently over-allocated, make a new AtomicString from a copy so its buffer is not so large.
+ if (canShrink())
+ return AtomicString(characters(), length());
+
+ if (!m_string.isNull())
+ return AtomicString(m_string);
+
+ ASSERT(m_buffer);
+ return AtomicString(m_buffer.get(), 0, m_length);
+ }
+
unsigned length() const
{
return m_length;
}
- bool isEmpty() const { return !length(); }
+ bool isEmpty() const { return !m_length; }
- void reserveCapacity(unsigned newCapacity);
+ WTF_EXPORT_PRIVATE void reserveCapacity(unsigned newCapacity);
- void resize(unsigned newSize);
+ unsigned capacity() const
+ {
+ return m_buffer ? m_buffer->length() : m_length;
+ }
+
+ WTF_EXPORT_PRIVATE void resize(unsigned newSize);
+
+ WTF_EXPORT_PRIVATE bool canShrink() const;
- void shrinkToFit();
+ WTF_EXPORT_PRIVATE void shrinkToFit();
UChar operator[](unsigned i) const
{
@@ -178,6 +226,8 @@ public:
return m_buffer->characters();
}
+ bool is8Bit() const { return m_is8Bit; }
+
void clear()
{
m_length = 0;
@@ -188,6 +238,16 @@ public:
m_valid16BitShadowLength = 0;
}
+ void swap(StringBuilder& stringBuilder)
+ {
+ std::swap(m_length, stringBuilder.m_length);
+ m_string.swap(stringBuilder.m_string);
+ m_buffer.swap(stringBuilder.m_buffer);
+ std::swap(m_is8Bit, stringBuilder.m_is8Bit);
+ std::swap(m_valid16BitShadowLength, stringBuilder.m_valid16BitShadowLength);
+ std::swap(m_bufferCharacters8, stringBuilder.m_bufferCharacters8);
+ }
+
private:
void allocateBuffer(const LChar* currentCharacters, unsigned requiredLength);
void allocateBuffer(const UChar* currentCharacters, unsigned requiredLength);
@@ -200,10 +260,10 @@ private:
CharType* appendUninitializedSlow(unsigned length);
template <typename CharType>
ALWAYS_INLINE CharType * getBufferCharacters();
- void reifyString();
+ WTF_EXPORT_PRIVATE void reifyString() const;
unsigned m_length;
- String m_string;
+ mutable String m_string;
RefPtr<StringImpl> m_buffer;
bool m_is8Bit;
mutable unsigned m_valid16BitShadowLength;
@@ -227,6 +287,45 @@ ALWAYS_INLINE UChar* StringBuilder::getBufferCharacters<UChar>()
return m_bufferCharacters16;
}
+template <typename CharType>
+bool equal(const StringBuilder& s, const CharType* buffer, unsigned length)
+{
+ if (s.length() != length)
+ return false;
+
+ if (s.is8Bit())
+ return equal(s.characters8(), buffer, length);
+
+ return equal(s.characters16(), buffer, length);
+}
+
+template <typename StringType>
+bool equal(const StringBuilder& a, const StringType& b)
+{
+ if (a.length() != b.length())
+ return false;
+
+ if (!a.length())
+ return true;
+
+ if (a.is8Bit()) {
+ if (b.is8Bit())
+ return equal(a.characters8(), b.characters8(), a.length());
+ return equal(a.characters8(), b.characters16(), a.length());
+ }
+
+ if (b.is8Bit())
+ return equal(a.characters16(), b.characters8(), a.length());
+ return equal(a.characters16(), b.characters16(), a.length());
+}
+
+inline bool operator==(const StringBuilder& a, const StringBuilder& b) { return equal(a, b); }
+inline bool operator!=(const StringBuilder& a, const StringBuilder& b) { return !equal(a, b); }
+inline bool operator==(const StringBuilder& a, const String& b) { return equal(a, b); }
+inline bool operator!=(const StringBuilder& a, const String& b) { return !equal(a, b); }
+inline bool operator==(const String& a, const StringBuilder& b) { return equal(b, a); }
+inline bool operator!=(const String& a, const StringBuilder& b) { return !equal(b, a); }
+
} // namespace WTF
using WTF::StringBuilder;
diff --git a/Source/JavaScriptCore/wtf/text/StringHash.h b/Source/JavaScriptCore/wtf/text/StringHash.h
index cde591c18..1b7a2ee2c 100644
--- a/Source/JavaScriptCore/wtf/text/StringHash.h
+++ b/Source/JavaScriptCore/wtf/text/StringHash.h
@@ -100,7 +100,9 @@ namespace WTF {
static unsigned hash(StringImpl* str)
{
- return hash(str->characters(), str->length());
+ if (str->is8Bit())
+ return hash(str->characters8(), str->length());
+ return hash(str->characters16(), str->length());
}
static unsigned hash(const LChar* data, unsigned length)
diff --git a/Source/JavaScriptCore/wtf/text/StringImpl.cpp b/Source/JavaScriptCore/wtf/text/StringImpl.cpp
index aa5a8d56e..3f73556b5 100644
--- a/Source/JavaScriptCore/wtf/text/StringImpl.cpp
+++ b/Source/JavaScriptCore/wtf/text/StringImpl.cpp
@@ -30,6 +30,8 @@
#include "StringHash.h"
#include <wtf/StdLibExtras.h>
#include <wtf/WTFThreadData.h>
+#include <wtf/unicode/CharacterNames.h>
+
using namespace std;
@@ -378,19 +380,53 @@ PassRefPtr<StringImpl> StringImpl::upper()
return newImpl.release();
// Do a slower implementation for cases that include non-ASCII Latin-1 characters.
- for (int32_t i = 0; i < length; i++)
- data8[i] = static_cast<LChar>(Unicode::toUpper(m_data8[i]));
+ int numberSharpSCharacters = 0;
+
+ // There are two special cases.
+ // 1. latin-1 characters when converted to upper case are 16 bit characters.
+ // 2. Lower case sharp-S converts to "SS" (two characters)
+ for (int32_t i = 0; i < length; i++) {
+ LChar c = m_data8[i];
+ if (UNLIKELY(c == smallLetterSharpS))
+ numberSharpSCharacters++;
+ UChar upper = Unicode::toUpper(c);
+ if (UNLIKELY(upper > 0xff)) {
+ // Since this upper-cased character does not fit in an 8-bit string, we need to take the 16-bit path.
+ goto upconvert;
+ }
+ data8[i] = static_cast<LChar>(upper);
+ }
+
+ if (!numberSharpSCharacters)
+ return newImpl.release();
+
+ // We have numberSSCharacters sharp-s characters, but none of the other special characters.
+ newImpl = createUninitialized(m_length + numberSharpSCharacters, data8);
+
+ LChar* dest = data8;
+
+ for (int32_t i = 0; i < length; i++) {
+ LChar c = m_data8[i];
+ if (c == smallLetterSharpS) {
+ *dest++ = 'S';
+ *dest++ = 'S';
+ } else
+ *dest++ = static_cast<LChar>(Unicode::toUpper(c));
+ }
return newImpl.release();
}
+upconvert:
+ const UChar* source16 = characters();
+
UChar* data16;
RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16);
// Do a faster loop for the case where all the characters are ASCII.
UChar ored = 0;
for (int i = 0; i < length; i++) {
- UChar c = m_data16[i];
+ UChar c = source16[i];
ored |= c;
data16[i] = toASCIIUpper(c);
}
@@ -400,11 +436,11 @@ PassRefPtr<StringImpl> StringImpl::upper()
// Do a slower implementation for cases that include non-ASCII characters.
bool error;
newImpl = createUninitialized(m_length, data16);
- int32_t realLength = Unicode::toUpper(data16, length, m_data16, m_length, &error);
+ int32_t realLength = Unicode::toUpper(data16, length, source16, m_length, &error);
if (!error && realLength == length)
return newImpl;
newImpl = createUninitialized(realLength, data16);
- Unicode::toUpper(data16, realLength, m_data16, m_length, &error);
+ Unicode::toUpper(data16, realLength, source16, m_length, &error);
if (error)
return this;
return newImpl.release();
@@ -715,6 +751,16 @@ float StringImpl::toFloat(bool* ok, bool* didReadNumber)
return charactersToFloat(characters16(), m_length, ok, didReadNumber);
}
+bool equalIgnoringCase(const LChar* a, const LChar* b, unsigned length)
+{
+ while (length--) {
+ LChar bc = *b++;
+ if (foldCase(*a++) != foldCase(bc))
+ return false;
+ }
+ return true;
+}
+
bool equalIgnoringCase(const UChar* a, const LChar* b, unsigned length)
{
while (length--) {
@@ -849,6 +895,35 @@ size_t StringImpl::findIgnoringCase(const LChar* matchString, unsigned index)
return index + i;
}
+template <typename CharType>
+ALWAYS_INLINE static size_t findInner(const CharType* searchCharacters, const CharType* matchCharacters, unsigned index, unsigned searchLength, unsigned matchLength)
+{
+ // Optimization: keep a running hash of the strings,
+ // only call memcmp if the hashes match.
+
+ // delta is the number of additional times to test; delta == 0 means test only once.
+ unsigned delta = searchLength - matchLength;
+
+ unsigned searchHash = 0;
+ unsigned matchHash = 0;
+
+ for (unsigned i = 0; i < matchLength; ++i) {
+ searchHash += searchCharacters[i];
+ matchHash += matchCharacters[i];
+ }
+
+ unsigned i = 0;
+ // keep looping until we match
+ while (searchHash != matchHash || memcmp(searchCharacters + i, matchCharacters, matchLength * sizeof(CharType))) {
+ if (i == delta)
+ return notFound;
+ searchHash += searchCharacters[i + matchLength];
+ searchHash -= searchCharacters[i];
+ ++i;
+ }
+ return index + i;
+}
+
size_t StringImpl::find(StringImpl* matchString, unsigned index)
{
// Check for null or empty string to match against
@@ -871,31 +946,12 @@ size_t StringImpl::find(StringImpl* matchString, unsigned index)
unsigned searchLength = length() - index;
if (matchLength > searchLength)
return notFound;
- // delta is the number of additional times to test; delta == 0 means test only once.
- unsigned delta = searchLength - matchLength;
- const UChar* searchCharacters = characters() + index;
- const UChar* matchCharacters = matchString->characters();
+ if (is8Bit() && matchString->is8Bit())
+ return findInner(characters8() + index, matchString->characters8(), index, searchLength, matchLength);
- // Optimization 2: keep a running hash of the strings,
- // only call memcmp if the hashes match.
- unsigned searchHash = 0;
- unsigned matchHash = 0;
- for (unsigned i = 0; i < matchLength; ++i) {
- searchHash += searchCharacters[i];
- matchHash += matchCharacters[i];
- }
+ return findInner(characters() + index, matchString->characters(), index, searchLength, matchLength);
- unsigned i = 0;
- // keep looping until we match
- while (searchHash != matchHash || memcmp(searchCharacters + i, matchCharacters, matchLength * sizeof(UChar))) {
- if (i == delta)
- return notFound;
- searchHash += searchCharacters[i + matchLength];
- searchHash -= searchCharacters[i];
- ++i;
- }
- return index + i;
}
size_t StringImpl::findIgnoringCase(StringImpl* matchString, unsigned index)
@@ -936,33 +992,15 @@ size_t StringImpl::reverseFind(UChar c, unsigned index)
return WTF::reverseFind(characters16(), m_length, c, index);
}
-size_t StringImpl::reverseFind(StringImpl* matchString, unsigned index)
+template <typename CharType>
+ALWAYS_INLINE static size_t reverseFindInner(const CharType* searchCharacters, const CharType* matchCharacters, unsigned index, unsigned length, unsigned matchLength)
{
- // Check for null or empty string to match against
- if (!matchString)
- return notFound;
- unsigned matchLength = matchString->length();
- if (!matchLength)
- return min(index, length());
-
- // Optimization 1: fast case for strings of length 1.
- if (matchLength == 1) {
- if (is8Bit() && matchString->is8Bit())
- return WTF::reverseFind(characters8(), length(), matchString->characters8()[0], index);
- return WTF::reverseFind(characters(), length(), matchString->characters()[0], index);
- }
+ // Optimization: keep a running hash of the strings,
+ // only call memcmp if the hashes match.
- // Check index & matchLength are in range.
- if (matchLength > length())
- return notFound;
// delta is the number of additional times to test; delta == 0 means test only once.
- unsigned delta = min(index, length() - matchLength);
-
- const UChar *searchCharacters = characters();
- const UChar *matchCharacters = matchString->characters();
-
- // Optimization 2: keep a running hash of the strings,
- // only call memcmp if the hashes match.
+ unsigned delta = min(index, length - matchLength);
+
unsigned searchHash = 0;
unsigned matchHash = 0;
for (unsigned i = 0; i < matchLength; ++i) {
@@ -971,7 +1009,7 @@ size_t StringImpl::reverseFind(StringImpl* matchString, unsigned index)
}
// keep looping until we match
- while (searchHash != matchHash || memcmp(searchCharacters + delta, matchCharacters, matchLength * sizeof(UChar))) {
+ while (searchHash != matchHash || memcmp(searchCharacters + delta, matchCharacters, matchLength * sizeof(CharType))) {
if (!delta)
return notFound;
delta--;
@@ -981,6 +1019,33 @@ size_t StringImpl::reverseFind(StringImpl* matchString, unsigned index)
return delta;
}
+size_t StringImpl::reverseFind(StringImpl* matchString, unsigned index)
+{
+ // Check for null or empty string to match against
+ if (!matchString)
+ return notFound;
+ unsigned matchLength = matchString->length();
+ unsigned ourLength = length();
+ if (!matchLength)
+ return min(index, ourLength);
+
+ // Optimization 1: fast case for strings of length 1.
+ if (matchLength == 1) {
+ if (is8Bit() && matchString->is8Bit())
+ return WTF::reverseFind(characters8(), ourLength, matchString->characters8()[0], index);
+ return WTF::reverseFind(characters(), ourLength, matchString->characters()[0], index);
+ }
+
+ // Check index & matchLength are in range.
+ if (matchLength > ourLength)
+ return notFound;
+
+ if (is8Bit() && matchString->is8Bit())
+ return reverseFindInner(characters8(), matchString->characters8(), index, ourLength, matchLength);
+
+ return reverseFindInner(characters(), matchString->characters(), index, ourLength, matchLength);
+}
+
size_t StringImpl::reverseFindIgnoringCase(StringImpl* matchString, unsigned index)
{
// Check for null or empty string to match against
@@ -995,7 +1060,20 @@ size_t StringImpl::reverseFindIgnoringCase(StringImpl* matchString, unsigned ind
return notFound;
// delta is the number of additional times to test; delta == 0 means test only once.
unsigned delta = min(index, length() - matchLength);
-
+
+ if (is8Bit() && matchString->is8Bit()) {
+ const LChar *searchCharacters = characters8();
+ const LChar *matchCharacters = matchString->characters8();
+
+ // keep looping until we match
+ while (!equalIgnoringCase(searchCharacters + delta, matchCharacters, matchLength)) {
+ if (!delta)
+ return notFound;
+ delta--;
+ }
+ return delta;
+ }
+
const UChar *searchCharacters = characters();
const UChar *matchCharacters = matchString->characters();
diff --git a/Source/JavaScriptCore/wtf/text/StringImpl.h b/Source/JavaScriptCore/wtf/text/StringImpl.h
index 003c44ce6..3862effb6 100644
--- a/Source/JavaScriptCore/wtf/text/StringImpl.h
+++ b/Source/JavaScriptCore/wtf/text/StringImpl.h
@@ -52,6 +52,7 @@ namespace WTF {
struct CStringTranslator;
struct HashAndCharactersTranslator;
struct HashAndUTF8CharactersTranslator;
+struct SubstringTranslator;
struct UCharBufferTranslator;
enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive };
@@ -68,6 +69,7 @@ class StringImpl {
friend struct WTF::CStringTranslator;
friend struct WTF::HashAndCharactersTranslator;
friend struct WTF::HashAndUTF8CharactersTranslator;
+ friend struct WTF::SubstringTranslator;
friend struct WTF::UCharBufferTranslator;
friend class AtomicStringImpl;
@@ -190,12 +192,12 @@ private:
}
public:
- ~StringImpl();
+ WTF_EXPORT_PRIVATE ~StringImpl();
- static PassRefPtr<StringImpl> create(const UChar*, unsigned length);
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> create(const UChar*, unsigned length);
static PassRefPtr<StringImpl> create(const LChar*, unsigned length);
ALWAYS_INLINE static PassRefPtr<StringImpl> create(const char* s, unsigned length) { return create(reinterpret_cast<const LChar*>(s), length); }
- static PassRefPtr<StringImpl> create(const LChar*);
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> create(const LChar*);
ALWAYS_INLINE static PassRefPtr<StringImpl> create(const char* s) { return create(reinterpret_cast<const LChar*>(s)); }
static ALWAYS_INLINE PassRefPtr<StringImpl> create8(PassRefPtr<StringImpl> rep, unsigned offset, unsigned length)
@@ -226,7 +228,7 @@ public:
}
static PassRefPtr<StringImpl> createUninitialized(unsigned length, LChar*& data);
- static PassRefPtr<StringImpl> createUninitialized(unsigned length, UChar*& data);
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> createUninitialized(unsigned length, UChar*& data);
template <typename T> static ALWAYS_INLINE PassRefPtr<StringImpl> tryCreateUninitialized(unsigned length, T*& output)
{
if (!length) {
@@ -275,7 +277,7 @@ public:
}
static PassRefPtr<StringImpl> adopt(StringBuffer<LChar>& buffer);
- static PassRefPtr<StringImpl> adopt(StringBuffer<UChar>& buffer);
+ WTF_EXPORT_PRIVATE static PassRefPtr<StringImpl> adopt(StringBuffer<UChar>& buffer);
unsigned length() const { return m_length; }
bool is8Bit() const { return m_hashAndFlags & s_hashFlag8BitBuffer; }
@@ -308,7 +310,7 @@ public:
}
bool has16BitShadow() const { return m_hashAndFlags & s_hashFlagHas16BitShadow; }
- void upconvertCharacters(unsigned, unsigned) const;
+ WTF_EXPORT_PRIVATE void upconvertCharacters(unsigned, unsigned) const;
bool isIdentifier() const { return m_hashAndFlags & s_hashFlagIsIdentifier; }
void setIsIdentifier(bool isIdentifier)
{
@@ -393,7 +395,7 @@ public:
m_refCount -= s_refCountIncrement;
}
- static StringImpl* empty();
+ WTF_EXPORT_PRIVATE static StringImpl* empty();
// FIXME: Does this really belong in StringImpl?
template <typename T> static void copyChars(T* destination, const T* source, unsigned numCharacters)
@@ -428,7 +430,7 @@ public:
// its own copy of the string.
PassRefPtr<StringImpl> isolatedCopy() const;
- PassRefPtr<StringImpl> substring(unsigned pos, unsigned len = UINT_MAX);
+ WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> substring(unsigned pos, unsigned len = UINT_MAX);
UChar operator[](unsigned i) const
{
@@ -437,9 +439,9 @@ public:
return m_data8[i];
return m_data16[i];
}
- UChar32 characterStartingAt(unsigned);
+ WTF_EXPORT_PRIVATE UChar32 characterStartingAt(unsigned);
- bool containsOnlyWhitespace();
+ WTF_EXPORT_PRIVATE bool containsOnlyWhitespace();
int toIntStrict(bool* ok = 0, int base = 10);
unsigned toUIntStrict(bool* ok = 0, int base = 10);
@@ -447,7 +449,7 @@ public:
uint64_t toUInt64Strict(bool* ok = 0, int base = 10);
intptr_t toIntPtrStrict(bool* ok = 0, int base = 10);
- int toInt(bool* ok = 0); // ignores trailing garbage
+ WTF_EXPORT_PRIVATE int toInt(bool* ok = 0); // ignores trailing garbage
unsigned toUInt(bool* ok = 0); // ignores trailing garbage
int64_t toInt64(bool* ok = 0); // ignores trailing garbage
uint64_t toUInt64(bool* ok = 0); // ignores trailing garbage
@@ -456,44 +458,44 @@ public:
double toDouble(bool* ok = 0, bool* didReadNumber = 0);
float toFloat(bool* ok = 0, bool* didReadNumber = 0);
- PassRefPtr<StringImpl> lower();
- PassRefPtr<StringImpl> upper();
+ WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> lower();
+ WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> upper();
- PassRefPtr<StringImpl> fill(UChar);
+ WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> fill(UChar);
// FIXME: Do we need fill(char) or can we just do the right thing if UChar is ASCII?
PassRefPtr<StringImpl> foldCase();
PassRefPtr<StringImpl> stripWhiteSpace();
PassRefPtr<StringImpl> stripWhiteSpace(IsWhiteSpaceFunctionPtr);
- PassRefPtr<StringImpl> simplifyWhiteSpace();
+ WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> simplifyWhiteSpace();
PassRefPtr<StringImpl> simplifyWhiteSpace(IsWhiteSpaceFunctionPtr);
PassRefPtr<StringImpl> removeCharacters(CharacterMatchFunctionPtr);
template <typename CharType>
ALWAYS_INLINE PassRefPtr<StringImpl> removeCharacters(const CharType* characters, CharacterMatchFunctionPtr);
- size_t find(UChar, unsigned index = 0);
- size_t find(CharacterMatchFunctionPtr, unsigned index = 0);
+ WTF_EXPORT_PRIVATE size_t find(UChar, unsigned index = 0);
+ WTF_EXPORT_PRIVATE size_t find(CharacterMatchFunctionPtr, unsigned index = 0);
size_t find(const LChar*, unsigned index = 0);
ALWAYS_INLINE size_t find(const char* s, unsigned index = 0) { return find(reinterpret_cast<const LChar*>(s), index); };
- size_t find(StringImpl*, unsigned index = 0);
+ WTF_EXPORT_PRIVATE size_t find(StringImpl*, unsigned index = 0);
size_t findIgnoringCase(const LChar*, unsigned index = 0);
ALWAYS_INLINE size_t findIgnoringCase(const char* s, unsigned index = 0) { return findIgnoringCase(reinterpret_cast<const LChar*>(s), index); };
- size_t findIgnoringCase(StringImpl*, unsigned index = 0);
+ WTF_EXPORT_PRIVATE size_t findIgnoringCase(StringImpl*, unsigned index = 0);
- size_t reverseFind(UChar, unsigned index = UINT_MAX);
- size_t reverseFind(StringImpl*, unsigned index = UINT_MAX);
- size_t reverseFindIgnoringCase(StringImpl*, unsigned index = UINT_MAX);
+ WTF_EXPORT_PRIVATE size_t reverseFind(UChar, unsigned index = UINT_MAX);
+ WTF_EXPORT_PRIVATE size_t reverseFind(StringImpl*, unsigned index = UINT_MAX);
+ WTF_EXPORT_PRIVATE size_t reverseFindIgnoringCase(StringImpl*, unsigned index = UINT_MAX);
bool startsWith(StringImpl* str, bool caseSensitive = true) { return (caseSensitive ? reverseFind(str, 0) : reverseFindIgnoringCase(str, 0)) == 0; }
- bool endsWith(StringImpl*, bool caseSensitive = true);
+ WTF_EXPORT_PRIVATE bool endsWith(StringImpl*, bool caseSensitive = true);
- PassRefPtr<StringImpl> replace(UChar, UChar);
- PassRefPtr<StringImpl> replace(UChar, StringImpl*);
- PassRefPtr<StringImpl> replace(StringImpl*, StringImpl*);
- PassRefPtr<StringImpl> replace(unsigned index, unsigned len, StringImpl*);
+ WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> replace(UChar, UChar);
+ WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> replace(UChar, StringImpl*);
+ WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> replace(StringImpl*, StringImpl*);
+ WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> replace(unsigned index, unsigned len, StringImpl*);
- WTF::Unicode::Direction defaultWritingDirection(bool* hasStrongDirectionality = 0);
+ WTF_EXPORT_PRIVATE WTF::Unicode::Direction defaultWritingDirection(bool* hasStrongDirectionality = 0);
#if USE(CF)
CFStringRef createCFString();
@@ -510,8 +512,8 @@ private:
bool isStatic() const { return m_refCount & s_refCountFlagIsStaticString; }
template <class UCharPredicate> PassRefPtr<StringImpl> stripMatchedCharacters(UCharPredicate);
template <typename CharType, class UCharPredicate> PassRefPtr<StringImpl> simplifyMatchedCharactersToSpace(UCharPredicate);
- NEVER_INLINE const UChar* getData16SlowCase() const;
- NEVER_INLINE unsigned hashSlowCase() const;
+ WTF_EXPORT_PRIVATE NEVER_INLINE const UChar* getData16SlowCase() const;
+ WTF_EXPORT_PRIVATE NEVER_INLINE unsigned hashSlowCase() const;
// The bottom bit in the ref count indicates a static (immortal) string.
static const unsigned s_refCountFlagIsStaticString = 0x1;
@@ -548,16 +550,16 @@ template <>
ALWAYS_INLINE const LChar* StringImpl::getCharacters<LChar>() const { return characters8(); }
template <>
-ALWAYS_INLINE const UChar* StringImpl::getCharacters<UChar>() const { return characters16(); }
+ALWAYS_INLINE const UChar* StringImpl::getCharacters<UChar>() const { return characters(); }
-bool equal(const StringImpl*, const StringImpl*);
-bool equal(const StringImpl*, const LChar*);
+WTF_EXPORT_PRIVATE bool equal(const StringImpl*, const StringImpl*);
+WTF_EXPORT_PRIVATE bool equal(const StringImpl*, const LChar*);
inline bool equal(const StringImpl* a, const char* b) { return equal(a, reinterpret_cast<const LChar*>(b)); }
-bool equal(const StringImpl*, const LChar*, unsigned);
+WTF_EXPORT_PRIVATE bool equal(const StringImpl*, const LChar*, unsigned);
inline bool equal(const StringImpl* a, const char* b, unsigned length) { return equal(a, reinterpret_cast<const LChar*>(b), length); }
inline bool equal(const LChar* a, StringImpl* b) { return equal(b, a); }
inline bool equal(const char* a, StringImpl* b) { return equal(b, reinterpret_cast<const LChar*>(a)); }
-bool equal(const StringImpl*, const UChar*, unsigned);
+WTF_EXPORT_PRIVATE bool equal(const StringImpl*, const UChar*, unsigned);
// Do comparisons 8 or 4 bytes-at-a-time on architectures where it's safe.
#if CPU(X86_64)
@@ -715,15 +717,16 @@ ALWAYS_INLINE bool equal(const UChar* a, const LChar* b, unsigned length)
return true;
}
-bool equalIgnoringCase(StringImpl*, StringImpl*);
-bool equalIgnoringCase(StringImpl*, const LChar*);
+WTF_EXPORT_PRIVATE bool equalIgnoringCase(StringImpl*, StringImpl*);
+WTF_EXPORT_PRIVATE bool equalIgnoringCase(StringImpl*, const LChar*);
inline bool equalIgnoringCase(const LChar* a, StringImpl* b) { return equalIgnoringCase(b, a); }
-bool equalIgnoringCase(const UChar*, const LChar*, unsigned);
+WTF_EXPORT_PRIVATE bool equalIgnoringCase(const LChar*, const LChar*, unsigned);
+WTF_EXPORT_PRIVATE bool equalIgnoringCase(const UChar*, const LChar*, unsigned);
inline bool equalIgnoringCase(const UChar* a, const char* b, unsigned length) { return equalIgnoringCase(a, reinterpret_cast<const LChar*>(b), length); }
inline bool equalIgnoringCase(const LChar* a, const UChar* b, unsigned length) { return equalIgnoringCase(b, a, length); }
inline bool equalIgnoringCase(const char* a, const UChar* b, unsigned length) { return equalIgnoringCase(b, reinterpret_cast<const LChar*>(a), length); }
-bool equalIgnoringNullity(StringImpl*, StringImpl*);
+WTF_EXPORT_PRIVATE bool equalIgnoringNullity(StringImpl*, StringImpl*);
template<size_t inlineCapacity>
bool equalIgnoringNullity(const Vector<UChar, inlineCapacity>& a, StringImpl* b)
@@ -735,7 +738,7 @@ bool equalIgnoringNullity(const Vector<UChar, inlineCapacity>& a, StringImpl* b)
return !memcmp(a.data(), b->characters(), b->length());
}
-int codePointCompare(const StringImpl*, const StringImpl*);
+WTF_EXPORT_PRIVATE int codePointCompare(const StringImpl*, const StringImpl*);
static inline bool isSpaceOrNewline(UChar c)
{
diff --git a/Source/JavaScriptCore/wtf/text/WTFString.cpp b/Source/JavaScriptCore/wtf/text/WTFString.cpp
index 4c42ed6a2..df74c65af 100644
--- a/Source/JavaScriptCore/wtf/text/WTFString.cpp
+++ b/Source/JavaScriptCore/wtf/text/WTFString.cpp
@@ -687,6 +687,13 @@ CString String::latin1() const
// preserved, characters outside of this range are converted to '?'.
unsigned length = this->length();
+
+ if (!length)
+ return CString("", 0);
+
+ if (is8Bit())
+ return CString(reinterpret_cast<const char*>(this->characters8()), length);
+
const UChar* characters = this->characters();
char* characterBuffer;
diff --git a/Source/JavaScriptCore/wtf/text/WTFString.h b/Source/JavaScriptCore/wtf/text/WTFString.h
index 3cecc0afd..2d32e6916 100644
--- a/Source/JavaScriptCore/wtf/text/WTFString.h
+++ b/Source/JavaScriptCore/wtf/text/WTFString.h
@@ -62,9 +62,9 @@ struct StringHash;
// Declarations of string operations
-WTF_EXPORT_PRIVATE int charactersToIntStrict(const LChar*, size_t, bool* ok = 0, int base = 10);
+int charactersToIntStrict(const LChar*, size_t, bool* ok = 0, int base = 10);
WTF_EXPORT_PRIVATE int charactersToIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10);
-WTF_EXPORT_PRIVATE unsigned charactersToUIntStrict(const LChar*, size_t, bool* ok = 0, int base = 10);
+unsigned charactersToUIntStrict(const LChar*, size_t, bool* ok = 0, int base = 10);
WTF_EXPORT_PRIVATE unsigned charactersToUIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10);
int64_t charactersToInt64Strict(const LChar*, size_t, bool* ok = 0, int base = 10);
int64_t charactersToInt64Strict(const UChar*, size_t, bool* ok = 0, int base = 10);
@@ -74,7 +74,7 @@ intptr_t charactersToIntPtrStrict(const LChar*, size_t, bool* ok = 0, int base =
intptr_t charactersToIntPtrStrict(const UChar*, size_t, bool* ok = 0, int base = 10);
int charactersToInt(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
-int charactersToInt(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
+WTF_EXPORT_PRIVATE int charactersToInt(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
unsigned charactersToUInt(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
unsigned charactersToUInt(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
int64_t charactersToInt64(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
@@ -87,7 +87,7 @@ intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = 0); // ignores trai
WTF_EXPORT_PRIVATE double charactersToDouble(const LChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
WTF_EXPORT_PRIVATE double charactersToDouble(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
float charactersToFloat(const LChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
-float charactersToFloat(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
+WTF_EXPORT_PRIVATE float charactersToFloat(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
enum FloatConversionFlags {
ShouldRoundSignificantFigures = 1 << 0,
@@ -187,7 +187,7 @@ public:
return m_impl->characters()[index];
}
- WTF_EXPORT_PRIVATE static String number(short);
+ static String number(short);
WTF_EXPORT_PRIVATE static String number(unsigned short);
WTF_EXPORT_PRIVATE static String number(int);
WTF_EXPORT_PRIVATE static String number(unsigned);
@@ -301,8 +301,8 @@ public:
WTF_EXPORT_PRIVATE int toIntStrict(bool* ok = 0, int base = 10) const;
WTF_EXPORT_PRIVATE unsigned toUIntStrict(bool* ok = 0, int base = 10) const;
WTF_EXPORT_PRIVATE int64_t toInt64Strict(bool* ok = 0, int base = 10) const;
- WTF_EXPORT_PRIVATE uint64_t toUInt64Strict(bool* ok = 0, int base = 10) const;
- WTF_EXPORT_PRIVATE intptr_t toIntPtrStrict(bool* ok = 0, int base = 10) const;
+ uint64_t toUInt64Strict(bool* ok = 0, int base = 10) const;
+ intptr_t toIntPtrStrict(bool* ok = 0, int base = 10) const;
WTF_EXPORT_PRIVATE int toInt(bool* ok = 0) const;
WTF_EXPORT_PRIVATE unsigned toUInt(bool* ok = 0) const;
diff --git a/Source/JavaScriptCore/wtf/unicode/CharacterNames.h b/Source/JavaScriptCore/wtf/unicode/CharacterNames.h
index 10fdbf0ef..4acb5f0b1 100644
--- a/Source/JavaScriptCore/wtf/unicode/CharacterNames.h
+++ b/Source/JavaScriptCore/wtf/unicode/CharacterNames.h
@@ -72,6 +72,7 @@ const UChar rightToLeftEmbed = 0x202B;
const UChar rightToLeftMark = 0x200F;
const UChar rightToLeftOverride = 0x202E;
const UChar sesameDot = 0xFE45;
+const UChar smallLetterSharpS = 0x00DF;
const UChar softHyphen = 0x00AD;
const UChar space = 0x0020;
const UChar tibetanMarkIntersyllabicTsheg = 0x0F0B;
diff --git a/Source/JavaScriptCore/wtf/unicode/Collator.h b/Source/JavaScriptCore/wtf/unicode/Collator.h
index 00ab16e6a..7994ff8e5 100644
--- a/Source/JavaScriptCore/wtf/unicode/Collator.h
+++ b/Source/JavaScriptCore/wtf/unicode/Collator.h
@@ -45,13 +45,13 @@ namespace WTF {
public:
enum Result { Equal = 0, Greater = 1, Less = -1 };
- Collator(const char* locale); // Parsing is lenient; e.g. language identifiers (such as "en-US") are accepted, too.
- ~Collator();
- void setOrderLowerFirst(bool);
+ WTF_EXPORT_PRIVATE Collator(const char* locale); // Parsing is lenient; e.g. language identifiers (such as "en-US") are accepted, too.
+ WTF_EXPORT_PRIVATE ~Collator();
+ WTF_EXPORT_PRIVATE void setOrderLowerFirst(bool);
static PassOwnPtr<Collator> userDefault();
- Result collate(const ::UChar*, size_t, const ::UChar*, size_t) const;
+ WTF_EXPORT_PRIVATE Result collate(const ::UChar*, size_t, const ::UChar*, size_t) const;
private:
#if USE(ICU_UNICODE) && !UCONFIG_NO_COLLATION
diff --git a/Source/JavaScriptCore/wtf/unicode/UTF8.h b/Source/JavaScriptCore/wtf/unicode/UTF8.h
index bd3dd8a0a..bc2497b72 100644
--- a/Source/JavaScriptCore/wtf/unicode/UTF8.h
+++ b/Source/JavaScriptCore/wtf/unicode/UTF8.h
@@ -62,7 +62,7 @@ namespace Unicode {
// to the replacement character; otherwise (when the flag is set to strict)
// they constitute an error.
- ConversionResult convertUTF8ToUTF16(
+ WTF_EXPORT_PRIVATE ConversionResult convertUTF8ToUTF16(
const char** sourceStart, const char* sourceEnd,
UChar** targetStart, UChar* targetEnd, bool strict = true);
@@ -70,7 +70,7 @@ namespace Unicode {
const LChar** sourceStart, const LChar* sourceEnd,
char** targetStart, char* targetEnd);
- ConversionResult convertUTF16ToUTF8(
+ WTF_EXPORT_PRIVATE ConversionResult convertUTF16ToUTF8(
const UChar** sourceStart, const UChar* sourceEnd,
char** targetStart, char* targetEnd, bool strict = true);
diff --git a/Source/JavaScriptCore/wtf/wtf.pri b/Source/JavaScriptCore/wtf/wtf.pri
deleted file mode 100644
index 176949f75..000000000
--- a/Source/JavaScriptCore/wtf/wtf.pri
+++ /dev/null
@@ -1,42 +0,0 @@
-# -------------------------------------------------------------------
-# This file contains shared rules used both when building WTF itself
-# and for targets that depend in some way on WTF.
-#
-# See 'Tools/qmake/README' for an overview of the build system
-# -------------------------------------------------------------------
-
-load(features)
-
-SOURCE_DIR = $${ROOT_WEBKIT_DIR}/Source/JavaScriptCore/wtf
-
-INCLUDEPATH += \
- $$SOURCE_DIR/.. \
- $$SOURCE_DIR \
- $$SOURCE_DIR/gobject \
- $$SOURCE_DIR/qt \
- $$SOURCE_DIR/unicode
-
-contains(CONFIG, use_system_icu) {
- DEFINES += WTF_USE_ICU_UNICODE=1
- DEFINES -= WTF_USE_QT4_UNICODE
- LIBS += -licuuc -licui18n
-} else {
- DEFINES += WTF_USE_QT4_UNICODE=1
- DEFINES -= WTF_USE_ICU_UNICODE
-}
-
-v8 {
- !haveQt(5): error("To build QtWebKit+V8 you need to use Qt 5")
- DEFINES *= WTF_USE_V8=1
- INCLUDEPATH += $${ROOT_WEBKIT_DIR}/Source/WebKit/qt/v8/ForwardingHeaders
- QT += v8-private declarative
-}
-
-linux-*:!contains(DEFINES, USE_QTMULTIMEDIA=1) {
- !contains(QT_CONFIG, no-pkg-config):system(pkg-config --exists glib-2.0 gio-2.0 gstreamer-0.10): {
- DEFINES += ENABLE_GLIB_SUPPORT=1
- PKGCONFIG += glib-2.0 gio-2.0
- }
-}
-
-win32-*: LIBS += -lwinmm
diff --git a/Source/JavaScriptCore/wtf/wtf.pro b/Source/JavaScriptCore/wtf/wtf.pro
deleted file mode 100644
index 234348f2b..000000000
--- a/Source/JavaScriptCore/wtf/wtf.pro
+++ /dev/null
@@ -1,252 +0,0 @@
-# -------------------------------------------------------------------
-# Project file for WTF
-#
-# See 'Tools/qmake/README' for an overview of the build system
-# -------------------------------------------------------------------
-
-TEMPLATE = lib
-TARGET = WTF
-
-include(wtf.pri)
-
-CONFIG += staticlib
-
-QT += core
-QT -= gui
-
-*-g++*:QMAKE_CXXFLAGS_RELEASE -= -O2
-*-g++*:QMAKE_CXXFLAGS_RELEASE += -O3
-
-HEADERS += \
- Alignment.h \
- AlwaysInline.h \
- ArrayBuffer.h \
- ArrayBufferView.h \
- ASCIICType.h \
- Assertions.h \
- Atomics.h \
- AVLTree.h \
- Bitmap.h \
- BitVector.h \
- BloomFilter.h \
- BoundsCheckedPointer.h \
- BumpPointerAllocator.h \
- ByteArray.h \
- CheckedArithmetic.h \
- Compiler.h \
- CryptographicallyRandomNumber.h \
- CurrentTime.h \
- DateMath.h \
- DecimalNumber.h \
- Decoder.h \
- Deque.h \
- DisallowCType.h \
- dtoa.h \
- dtoa/bignum-dtoa.h \
- dtoa/bignum.h \
- dtoa/cached-powers.h \
- dtoa/diy-fp.h \
- dtoa/double-conversion.h \
- dtoa/double.h \
- dtoa/fast-dtoa.h \
- dtoa/fixed-dtoa.h \
- dtoa/strtod.h \
- dtoa/utils.h \
- DynamicAnnotations.h \
- Encoder.h \
- FastAllocBase.h \
- FastMalloc.h \
- FixedArray.h \
- Float32Array.h \
- Float64Array.h \
- Forward.h \
- Functional.h \
- GetPtr.h \
- HashCountedSet.h \
- HashFunctions.h \
- HashIterators.h \
- HashMap.h \
- HashSet.h \
- HashTable.h \
- HashTraits.h \
- HexNumber.h \
- Int16Array.h \
- Int32Array.h \
- Int8Array.h \
- ListHashSet.h \
- ListRefPtr.h \
- Locker.h \
- MainThread.h \
- MallocZoneSupport.h \
- MathExtras.h \
- MD5.h \
- MessageQueue.h \
- MetaAllocator.h \
- MetaAllocatorHandle.h \
- Noncopyable.h \
- NonCopyingSort.h \
- NotFound.h \
- NullPtr.h \
- OSAllocator.h \
- OSRandomSource.h \
- OwnArrayPtr.h \
- OwnPtr.h \
- OwnPtrCommon.h \
- PackedIntVector.h \
- PageAllocation.h \
- PageAllocationAligned.h \
- PageBlock.h \
- PageReservation.h \
- ParallelJobs.h \
- ParallelJobsGeneric.h \
- ParallelJobsLibdispatch.h \
- ParallelJobsOpenMP.h \
- PassOwnArrayPtr.h \
- PassOwnPtr.h \
- PassRefPtr.h \
- PassTraits.h \
- Platform.h \
- PossiblyNull.h \
- qt/UtilsQt.h \
- RandomNumber.h \
- RandomNumberSeed.h \
- RedBlackTree.h \
- RefCounted.h \
- RefCountedLeakCounter.h \
- RefPtr.h \
- RefPtrHashMap.h \
- RetainPtr.h \
- SHA1.h \
- Spectrum.h \
- StackBounds.h \
- StaticConstructors.h \
- StdLibExtras.h \
- StringExtras.h \
- StringHasher.h \
- TCPackedCache.h \
- TCSpinLock.h \
- TCSystemAlloc.h \
- text/ASCIIFastPath.h \
- text/AtomicString.h \
- text/AtomicStringHash.h \
- text/AtomicStringImpl.h \
- text/CString.h \
- text/StringBuffer.h \
- text/StringBuilder.h \
- text/StringConcatenate.h \
- text/StringHash.h \
- text/StringImpl.h \
- text/StringOperators.h \
- text/TextPosition.h \
- text/WTFString.h \
- Threading.h \
- ThreadingPrimitives.h \
- ThreadRestrictionVerifier.h \
- ThreadSafeRefCounted.h \
- ThreadSpecific.h \
- TypeTraits.h \
- Uint16Array.h \
- Uint32Array.h \
- Uint8Array.h \
- unicode/CharacterNames.h \
- unicode/Collator.h \
- unicode/icu/UnicodeIcu.h \
- unicode/qt4/UnicodeQt4.h \
- unicode/ScriptCodesFromICU.h \
- unicode/Unicode.h \
- unicode/UnicodeMacrosFromICU.h \
- unicode/UTF8.h \
- UnusedParam.h \
- ValueCheck.h \
- Vector.h \
- VectorTraits.h \
- VMTags.h \
- WTFThreadData.h
-
-
-unix: HEADERS += ThreadIdentifierDataPthreads.h
-
-SOURCES += \
- ArrayBuffer.cpp \
- ArrayBufferView.cpp \
- Assertions.cpp \
- BitVector.cpp \
- ByteArray.cpp \
- CryptographicallyRandomNumber.cpp \
- CurrentTime.cpp \
- DateMath.cpp \
- DecimalNumber.cpp \
- dtoa.cpp \
- dtoa/bignum-dtoa.cc \
- dtoa/bignum.cc \
- dtoa/cached-powers.cc \
- dtoa/diy-fp.cc \
- dtoa/double-conversion.cc \
- dtoa/fast-dtoa.cc \
- dtoa/fixed-dtoa.cc \
- dtoa/strtod.cc \
- FastMalloc.cpp \
- gobject/GOwnPtr.cpp \
- gobject/GRefPtr.cpp \
- HashTable.cpp \
- MD5.cpp \
- MainThread.cpp \
- MetaAllocator.cpp \
- NullPtr.cpp \
- OSRandomSource.cpp \
- qt/MainThreadQt.cpp \
- qt/StringQt.cpp \
- PageAllocationAligned.cpp \
- PageBlock.cpp \
- ParallelJobsGeneric.cpp \
- RandomNumber.cpp \
- RefCountedLeakCounter.cpp \
- SHA1.cpp \
- StackBounds.cpp \
- TCSystemAlloc.cpp \
- Threading.cpp \
- TypeTraits.cpp \
- WTFThreadData.cpp \
- text/AtomicString.cpp \
- text/CString.cpp \
- text/StringBuilder.cpp \
- text/StringImpl.cpp \
- text/StringStatics.cpp \
- text/WTFString.cpp \
- unicode/CollatorDefault.cpp \
- unicode/icu/CollatorICU.cpp \
- unicode/UTF8.cpp
-
-unix: SOURCES += \
- OSAllocatorPosix.cpp \
- ThreadIdentifierDataPthreads.cpp \
- ThreadingPthreads.cpp
-
-win*|wince*: SOURCES += \
- OSAllocatorWin.cpp \
- ThreadSpecificWin.cpp \
- ThreadingWin.cpp
-
-*sh4* {
- QMAKE_CXXFLAGS += -mieee -w
- QMAKE_CFLAGS += -mieee -w
-}
-
-lessThan(QT_GCC_MAJOR_VERSION, 5) {
- # GCC 4.5 and before
- lessThan(QT_GCC_MINOR_VERSION, 6) {
- # Disable C++0x mode in JSC for those who enabled it in their Qt's mkspec.
- *-g++*:QMAKE_CXXFLAGS -= -std=c++0x -std=gnu++0x
- }
-
- # GCC 4.6 and after.
- greaterThan(QT_GCC_MINOR_VERSION, 5) {
- if (!contains(QMAKE_CXXFLAGS, -std=c++0x) && !contains(QMAKE_CXXFLAGS, -std=gnu++0x)) {
- # We need to deactivate those warnings because some names conflicts with upcoming c++0x types (e.g.nullptr).
- QMAKE_CFLAGS_WARN_ON += -Wno-c++0x-compat
- QMAKE_CXXFLAGS_WARN_ON += -Wno-c++0x-compat
- QMAKE_CFLAGS += -Wno-c++0x-compat
- QMAKE_CXXFLAGS += -Wno-c++0x-compat
- }
- }
-}