diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
commit | dd91e772430dc294e3bf478c119ef8d43c0a3358 (patch) | |
tree | 6f33ce4d5872a5691e0291eb45bf6ab373a5f567 /Source/JavaScriptCore/wtf | |
parent | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (diff) | |
download | qtwebkit-dd91e772430dc294e3bf478c119ef8d43c0a3358.tar.gz |
Imported WebKit commit 3db4eb1820ac8fb03065d7ea73a4d9db1e8fea1a (http://svn.webkit.org/repository/webkit/trunk@110422)
This includes build fixes for the latest qtbase/qtdeclarative as well as the final QML2 API.
Diffstat (limited to 'Source/JavaScriptCore/wtf')
90 files changed, 614 insertions, 206 deletions
diff --git a/Source/JavaScriptCore/wtf/AVLTree.h b/Source/JavaScriptCore/wtf/AVLTree.h index ec8a63951..f2f82e170 100644 --- a/Source/JavaScriptCore/wtf/AVLTree.h +++ b/Source/JavaScriptCore/wtf/AVLTree.h @@ -32,7 +32,7 @@ #ifndef AVL_TREE_H_ #define AVL_TREE_H_ -#include "Assertions.h" +#include <wtf/Assertions.h> #include <wtf/FixedArray.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/Alignment.h b/Source/JavaScriptCore/wtf/Alignment.h index 9b443efc6..ac780b96e 100644 --- a/Source/JavaScriptCore/wtf/Alignment.h +++ b/Source/JavaScriptCore/wtf/Alignment.h @@ -21,7 +21,7 @@ #ifndef WTF_Alignment_h #define WTF_Alignment_h -#include "Platform.h" +#include <wtf/Platform.h> #include <algorithm> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/AlwaysInline.h b/Source/JavaScriptCore/wtf/AlwaysInline.h index de12ddd90..68b7ae1a8 100644 --- a/Source/JavaScriptCore/wtf/AlwaysInline.h +++ b/Source/JavaScriptCore/wtf/AlwaysInline.h @@ -20,4 +20,4 @@ /* This file is no longer necessary, since all the functionality has been moved to Compiler.h. */ -#include "Platform.h" +#include <wtf/Platform.h> diff --git a/Source/JavaScriptCore/wtf/ArrayBuffer.h b/Source/JavaScriptCore/wtf/ArrayBuffer.h index ee95f5bc6..3257df3d0 100644 --- a/Source/JavaScriptCore/wtf/ArrayBuffer.h +++ b/Source/JavaScriptCore/wtf/ArrayBuffer.h @@ -88,7 +88,7 @@ public: void addView(ArrayBufferView*); void removeView(ArrayBufferView*); - bool transfer(ArrayBufferContents&, Vector<RefPtr<ArrayBufferView> >& neuteredViews); + WTF_EXPORT_PRIVATE bool transfer(ArrayBufferContents&, Vector<RefPtr<ArrayBufferView> >& neuteredViews); bool isNeutered() { return !m_contents.m_data; } ~ArrayBuffer() { } diff --git a/Source/JavaScriptCore/wtf/ArrayBufferView.h b/Source/JavaScriptCore/wtf/ArrayBufferView.h index 24ce25a5e..f314dd56c 100644 --- a/Source/JavaScriptCore/wtf/ArrayBufferView.h +++ b/Source/JavaScriptCore/wtf/ArrayBufferView.h @@ -26,7 +26,7 @@ #ifndef ArrayBufferView_h #define ArrayBufferView_h -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include <algorithm> #include <limits.h> @@ -36,7 +36,7 @@ namespace WTF { -class ArrayBufferView : public RefCounted<ArrayBufferView> { +class WTF_EXPORT_PRIVATE_RTTI ArrayBufferView : public RefCounted<ArrayBufferView> { public: virtual bool isByteArray() const { return false; } virtual bool isUnsignedByteArray() const { return false; } @@ -186,6 +186,8 @@ void ArrayBufferView::calculateOffsetAndLength(int start, int end, unsigned arra end += arraySize; if (end < 0) end = 0; + if (static_cast<unsigned>(end) > arraySize) + end = arraySize; if (end < start) end = start; *offset = static_cast<unsigned>(start); diff --git a/Source/JavaScriptCore/wtf/Assertions.cpp b/Source/JavaScriptCore/wtf/Assertions.cpp index 80afcf414..9e744d387 100644 --- a/Source/JavaScriptCore/wtf/Assertions.cpp +++ b/Source/JavaScriptCore/wtf/Assertions.cpp @@ -70,8 +70,15 @@ static void vprintf_stderr_common(const char* format, va_list args) #if PLATFORM(MAC) if (strstr(format, "%@")) { CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8); - CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args); +#if COMPILER(CLANG) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#endif + CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args); +#if COMPILER(CLANG) +#pragma clang diagnostic pop +#endif int length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8); char* buffer = (char*)malloc(length + 1); diff --git a/Source/JavaScriptCore/wtf/Assertions.h b/Source/JavaScriptCore/wtf/Assertions.h index e7358dccb..14b9091fd 100644 --- a/Source/JavaScriptCore/wtf/Assertions.h +++ b/Source/JavaScriptCore/wtf/Assertions.h @@ -42,7 +42,7 @@ http://msdn2.microsoft.com/en-us/library/ms177415(VS.80).aspx */ -#include "Platform.h" +#include <wtf/Platform.h> #include <stddef.h> diff --git a/Source/JavaScriptCore/wtf/Atomics.h b/Source/JavaScriptCore/wtf/Atomics.h index 5e10460c6..d30926897 100644 --- a/Source/JavaScriptCore/wtf/Atomics.h +++ b/Source/JavaScriptCore/wtf/Atomics.h @@ -59,9 +59,9 @@ #ifndef Atomics_h #define Atomics_h -#include "Platform.h" -#include "StdLibExtras.h" -#include "UnusedParam.h" +#include <wtf/Platform.h> +#include <wtf/StdLibExtras.h> +#include <wtf/UnusedParam.h> #if OS(WINDOWS) #include <windows.h> @@ -118,7 +118,11 @@ inline int atomicDecrement(int volatile* addend) { return __gnu_cxx::__exchange_ #endif +#if COMPILER(GCC) && !COMPILER(CLANG) // Work around a gcc bug +inline bool weakCompareAndSwap(volatile unsigned* location, unsigned expected, unsigned newValue) +#else inline bool weakCompareAndSwap(unsigned* location, unsigned expected, unsigned newValue) +#endif { #if ENABLE(COMPARE_AND_SWAP) bool result; @@ -181,7 +185,7 @@ inline bool weakCompareAndSwap(void*volatile* location, void* expected, void* ne #endif // ENABLE(COMPARE_AND_SWAP) } -inline bool weakCompareAndSwap(volatile uintptr_t* location, uintptr_t expected, uintptr_t newValue) +inline bool weakCompareAndSwapUIntPtr(volatile uintptr_t* location, uintptr_t expected, uintptr_t newValue) { return weakCompareAndSwap(reinterpret_cast<void*volatile*>(location), reinterpret_cast<void*>(expected), reinterpret_cast<void*>(newValue)); } diff --git a/Source/JavaScriptCore/wtf/Bitmap.h b/Source/JavaScriptCore/wtf/Bitmap.h index d7e2528a3..76a2ca4b3 100644 --- a/Source/JavaScriptCore/wtf/Bitmap.h +++ b/Source/JavaScriptCore/wtf/Bitmap.h @@ -19,9 +19,9 @@ #ifndef Bitmap_h #define Bitmap_h -#include "Atomics.h" -#include "FixedArray.h" -#include "StdLibExtras.h" +#include <wtf/Atomics.h> +#include <wtf/FixedArray.h> +#include <wtf/StdLibExtras.h> #include <stdint.h> #include <string.h> diff --git a/Source/JavaScriptCore/wtf/BoundsCheckedPointer.h b/Source/JavaScriptCore/wtf/BoundsCheckedPointer.h index d5d42fc1c..1f7caab63 100644 --- a/Source/JavaScriptCore/wtf/BoundsCheckedPointer.h +++ b/Source/JavaScriptCore/wtf/BoundsCheckedPointer.h @@ -29,8 +29,8 @@ #ifndef WTF_BoundsCheckedPointer_h #define WTF_BoundsCheckedPointer_h -#include "Assertions.h" -#include "UnusedParam.h" +#include <wtf/Assertions.h> +#include <wtf/UnusedParam.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/CMakeLists.txt b/Source/JavaScriptCore/wtf/CMakeLists.txt index 63fc59c73..72420128a 100644 --- a/Source/JavaScriptCore/wtf/CMakeLists.txt +++ b/Source/JavaScriptCore/wtf/CMakeLists.txt @@ -206,14 +206,9 @@ WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS() WEBKIT_WRAP_SOURCELIST(${WTF_SOURCES}) INCLUDE_DIRECTORIES(${WTF_INCLUDE_DIRECTORIES}) ADD_DEFINITIONS(-DBUILDING_WTF) -ADD_LIBRARY(${WTF_LIBRARY_NAME} ${WTF_LIBRARY_TYPE} ${WTF_HEADERS} ${WTF_SOURCES}) +ADD_LIBRARY(${WTF_LIBRARY_NAME} STATIC ${WTF_HEADERS} ${WTF_SOURCES}) TARGET_LINK_LIBRARIES(${WTF_LIBRARY_NAME} ${WTF_LIBRARIES}) IF (WTF_LINK_FLAGS) ADD_TARGET_PROPERTIES(${WTF_LIBRARY_NAME} LINK_FLAGS "${WTF_LINK_FLAGS}") ENDIF () - -IF (SHARED_CORE) - SET_TARGET_PROPERTIES(${WTF_LIBRARY_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) - INSTALL(TARGETS ${WTF_LIBRARY_NAME} DESTINATION lib) -ENDIF () diff --git a/Source/JavaScriptCore/wtf/CheckedArithmetic.h b/Source/JavaScriptCore/wtf/CheckedArithmetic.h index f90efae41..b18916538 100644 --- a/Source/JavaScriptCore/wtf/CheckedArithmetic.h +++ b/Source/JavaScriptCore/wtf/CheckedArithmetic.h @@ -26,8 +26,8 @@ #ifndef CheckedArithmetic_h #define CheckedArithmetic_h -#include "Assertions.h" -#include "TypeTraits.h" +#include <wtf/Assertions.h> +#include <wtf/TypeTraits.h> #include <limits> #include <stdint.h> diff --git a/Source/JavaScriptCore/wtf/DateMath.cpp b/Source/JavaScriptCore/wtf/DateMath.cpp index dc503ca2a..cf601a5ec 100644 --- a/Source/JavaScriptCore/wtf/DateMath.cpp +++ b/Source/JavaScriptCore/wtf/DateMath.cpp @@ -935,6 +935,14 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT } } } + + // The year may be after the time but before the time zone. + if (isASCIIDigit(*dateString) && year == -1) { + if (!parseLong(dateString, &newPosStr, 10, &year)) + return std::numeric_limits<double>::quiet_NaN(); + dateString = newPosStr; + skipSpacesAndComments(dateString); + } // Don't fail if the time zone is missing. // Some websites omit the time zone (4275206). @@ -987,10 +995,9 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT if (!parseLong(dateString, &newPosStr, 10, &year)) return std::numeric_limits<double>::quiet_NaN(); dateString = newPosStr; + skipSpacesAndComments(dateString); } - skipSpacesAndComments(dateString); - // Trailing garbage if (*dateString) return std::numeric_limits<double>::quiet_NaN(); diff --git a/Source/JavaScriptCore/wtf/Deque.h b/Source/JavaScriptCore/wtf/Deque.h index 18eb10582..47c0dfffa 100644 --- a/Source/JavaScriptCore/wtf/Deque.h +++ b/Source/JavaScriptCore/wtf/Deque.h @@ -33,8 +33,8 @@ // FIXME: Could move what Vector and Deque share into a separate file. // Deque doesn't actually use Vector. -#include "PassTraits.h" -#include "Vector.h" +#include <wtf/PassTraits.h> +#include <wtf/Vector.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/ExportMacros.h b/Source/JavaScriptCore/wtf/ExportMacros.h index a6b3bce5a..4d3219329 100644 --- a/Source/JavaScriptCore/wtf/ExportMacros.h +++ b/Source/JavaScriptCore/wtf/ExportMacros.h @@ -30,7 +30,7 @@ #ifndef ExportMacros_h #define ExportMacros_h -#include "Platform.h" +#include <wtf/Platform.h> // See note in wtf/Platform.h for more info on EXPORT_MACROS. #if USE(EXPORT_MACROS) @@ -83,6 +83,14 @@ #define WTF_EXPORT_PRIVATE WTF_IMPORT #endif +// wxWebKit uses RTTI because wx itself does, so use a special macro for +// extra exports it needs. +#if PLATFORM(WX) +#define WTF_EXPORT_PRIVATE_RTTI WTF_EXPORT_PRIVATE +#else +#define WTF_EXPORT_PRIVATE_RTTI +#endif + #define WTF_EXPORT_HIDDEN WTF_HIDDEN #define HIDDEN_INLINE WTF_EXPORT_HIDDEN inline diff --git a/Source/JavaScriptCore/wtf/FastAllocBase.h b/Source/JavaScriptCore/wtf/FastAllocBase.h index b9ab0cab1..a0804ad3d 100644 --- a/Source/JavaScriptCore/wtf/FastAllocBase.h +++ b/Source/JavaScriptCore/wtf/FastAllocBase.h @@ -88,10 +88,10 @@ #include <stdint.h> #include <stdlib.h> #include <string.h> -#include "Assertions.h" -#include "FastMalloc.h" -#include "StdLibExtras.h" -#include "TypeTraits.h" +#include <wtf/Assertions.h> +#include <wtf/FastMalloc.h> +#include <wtf/StdLibExtras.h> +#include <wtf/TypeTraits.h> #define WTF_MAKE_FAST_ALLOCATED \ public: \ diff --git a/Source/JavaScriptCore/wtf/FastMalloc.h b/Source/JavaScriptCore/wtf/FastMalloc.h index b115908ba..871be3756 100644 --- a/Source/JavaScriptCore/wtf/FastMalloc.h +++ b/Source/JavaScriptCore/wtf/FastMalloc.h @@ -21,8 +21,8 @@ #ifndef WTF_FastMalloc_h #define WTF_FastMalloc_h -#include "Platform.h" -#include "PossiblyNull.h" +#include <wtf/Platform.h> +#include <wtf/PossiblyNull.h> #include <stdlib.h> #include <new> diff --git a/Source/JavaScriptCore/wtf/Float32Array.h b/Source/JavaScriptCore/wtf/Float32Array.h index 230a768aa..55e61e006 100644 --- a/Source/JavaScriptCore/wtf/Float32Array.h +++ b/Source/JavaScriptCore/wtf/Float32Array.h @@ -27,7 +27,7 @@ #ifndef Float32Array_h #define Float32Array_h -#include "TypedArrayBase.h" +#include <wtf/TypedArrayBase.h> #include <wtf/MathExtras.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/Float64Array.h b/Source/JavaScriptCore/wtf/Float64Array.h index 46713556c..30633dbec 100644 --- a/Source/JavaScriptCore/wtf/Float64Array.h +++ b/Source/JavaScriptCore/wtf/Float64Array.h @@ -27,7 +27,7 @@ #ifndef Float64Array_h #define Float64Array_h -#include "TypedArrayBase.h" +#include <wtf/TypedArrayBase.h> #include <wtf/MathExtras.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/Functional.h b/Source/JavaScriptCore/wtf/Functional.h index bd0f3e282..bfc813b2a 100644 --- a/Source/JavaScriptCore/wtf/Functional.h +++ b/Source/JavaScriptCore/wtf/Functional.h @@ -26,10 +26,10 @@ #ifndef WTF_Functional_h #define WTF_Functional_h -#include "Assertions.h" -#include "PassRefPtr.h" -#include "RefPtr.h" -#include "ThreadSafeRefCounted.h" +#include <wtf/Assertions.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/ThreadSafeRefCounted.h> #if PLATFORM(MAC) && COMPILER_SUPPORTS(BLOCKS) #include <objc/objc-runtime.h> diff --git a/Source/JavaScriptCore/wtf/HashCountedSet.h b/Source/JavaScriptCore/wtf/HashCountedSet.h index b97d8c8fd..cafb2649e 100644 --- a/Source/JavaScriptCore/wtf/HashCountedSet.h +++ b/Source/JavaScriptCore/wtf/HashCountedSet.h @@ -21,9 +21,9 @@ #ifndef WTF_HashCountedSet_h #define WTF_HashCountedSet_h -#include "Assertions.h" -#include "HashMap.h" -#include "Vector.h" +#include <wtf/Assertions.h> +#include <wtf/HashMap.h> +#include <wtf/Vector.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/HashFunctions.h b/Source/JavaScriptCore/wtf/HashFunctions.h index 2c66a2d9f..808b2b1e5 100644 --- a/Source/JavaScriptCore/wtf/HashFunctions.h +++ b/Source/JavaScriptCore/wtf/HashFunctions.h @@ -21,7 +21,7 @@ #ifndef WTF_HashFunctions_h #define WTF_HashFunctions_h -#include "RefPtr.h" +#include <wtf/RefPtr.h> #include <stdint.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/HashMap.h b/Source/JavaScriptCore/wtf/HashMap.h index 13e6d496d..be7e9ebed 100644 --- a/Source/JavaScriptCore/wtf/HashMap.h +++ b/Source/JavaScriptCore/wtf/HashMap.h @@ -21,7 +21,7 @@ #ifndef WTF_HashMap_h #define WTF_HashMap_h -#include "HashTable.h" +#include <wtf/HashTable.h> namespace WTF { @@ -486,6 +486,6 @@ namespace WTF { using WTF::HashMap; -#include "RefPtrHashMap.h" +#include <wtf/RefPtrHashMap.h> #endif /* WTF_HashMap_h */ diff --git a/Source/JavaScriptCore/wtf/HashSet.h b/Source/JavaScriptCore/wtf/HashSet.h index 7fce19348..33cb14daa 100644 --- a/Source/JavaScriptCore/wtf/HashSet.h +++ b/Source/JavaScriptCore/wtf/HashSet.h @@ -21,8 +21,8 @@ #ifndef WTF_HashSet_h #define WTF_HashSet_h -#include "FastAllocBase.h" -#include "HashTable.h" +#include <wtf/FastAllocBase.h> +#include <wtf/HashTable.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/HashTable.h b/Source/JavaScriptCore/wtf/HashTable.h index cbcc09817..05722d9c5 100644 --- a/Source/JavaScriptCore/wtf/HashTable.h +++ b/Source/JavaScriptCore/wtf/HashTable.h @@ -22,13 +22,13 @@ #ifndef WTF_HashTable_h #define WTF_HashTable_h -#include "Alignment.h" -#include "Assertions.h" -#include "FastMalloc.h" -#include "HashTraits.h" -#include "StdLibExtras.h" -#include "Threading.h" -#include "ValueCheck.h" +#include <wtf/Alignment.h> +#include <wtf/Assertions.h> +#include <wtf/FastMalloc.h> +#include <wtf/HashTraits.h> +#include <wtf/StdLibExtras.h> +#include <wtf/Threading.h> +#include <wtf/ValueCheck.h> namespace WTF { @@ -310,7 +310,8 @@ namespace WTF { ~HashTable() { invalidateIterators(); - deallocateTable(m_table, m_tableSize); + if (m_table) + deallocateTable(m_table, m_tableSize); #if CHECK_HASHTABLE_USE_AFTER_DESTRUCTION m_table = (ValueType*)(uintptr_t)0xbbadbeef; #endif @@ -979,6 +980,9 @@ namespace WTF { void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::clear() { invalidateIterators(); + if (!m_table) + return; + deallocateTable(m_table, m_tableSize); m_table = 0; m_tableSize = 0; @@ -1240,6 +1244,6 @@ namespace WTF { } // namespace WTF -#include "HashIterators.h" +#include <wtf/HashIterators.h> #endif // WTF_HashTable_h diff --git a/Source/JavaScriptCore/wtf/HashTraits.h b/Source/JavaScriptCore/wtf/HashTraits.h index e3783ed42..10f14d1af 100644 --- a/Source/JavaScriptCore/wtf/HashTraits.h +++ b/Source/JavaScriptCore/wtf/HashTraits.h @@ -21,9 +21,9 @@ #ifndef WTF_HashTraits_h #define WTF_HashTraits_h -#include "HashFunctions.h" -#include "StdLibExtras.h" -#include "TypeTraits.h" +#include <wtf/HashFunctions.h> +#include <wtf/StdLibExtras.h> +#include <wtf/TypeTraits.h> #include <utility> #include <limits> diff --git a/Source/JavaScriptCore/wtf/Int16Array.h b/Source/JavaScriptCore/wtf/Int16Array.h index 34a52de90..df3dcc265 100644 --- a/Source/JavaScriptCore/wtf/Int16Array.h +++ b/Source/JavaScriptCore/wtf/Int16Array.h @@ -26,7 +26,7 @@ #ifndef Int16Array_h #define Int16Array_h -#include "IntegralTypedArrayBase.h" +#include <wtf/IntegralTypedArrayBase.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/Int32Array.h b/Source/JavaScriptCore/wtf/Int32Array.h index 0b61457b3..f3148c7bc 100644 --- a/Source/JavaScriptCore/wtf/Int32Array.h +++ b/Source/JavaScriptCore/wtf/Int32Array.h @@ -27,7 +27,7 @@ #ifndef Int32Array_h #define Int32Array_h -#include "IntegralTypedArrayBase.h" +#include <wtf/IntegralTypedArrayBase.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/Int8Array.h b/Source/JavaScriptCore/wtf/Int8Array.h index 6db7b6899..cb5d343e4 100644 --- a/Source/JavaScriptCore/wtf/Int8Array.h +++ b/Source/JavaScriptCore/wtf/Int8Array.h @@ -27,7 +27,7 @@ #ifndef Int8Array_h #define Int8Array_h -#include "IntegralTypedArrayBase.h" +#include <wtf/IntegralTypedArrayBase.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/IntegralTypedArrayBase.h b/Source/JavaScriptCore/wtf/IntegralTypedArrayBase.h index 48f82a361..f276400f8 100644 --- a/Source/JavaScriptCore/wtf/IntegralTypedArrayBase.h +++ b/Source/JavaScriptCore/wtf/IntegralTypedArrayBase.h @@ -27,7 +27,7 @@ #ifndef IntegralTypedArrayBase_h #define IntegralTypedArrayBase_h -#include "TypedArrayBase.h" +#include <wtf/TypedArrayBase.h> #include <limits> #include <wtf/MathExtras.h> diff --git a/Source/JavaScriptCore/wtf/ListHashSet.h b/Source/JavaScriptCore/wtf/ListHashSet.h index 32bd23832..799466fa9 100644 --- a/Source/JavaScriptCore/wtf/ListHashSet.h +++ b/Source/JavaScriptCore/wtf/ListHashSet.h @@ -22,9 +22,9 @@ #ifndef WTF_ListHashSet_h #define WTF_ListHashSet_h -#include "HashSet.h" -#include "OwnPtr.h" -#include "PassOwnPtr.h" +#include <wtf/HashSet.h> +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/MainThread.h b/Source/JavaScriptCore/wtf/MainThread.h index 4839c8117..24200779a 100644 --- a/Source/JavaScriptCore/wtf/MainThread.h +++ b/Source/JavaScriptCore/wtf/MainThread.h @@ -30,7 +30,7 @@ #ifndef MainThread_h #define MainThread_h -#include "Platform.h" +#include <wtf/Platform.h> #include <stdint.h> diff --git a/Source/JavaScriptCore/wtf/MetaAllocator.cpp b/Source/JavaScriptCore/wtf/MetaAllocator.cpp index ac6cba8d1..649fbf2bc 100644 --- a/Source/JavaScriptCore/wtf/MetaAllocator.cpp +++ b/Source/JavaScriptCore/wtf/MetaAllocator.cpp @@ -64,6 +64,7 @@ MetaAllocatorHandle::MetaAllocatorHandle(MetaAllocator* allocator, void* start, ASSERT(allocator); ASSERT(start); ASSERT(sizeInBytes); + turnOffVerifier(); } MetaAllocatorHandle::~MetaAllocatorHandle() @@ -169,8 +170,6 @@ PassRefPtr<MetaAllocatorHandle> MetaAllocator::allocate(size_t sizeInBytes, void #endif 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); diff --git a/Source/JavaScriptCore/wtf/MetaAllocator.h b/Source/JavaScriptCore/wtf/MetaAllocator.h index ffd55667e..8a73a3b03 100644 --- a/Source/JavaScriptCore/wtf/MetaAllocator.h +++ b/Source/JavaScriptCore/wtf/MetaAllocator.h @@ -29,15 +29,15 @@ #ifndef WTF_MetaAllocator_h #define WTF_MetaAllocator_h -#include "Assertions.h" -#include "HashMap.h" -#include "MetaAllocatorHandle.h" -#include "Noncopyable.h" -#include "PageBlock.h" -#include "RedBlackTree.h" -#include "RefCounted.h" -#include "RefPtr.h" -#include "TCSpinLock.h" +#include <wtf/Assertions.h> +#include <wtf/HashMap.h> +#include <wtf/MetaAllocatorHandle.h> +#include <wtf/Noncopyable.h> +#include <wtf/PageBlock.h> +#include <wtf/RedBlackTree.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> +#include <wtf/TCSpinLock.h> namespace WTF { @@ -204,6 +204,7 @@ inline MetaAllocator::~MetaAllocator() freeFreeSpaceNode(node); node = next; } + m_lock.Finalize(); #ifndef NDEBUG ASSERT(!m_mallocBalance); #endif diff --git a/Source/JavaScriptCore/wtf/Noncopyable.h b/Source/JavaScriptCore/wtf/Noncopyable.h index 9f93f173b..1e95cbb92 100644 --- a/Source/JavaScriptCore/wtf/Noncopyable.h +++ b/Source/JavaScriptCore/wtf/Noncopyable.h @@ -21,7 +21,7 @@ #ifndef WTF_Noncopyable_h #define WTF_Noncopyable_h -#include "Compiler.h" +#include <wtf/Compiler.h> #if COMPILER_SUPPORTS(CXX_DELETED_FUNCTIONS) #define WTF_MAKE_NONCOPYABLE(ClassName) \ diff --git a/Source/JavaScriptCore/wtf/OwnArrayPtr.h b/Source/JavaScriptCore/wtf/OwnArrayPtr.h index 0fc8e71b3..b3d72dfdb 100644 --- a/Source/JavaScriptCore/wtf/OwnArrayPtr.h +++ b/Source/JavaScriptCore/wtf/OwnArrayPtr.h @@ -21,10 +21,10 @@ #ifndef WTF_OwnArrayPtr_h #define WTF_OwnArrayPtr_h -#include "Assertions.h" -#include "Noncopyable.h" -#include "NullPtr.h" -#include "PassOwnArrayPtr.h" +#include <wtf/Assertions.h> +#include <wtf/Noncopyable.h> +#include <wtf/NullPtr.h> +#include <wtf/PassOwnArrayPtr.h> #include <algorithm> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/OwnPtr.h b/Source/JavaScriptCore/wtf/OwnPtr.h index 097967964..326e3fd61 100644 --- a/Source/JavaScriptCore/wtf/OwnPtr.h +++ b/Source/JavaScriptCore/wtf/OwnPtr.h @@ -21,10 +21,10 @@ #ifndef WTF_OwnPtr_h #define WTF_OwnPtr_h -#include "Assertions.h" -#include "NullPtr.h" -#include "OwnPtrCommon.h" -#include "TypeTraits.h" +#include <wtf/Assertions.h> +#include <wtf/NullPtr.h> +#include <wtf/OwnPtrCommon.h> +#include <wtf/TypeTraits.h> #include <algorithm> #include <memory> diff --git a/Source/JavaScriptCore/wtf/PackedIntVector.h b/Source/JavaScriptCore/wtf/PackedIntVector.h index 76fa48a1d..9289eb6b3 100644 --- a/Source/JavaScriptCore/wtf/PackedIntVector.h +++ b/Source/JavaScriptCore/wtf/PackedIntVector.h @@ -26,7 +26,7 @@ #ifndef PackedIntVector_h #define PackedIntVector_h -#include "BitVector.h" +#include <wtf/BitVector.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/ParallelJobs.h b/Source/JavaScriptCore/wtf/ParallelJobs.h index 92b9c5b5b..0923886ad 100644 --- a/Source/JavaScriptCore/wtf/ParallelJobs.h +++ b/Source/JavaScriptCore/wtf/ParallelJobs.h @@ -28,9 +28,9 @@ #ifndef ParallelJobs_h #define ParallelJobs_h -#include "Assertions.h" -#include "Noncopyable.h" -#include "RefPtr.h" +#include <wtf/Assertions.h> +#include <wtf/Noncopyable.h> +#include <wtf/RefPtr.h> #include <wtf/Vector.h> // Usage: @@ -50,13 +50,13 @@ // #if ENABLE(THREADING_GENERIC) -#include "ParallelJobsGeneric.h" +#include <wtf/ParallelJobsGeneric.h> #elif ENABLE(THREADING_OPENMP) -#include "ParallelJobsOpenMP.h" +#include <wtf/ParallelJobsOpenMP.h> #elif ENABLE(THREADING_LIBDISPATCH) -#include "ParallelJobsLibdispatch.h" +#include <wtf/ParallelJobsLibdispatch.h> #else #error "No parallel processing API for ParallelJobs" diff --git a/Source/JavaScriptCore/wtf/PassOwnArrayPtr.h b/Source/JavaScriptCore/wtf/PassOwnArrayPtr.h index 3748f18c6..1db7343de 100644 --- a/Source/JavaScriptCore/wtf/PassOwnArrayPtr.h +++ b/Source/JavaScriptCore/wtf/PassOwnArrayPtr.h @@ -26,9 +26,9 @@ #ifndef WTF_PassOwnArrayPtr_h #define WTF_PassOwnArrayPtr_h -#include "Assertions.h" -#include "NullPtr.h" -#include "TypeTraits.h" +#include <wtf/Assertions.h> +#include <wtf/NullPtr.h> +#include <wtf/TypeTraits.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/PassOwnPtr.h b/Source/JavaScriptCore/wtf/PassOwnPtr.h index 262ac3bfe..5ebf83d65 100644 --- a/Source/JavaScriptCore/wtf/PassOwnPtr.h +++ b/Source/JavaScriptCore/wtf/PassOwnPtr.h @@ -26,10 +26,10 @@ #ifndef WTF_PassOwnPtr_h #define WTF_PassOwnPtr_h -#include "Assertions.h" -#include "NullPtr.h" -#include "OwnPtrCommon.h" -#include "TypeTraits.h" +#include <wtf/Assertions.h> +#include <wtf/NullPtr.h> +#include <wtf/OwnPtrCommon.h> +#include <wtf/TypeTraits.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/PassRefPtr.h b/Source/JavaScriptCore/wtf/PassRefPtr.h index a13dee794..207721c96 100644 --- a/Source/JavaScriptCore/wtf/PassRefPtr.h +++ b/Source/JavaScriptCore/wtf/PassRefPtr.h @@ -21,8 +21,8 @@ #ifndef WTF_PassRefPtr_h #define WTF_PassRefPtr_h -#include "AlwaysInline.h" -#include "NullPtr.h" +#include <wtf/AlwaysInline.h> +#include <wtf/NullPtr.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/PassTraits.h b/Source/JavaScriptCore/wtf/PassTraits.h index 346273486..9564e3ad3 100644 --- a/Source/JavaScriptCore/wtf/PassTraits.h +++ b/Source/JavaScriptCore/wtf/PassTraits.h @@ -29,8 +29,8 @@ #ifndef WTF_PassTraits_h #define WTF_PassTraits_h -#include "OwnPtr.h" -#include "RefPtr.h" +#include <wtf/OwnPtr.h> +#include <wtf/RefPtr.h> // The PassTraits template exists to help optimize (or make possible) use // of WTF data structures with WTF smart pointers that have a Pass diff --git a/Source/JavaScriptCore/wtf/Platform.h b/Source/JavaScriptCore/wtf/Platform.h index 76b11fe88..c374b03c9 100644 --- a/Source/JavaScriptCore/wtf/Platform.h +++ b/Source/JavaScriptCore/wtf/Platform.h @@ -29,7 +29,7 @@ #define WTF_Platform_h /* Include compiler specific macros */ -#include "Compiler.h" +#include <wtf/Compiler.h> /* ==== PLATFORM handles OS, operating environment, graphics API, and CPU. This macro will be phased out in favor of platform adaptation @@ -295,7 +295,7 @@ #endif /* ARM */ -#if CPU(ARM) || CPU(MIPS) || CPU(SH4) +#if CPU(ARM) || CPU(MIPS) || CPU(SH4) || CPU(SPARC) #define WTF_CPU_NEEDS_ALIGNED_ACCESS 1 #endif @@ -558,6 +558,9 @@ #if defined(ENABLE_VIDEO) #define ENABLE_VIDEO_TRACK 1 #endif +#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) +#define HAVE_LAYER_HOSTING_IN_WINDOW_SERVER 1 +#endif #endif /* PLATFORM(MAC) && !PLATFORM(IOS) */ #if PLATFORM(CHROMIUM) && OS(DARWIN) @@ -607,8 +610,9 @@ #define ENABLE_JIT 0 #define ENABLE_YARR_JIT 0 #else - #define ENABLE_CLASSIC_INTERPRETER 1 + #define ENABLE_CLASSIC_INTERPRETER 0 #define ENABLE_JIT 1 + #define ENABLE_LLINT 1 #define ENABLE_YARR_JIT 1 #endif @@ -920,7 +924,7 @@ #define ENABLE_JIT 0 #endif -/* The JIT is enabled by default on all x86, x64-64, ARM & MIPS platforms. */ +/* The JIT is enabled by default on all x86, x86-64, ARM & MIPS platforms. */ #if !defined(ENABLE_JIT) \ && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(MIPS)) \ && (OS(DARWIN) || !COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 1, 0)) \ @@ -931,7 +935,7 @@ /* On some of the platforms where we have a JIT, we want to also have the low-level interpreter. */ -#if !defined(ENABLE_LLINT) && ENABLE(JIT) && OS(DARWIN) && (CPU(X86) || CPU(ARM_THUMB2)) && USE(JSVALUE32_64) +#if !defined(ENABLE_LLINT) && ENABLE(JIT) && OS(DARWIN) && (CPU(X86) || CPU(X86_64) || CPU(ARM_THUMB2)) #define ENABLE_LLINT 1 #endif @@ -1074,6 +1078,11 @@ #define WTF_USE_ACCELERATED_COMPOSITING 1 #endif +/* Compositing on the UI-process in WebKit2 */ +#if PLATFORM(QT) +#define WTF_USE_UI_SIDE_COMPOSITING 1 +#endif + #if (PLATFORM(MAC) && !defined(BUILDING_ON_LEOPARD)) || PLATFORM(IOS) #define WTF_USE_PROTECTION_SPACE_AUTH_CALLBACK 1 #endif @@ -1098,6 +1107,10 @@ #define WTF_USE_CROSS_PLATFORM_CONTEXT_MENUS 1 #endif +#if PLATFORM(MAC) && HAVE(ACCESSIBILITY) +#define WTF_USE_ACCESSIBILITY_CONTEXT_MENUS 1 +#endif + /* Geolocation request policy. pre-emptive policy is to acquire user permission before acquiring location. Client based implementations will have option to choose between pre-emptive and nonpre-emptive permission policy. pre-emptive permission policy is enabled by default for all client-based implementations. */ @@ -1118,7 +1131,7 @@ #endif #if ENABLE(GLIB_SUPPORT) -#include "GTypedefs.h" +#include <wtf/gobject/GTypedefs.h> #endif /* FIXME: This define won't be needed once #27551 is fully landed. However, @@ -1194,4 +1207,8 @@ #define WTF_USE_WTFURL 0 #endif +#if !PLATFORM(QT) && !PLATFORM(EFL) +#define WTF_USE_ZLIB 1 +#endif + #endif /* WTF_Platform_h */ diff --git a/Source/JavaScriptCore/wtf/PossiblyNull.h b/Source/JavaScriptCore/wtf/PossiblyNull.h index 79c4d8200..46a7d713b 100644 --- a/Source/JavaScriptCore/wtf/PossiblyNull.h +++ b/Source/JavaScriptCore/wtf/PossiblyNull.h @@ -26,7 +26,7 @@ #ifndef PossiblyNull_h #define PossiblyNull_h -#include "Assertions.h" +#include <wtf/Assertions.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/RefCounted.h b/Source/JavaScriptCore/wtf/RefCounted.h index 51c5dc26e..cea1434e1 100644 --- a/Source/JavaScriptCore/wtf/RefCounted.h +++ b/Source/JavaScriptCore/wtf/RefCounted.h @@ -21,12 +21,12 @@ #ifndef RefCounted_h #define RefCounted_h -#include "Assertions.h" -#include "FastAllocBase.h" -#include "ThreadRestrictionVerifier.h" -#include "Noncopyable.h" -#include "OwnPtr.h" -#include "UnusedParam.h" +#include <wtf/Assertions.h> +#include <wtf/FastAllocBase.h> +#include <wtf/Noncopyable.h> +#include <wtf/OwnPtr.h> +#include <wtf/ThreadRestrictionVerifier.h> +#include <wtf/UnusedParam.h> namespace WTF { @@ -77,8 +77,15 @@ public: // Turns off verification. Use of this method is discouraged (instead extend // ThreadRestrictionVerifier to verify your case). - // FIXME: remove this method. - void deprecatedTurnOffVerifier() + // NB. It is necessary to call this in the constructor of many objects in + // JavaScriptCore, because JavaScriptCore objects may be used from multiple + // threads even if the reference counting is done in a racy manner. This is + // because a JSC instance may be used from multiple threads so long as all + // accesses into that instance are protected by a per-instance lock. It would + // be absolutely wrong to prohibit this pattern, and it would be a disastrous + // regression to require that the objects within that instance use a thread- + // safe version of reference counting. + void turnOffVerifier() { #ifndef NDEBUG m_verifier.turnOffVerification(); diff --git a/Source/JavaScriptCore/wtf/RefCountedArray.h b/Source/JavaScriptCore/wtf/RefCountedArray.h new file mode 100644 index 000000000..2610a69b8 --- /dev/null +++ b/Source/JavaScriptCore/wtf/RefCountedArray.h @@ -0,0 +1,165 @@ +/* + * 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 RefCountedArray_h +#define RefCountedArray_h + +#include <wtf/FastMalloc.h> +#include <wtf/StdLibExtras.h> +#include <wtf/Vector.h> + +// This implements a reference counted array for POD** values, which is optimized for: +// - An empty array only uses one word. +// - A copy of the array only uses one word (i.e. assignment means aliasing). +// - The vector can't grow beyond 2^32-1 elements. +// - In all other regards this has similar space usage to a Vector. +// +// ** This could be modified to support non-POD values quite easily. It just +// hasn't been, so far, because there has been no need. Moreover, even now, +// it's used for things that aren't quite POD according to the official +// defintion, such as JSC::Instruction. + +namespace WTF { + +template<typename T> +class RefCountedArray { +public: + RefCountedArray() + : m_data(0) + { + } + + RefCountedArray(const RefCountedArray& other) + : m_data(other.m_data) + { + if (m_data) + Header::fromPayload(m_data)->refCount++; + } + + explicit RefCountedArray(const Vector<T>& other) + { + if (other.isEmpty()) { + m_data = 0; + return; + } + + m_data = (static_cast<Header*>(fastMalloc(Header::size() + sizeof(T) * other.size())))->payload(); + Header::fromPayload(m_data)->refCount = 1; + Header::fromPayload(m_data)->length = other.size(); + ASSERT(Header::fromPayload(m_data)->length == other.size()); + memcpy(m_data, other.begin(), sizeof(T) * other.size()); + } + + RefCountedArray& operator=(const RefCountedArray& other) + { + T* oldData = m_data; + m_data = other.m_data; + if (m_data) + Header::fromPayload(m_data)->refCount++; + + if (!oldData) + return *this; + if (--Header::fromPayload(oldData)->refCount) + return *this; + fastFree(Header::fromPayload(oldData)); + return *this; + } + + ~RefCountedArray() + { + if (!m_data) + return; + if (--Header::fromPayload(m_data)->refCount) + return; + fastFree(Header::fromPayload(m_data)); + } + + size_t size() const + { + if (!m_data) + return 0; + return Header::fromPayload(m_data)->length; + } + + T* data() { return m_data; } + T* begin() { return m_data; } + T* end() + { + if (!m_data) + return 0; + return m_data + Header::fromPayload(m_data)->length; + } + + const T* data() const { return m_data; } + const T* begin() const { return m_data; } + const T* end() const { return const_cast<RefCountedArray*>(this)->end(); } + + T& at(size_t i) + { + ASSERT(i < size()); + return begin()[i]; + } + + const T& at(size_t i) const + { + ASSERT(i < size()); + return begin()[i]; + } + + T& operator[](size_t i) { return at(i); } + const T& operator[](size_t i) const { return at(i); } + +private: + struct Header { + unsigned refCount; + unsigned length; + + static size_t size() + { + return (sizeof(Header) + 7) & ~7; + } + + T* payload() + { + char* result = reinterpret_cast<char*>(this) + size(); + ASSERT(!(bitwise_cast<uintptr_t>(result) & 7)); + return reinterpret_cast<T*>(result); + } + + static Header* fromPayload(T* payload) + { + return reinterpret_cast_ptr<Header*>(reinterpret_cast<char*>(payload) - size()); + } + }; + + T* m_data; +}; + +} // namespace WTF + +using WTF::RefCountedArray; + +#endif // RefCountedArray_h + diff --git a/Source/JavaScriptCore/wtf/RefCountedLeakCounter.h b/Source/JavaScriptCore/wtf/RefCountedLeakCounter.h index 476b1735a..8d894dd91 100644 --- a/Source/JavaScriptCore/wtf/RefCountedLeakCounter.h +++ b/Source/JavaScriptCore/wtf/RefCountedLeakCounter.h @@ -21,8 +21,8 @@ #ifndef RefCountedLeakCounter_h #define RefCountedLeakCounter_h -#include "Assertions.h" -#include "Threading.h" +#include <wtf/Assertions.h> +#include <wtf/Threading.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/RefPtr.h b/Source/JavaScriptCore/wtf/RefPtr.h index ac94993e3..70ab60003 100644 --- a/Source/JavaScriptCore/wtf/RefPtr.h +++ b/Source/JavaScriptCore/wtf/RefPtr.h @@ -24,8 +24,8 @@ #define WTF_RefPtr_h #include <algorithm> -#include "FastAllocBase.h" -#include "PassRefPtr.h" +#include <wtf/FastAllocBase.h> +#include <wtf/PassRefPtr.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/RetainPtr.h b/Source/JavaScriptCore/wtf/RetainPtr.h index 3d4b0c3f9..a3489577a 100644 --- a/Source/JavaScriptCore/wtf/RetainPtr.h +++ b/Source/JavaScriptCore/wtf/RetainPtr.h @@ -21,9 +21,9 @@ #ifndef RetainPtr_h #define RetainPtr_h -#include "HashTraits.h" -#include "NullPtr.h" -#include "TypeTraits.h" +#include <wtf/HashTraits.h> +#include <wtf/NullPtr.h> +#include <wtf/TypeTraits.h> #include <algorithm> #if USE(CF) diff --git a/Source/JavaScriptCore/wtf/SimpleStats.h b/Source/JavaScriptCore/wtf/SimpleStats.h new file mode 100644 index 000000000..f1fd7e10a --- /dev/null +++ b/Source/JavaScriptCore/wtf/SimpleStats.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 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 + * 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 SimpleStats_h +#define SimpleStats_h + +#include <wtf/MathExtras.h> +#include <wtf/StdLibExtras.h> + +namespace WTF { + +// Simple and cheap way of tracking statistics if you're not worried about chopping on +// the sum of squares (i.e. the sum of squares is unlikely to exceed 2^52). +class SimpleStats { +public: + SimpleStats() + : m_count(0) + , m_sum(0) + , m_sumOfSquares(0) + { + } + + void add(double value) + { + m_count++; + m_sum += value; + m_sumOfSquares += value * value; + } + + bool operator!() const + { + return !m_count; + } + + double count() const + { + return m_count; + } + + double sum() const + { + return m_sum; + } + + double sumOfSquares() const + { + return m_sumOfSquares; + } + + double mean() const + { + return m_sum / m_count; + } + + // NB. This gives a biased variance as it divides by the number of samples rather + // than the degrees of freedom. This is fine once the count grows large, which in + // our case will happen rather quickly. + double variance() const + { + if (m_count < 2) + return 0; + + // Compute <x^2> - <x>^2 + double secondMoment = m_sumOfSquares / m_count; + double firstMoment = m_sum / m_count; + + return secondMoment - firstMoment * firstMoment; + } + + // NB. This gives a biased standard deviation. See above. + double standardDeviation() const + { + return sqrt(variance()); + } + +private: + double m_count; + double m_sum; + double m_sumOfSquares; +}; + +} // namespace WTF + +#endif // SimpleStats_h + diff --git a/Source/JavaScriptCore/wtf/Spectrum.h b/Source/JavaScriptCore/wtf/Spectrum.h index c403eda18..59bc4a29a 100644 --- a/Source/JavaScriptCore/wtf/Spectrum.h +++ b/Source/JavaScriptCore/wtf/Spectrum.h @@ -26,8 +26,8 @@ #ifndef Spectrum_h #define Spectrum_h -#include "HashMap.h" -#include "Vector.h" +#include <wtf/HashMap.h> +#include <wtf/Vector.h> #include <algorithm> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/StdLibExtras.h b/Source/JavaScriptCore/wtf/StdLibExtras.h index 2a0a9f950..0387e5b05 100644 --- a/Source/JavaScriptCore/wtf/StdLibExtras.h +++ b/Source/JavaScriptCore/wtf/StdLibExtras.h @@ -26,8 +26,8 @@ #ifndef WTF_StdLibExtras_h #define WTF_StdLibExtras_h -#include "CheckedArithmetic.h" -#include "Assertions.h" +#include <wtf/Assertions.h> +#include <wtf/CheckedArithmetic.h> // Use these to declare and define a static local variable (static T;) so that // it is leaked so that its destructors are not called at exit. Using this diff --git a/Source/JavaScriptCore/wtf/TCPageMap.h b/Source/JavaScriptCore/wtf/TCPageMap.h index 99bdc400e..92fe0b065 100644 --- a/Source/JavaScriptCore/wtf/TCPageMap.h +++ b/Source/JavaScriptCore/wtf/TCPageMap.h @@ -54,7 +54,7 @@ #endif #include <string.h> -#include "Assertions.h" +#include <wtf/Assertions.h> // Single-level array template <int BITS> diff --git a/Source/JavaScriptCore/wtf/TCSpinLock.h b/Source/JavaScriptCore/wtf/TCSpinLock.h index 81b7d0cae..7f19b6c25 100644 --- a/Source/JavaScriptCore/wtf/TCSpinLock.h +++ b/Source/JavaScriptCore/wtf/TCSpinLock.h @@ -128,6 +128,7 @@ struct TCMalloc_SpinLock { } inline void Init() { lockword_ = 0; } + inline void Finalize() { } volatile unsigned int lockword_; }; @@ -221,6 +222,7 @@ struct TCMalloc_SpinLock { } inline void Init() { m_lockword = 0; } + inline void Finalize() { } LONG m_lockword; }; diff --git a/Source/JavaScriptCore/wtf/TemporaryChange.h b/Source/JavaScriptCore/wtf/TemporaryChange.h index fe374b194..95df1728b 100644 --- a/Source/JavaScriptCore/wtf/TemporaryChange.h +++ b/Source/JavaScriptCore/wtf/TemporaryChange.h @@ -26,7 +26,7 @@ #ifndef TemporaryChange_h #define TemporaryChange_h -#include "Noncopyable.h" +#include <wtf/Noncopyable.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/ThreadSafeRefCounted.h b/Source/JavaScriptCore/wtf/ThreadSafeRefCounted.h index 8497b3bc2..44035e547 100644 --- a/Source/JavaScriptCore/wtf/ThreadSafeRefCounted.h +++ b/Source/JavaScriptCore/wtf/ThreadSafeRefCounted.h @@ -59,7 +59,7 @@ #ifndef ThreadSafeRefCounted_h #define ThreadSafeRefCounted_h -#include "Platform.h" +#include <wtf/Platform.h> #include <wtf/Atomics.h> #include <wtf/DynamicAnnotations.h> diff --git a/Source/JavaScriptCore/wtf/Threading.h b/Source/JavaScriptCore/wtf/Threading.h index b5d432681..3e558fc68 100644 --- a/Source/JavaScriptCore/wtf/Threading.h +++ b/Source/JavaScriptCore/wtf/Threading.h @@ -59,7 +59,7 @@ #ifndef Threading_h #define Threading_h -#include "Platform.h" +#include <wtf/Platform.h> #include <stdint.h> #include <wtf/Assertions.h> diff --git a/Source/JavaScriptCore/wtf/ThreadingPrimitives.h b/Source/JavaScriptCore/wtf/ThreadingPrimitives.h index 2ac42c8f1..9ed38bc9f 100644 --- a/Source/JavaScriptCore/wtf/ThreadingPrimitives.h +++ b/Source/JavaScriptCore/wtf/ThreadingPrimitives.h @@ -31,7 +31,7 @@ #ifndef ThreadingPrimitives_h #define ThreadingPrimitives_h -#include "Platform.h" +#include <wtf/Platform.h> #include <wtf/Assertions.h> #include <wtf/FastAllocBase.h> diff --git a/Source/JavaScriptCore/wtf/TypeTraits.h b/Source/JavaScriptCore/wtf/TypeTraits.h index 34e8b79a3..bfed2aa7b 100644 --- a/Source/JavaScriptCore/wtf/TypeTraits.h +++ b/Source/JavaScriptCore/wtf/TypeTraits.h @@ -22,7 +22,7 @@ #ifndef TypeTraits_h #define TypeTraits_h -#include "Platform.h" +#include <wtf/Platform.h> #if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) #include <type_traits> diff --git a/Source/JavaScriptCore/wtf/TypedArrayBase.h b/Source/JavaScriptCore/wtf/TypedArrayBase.h index dba95d55f..7f989198a 100644 --- a/Source/JavaScriptCore/wtf/TypedArrayBase.h +++ b/Source/JavaScriptCore/wtf/TypedArrayBase.h @@ -27,8 +27,8 @@ #ifndef TypedArrayBase_h #define TypedArrayBase_h -#include "ArrayBuffer.h" -#include "ArrayBufferView.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/ArrayBufferView.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/Uint16Array.h b/Source/JavaScriptCore/wtf/Uint16Array.h index 2d0765051..e73c8ddff 100644 --- a/Source/JavaScriptCore/wtf/Uint16Array.h +++ b/Source/JavaScriptCore/wtf/Uint16Array.h @@ -27,7 +27,7 @@ #ifndef Uint16Array_h #define Uint16Array_h -#include "IntegralTypedArrayBase.h" +#include <wtf/IntegralTypedArrayBase.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/Uint32Array.h b/Source/JavaScriptCore/wtf/Uint32Array.h index 3765f8077..b2a391267 100644 --- a/Source/JavaScriptCore/wtf/Uint32Array.h +++ b/Source/JavaScriptCore/wtf/Uint32Array.h @@ -27,7 +27,7 @@ #ifndef Uint32Array_h #define Uint32Array_h -#include "IntegralTypedArrayBase.h" +#include <wtf/IntegralTypedArrayBase.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/Uint8Array.h b/Source/JavaScriptCore/wtf/Uint8Array.h index a0959706c..f46ef0fc0 100644 --- a/Source/JavaScriptCore/wtf/Uint8Array.h +++ b/Source/JavaScriptCore/wtf/Uint8Array.h @@ -27,7 +27,7 @@ #ifndef Uint8Array_h #define Uint8Array_h -#include "IntegralTypedArrayBase.h" +#include <wtf/IntegralTypedArrayBase.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/Uint8ClampedArray.h b/Source/JavaScriptCore/wtf/Uint8ClampedArray.h index f1044091b..2b77dacc3 100644 --- a/Source/JavaScriptCore/wtf/Uint8ClampedArray.h +++ b/Source/JavaScriptCore/wtf/Uint8ClampedArray.h @@ -28,7 +28,7 @@ #ifndef Uint8ClampedArray_h #define Uint8ClampedArray_h -#include "Uint8Array.h" +#include <wtf/Uint8Array.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/UnusedParam.h b/Source/JavaScriptCore/wtf/UnusedParam.h index 6ff6fd895..4b7234b8d 100644 --- a/Source/JavaScriptCore/wtf/UnusedParam.h +++ b/Source/JavaScriptCore/wtf/UnusedParam.h @@ -24,7 +24,7 @@ /* don't use this for C++, it should only be used in plain C files or ObjC methods, where leaving off the parameter name is not allowed. */ -#include "Platform.h" +#include <wtf/Platform.h> #if COMPILER(INTEL) && !OS(WINDOWS) || COMPILER(RVCT) template<typename T> diff --git a/Source/JavaScriptCore/wtf/Vector.h b/Source/JavaScriptCore/wtf/Vector.h index 29bbd37d9..19e6ffb8c 100644 --- a/Source/JavaScriptCore/wtf/Vector.h +++ b/Source/JavaScriptCore/wtf/Vector.h @@ -21,13 +21,13 @@ #ifndef WTF_Vector_h #define WTF_Vector_h -#include "Alignment.h" -#include "FastAllocBase.h" -#include "Noncopyable.h" -#include "NotFound.h" -#include "StdLibExtras.h" -#include "ValueCheck.h" -#include "VectorTraits.h" +#include <wtf/Alignment.h> +#include <wtf/FastAllocBase.h> +#include <wtf/Noncopyable.h> +#include <wtf/NotFound.h> +#include <wtf/StdLibExtras.h> +#include <wtf/ValueCheck.h> +#include <wtf/VectorTraits.h> #include <limits> #include <utility> @@ -281,10 +281,14 @@ namespace WTF { void deallocateBuffer(T* bufferToDeallocate) { + if (!bufferToDeallocate) + return; + if (m_buffer == bufferToDeallocate) { m_buffer = 0; m_capacity = 0; } + fastFree(bufferToDeallocate); } diff --git a/Source/JavaScriptCore/wtf/VectorTraits.h b/Source/JavaScriptCore/wtf/VectorTraits.h index 6777c9ebf..4041217ab 100644 --- a/Source/JavaScriptCore/wtf/VectorTraits.h +++ b/Source/JavaScriptCore/wtf/VectorTraits.h @@ -21,9 +21,9 @@ #ifndef WTF_VectorTraits_h #define WTF_VectorTraits_h -#include "OwnPtr.h" -#include "RefPtr.h" -#include "TypeTraits.h" +#include <wtf/OwnPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/TypeTraits.h> #include <utility> #include <memory> diff --git a/Source/JavaScriptCore/wtf/WTFThreadData.cpp b/Source/JavaScriptCore/wtf/WTFThreadData.cpp index 241fbe449..ec5de7220 100644 --- a/Source/JavaScriptCore/wtf/WTFThreadData.cpp +++ b/Source/JavaScriptCore/wtf/WTFThreadData.cpp @@ -51,4 +51,25 @@ WTFThreadData::~WTFThreadData() #endif } +} // namespace WTF + +#if USE(JSC) +namespace JSC { + +IdentifierTable::~IdentifierTable() +{ + HashSet<StringImpl*>::iterator end = m_table.end(); + for (HashSet<StringImpl*>::iterator iter = m_table.begin(); iter != end; ++iter) + (*iter)->setIsIdentifier(false); +} + +std::pair<HashSet<StringImpl*>::iterator, bool> IdentifierTable::add(StringImpl* value) +{ + std::pair<HashSet<StringImpl*>::iterator, bool> result = m_table.add(value); + (*result.first)->setIsIdentifier(true); + return result; } + +} // namespace JSC +#endif + diff --git a/Source/JavaScriptCore/wtf/dtoa/double-conversion.h b/Source/JavaScriptCore/wtf/dtoa/double-conversion.h index 4d6fc2f57..eec956a21 100644 --- a/Source/JavaScriptCore/wtf/dtoa/double-conversion.h +++ b/Source/JavaScriptCore/wtf/dtoa/double-conversion.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ #define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ -#include "utils.h" +#include <wtf/dtoa/utils.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/dtoa/utils.h b/Source/JavaScriptCore/wtf/dtoa/utils.h index 64e5ad42f..da6e13226 100644 --- a/Source/JavaScriptCore/wtf/dtoa/utils.h +++ b/Source/JavaScriptCore/wtf/dtoa/utils.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_UTILS_H_ #define DOUBLE_CONVERSION_UTILS_H_ -#include "Assertions.h" +#include <wtf/Assertions.h> #include <stdlib.h> #include <string.h> diff --git a/Source/JavaScriptCore/wtf/gobject/GRefPtr.cpp b/Source/JavaScriptCore/wtf/gobject/GRefPtr.cpp index 1cd22c532..30df2c9a6 100644 --- a/Source/JavaScriptCore/wtf/gobject/GRefPtr.cpp +++ b/Source/JavaScriptCore/wtf/gobject/GRefPtr.cpp @@ -37,6 +37,32 @@ template <> void derefGPtr(GHashTable* ptr) g_hash_table_unref(ptr); } +template <> GMainContext* refGPtr(GMainContext* ptr) +{ + if (ptr) + g_main_context_ref(ptr); + return ptr; +} + +template <> void derefGPtr(GMainContext* ptr) +{ + if (ptr) + g_main_context_unref(ptr); +} + +template <> GMainLoop* refGPtr(GMainLoop* ptr) +{ + if (ptr) + g_main_loop_ref(ptr); + return ptr; +} + +template <> void derefGPtr(GMainLoop* ptr) +{ + if (ptr) + g_main_loop_unref(ptr); +} + #if GLIB_CHECK_VERSION(2, 24, 0) template <> GVariant* refGPtr(GVariant* ptr) { diff --git a/Source/JavaScriptCore/wtf/gobject/GRefPtr.h b/Source/JavaScriptCore/wtf/gobject/GRefPtr.h index 10ebf0753..92acffc0c 100644 --- a/Source/JavaScriptCore/wtf/gobject/GRefPtr.h +++ b/Source/JavaScriptCore/wtf/gobject/GRefPtr.h @@ -25,9 +25,8 @@ #if ENABLE(GLIB_SUPPORT) -#include "AlwaysInline.h" -#include "GRefPtr.h" -#include "RefPtr.h" +#include <wtf/AlwaysInline.h> +#include <wtf/RefPtr.h> #include <algorithm> extern "C" void g_object_unref(gpointer); @@ -201,6 +200,10 @@ template <typename T> GRefPtr<T> adoptGRef(T* p) template <> GHashTable* refGPtr(GHashTable* ptr); template <> void derefGPtr(GHashTable* ptr); +template <> GMainContext* refGPtr(GMainContext* ptr); +template <> void derefGPtr(GMainContext* ptr); +template <> GMainLoop* refGPtr(GMainLoop* ptr); +template <> void derefGPtr(GMainLoop* ptr); template <> GVariant* refGPtr(GVariant* ptr); template <> void derefGPtr(GVariant* ptr); template <> GSource* refGPtr(GSource* ptr); diff --git a/Source/JavaScriptCore/wtf/gobject/GTypedefs.h b/Source/JavaScriptCore/wtf/gobject/GTypedefs.h index cb3842b78..e29250bef 100644 --- a/Source/JavaScriptCore/wtf/gobject/GTypedefs.h +++ b/Source/JavaScriptCore/wtf/gobject/GTypedefs.h @@ -51,6 +51,8 @@ typedef struct _GFile GFile; typedef struct _GHashTable GHashTable; typedef struct _GInputStream GInputStream; typedef struct _GList GList; +typedef struct _GMainContext GMainContext; +typedef struct _GMainLoop GMainLoop; typedef struct _GPatternSpec GPatternSpec; typedef struct _GPollableOutputStream GPollableOutputStream; typedef struct _GSList GSList; diff --git a/Source/JavaScriptCore/wtf/gobject/GlibUtilities.h b/Source/JavaScriptCore/wtf/gobject/GlibUtilities.h index 5577bf58e..ce10a05c8 100644 --- a/Source/JavaScriptCore/wtf/gobject/GlibUtilities.h +++ b/Source/JavaScriptCore/wtf/gobject/GlibUtilities.h @@ -20,8 +20,8 @@ #ifndef GlibUtilities_h #define GlibUtilities_h -#include "Assertions.h" -#include "CString.h" +#include <wtf/Assertions.h> +#include <wtf/text/CString.h> CString getCurrentExecutablePath(); diff --git a/Source/JavaScriptCore/wtf/text/AtomicString.h b/Source/JavaScriptCore/wtf/text/AtomicString.h index b135845fe..e7323f94a 100644 --- a/Source/JavaScriptCore/wtf/text/AtomicString.h +++ b/Source/JavaScriptCore/wtf/text/AtomicString.h @@ -21,8 +21,8 @@ #ifndef AtomicString_h #define AtomicString_h -#include "AtomicStringImpl.h" -#include "WTFString.h" +#include <wtf/text/AtomicStringImpl.h> +#include <wtf/text/WTFString.h> // Define 'NO_IMPLICIT_ATOMICSTRING' before including this header, // to disallow (expensive) implicit String-->AtomicString conversions. @@ -213,5 +213,5 @@ using WTF::xmlAtom; using WTF::xmlnsAtom; #endif -#include "StringConcatenate.h" +#include <wtf/text/StringConcatenate.h> #endif // AtomicString_h diff --git a/Source/JavaScriptCore/wtf/text/AtomicStringImpl.h b/Source/JavaScriptCore/wtf/text/AtomicStringImpl.h index 3f0c37606..0716275a8 100644 --- a/Source/JavaScriptCore/wtf/text/AtomicStringImpl.h +++ b/Source/JavaScriptCore/wtf/text/AtomicStringImpl.h @@ -21,7 +21,7 @@ #ifndef AtomicStringImpl_h #define AtomicStringImpl_h -#include "StringImpl.h" +#include <wtf/text/StringImpl.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/text/CString.h b/Source/JavaScriptCore/wtf/text/CString.h index d43ad4bd7..9abfa70f7 100644 --- a/Source/JavaScriptCore/wtf/text/CString.h +++ b/Source/JavaScriptCore/wtf/text/CString.h @@ -26,9 +26,9 @@ #ifndef CString_h #define CString_h -#include "PassRefPtr.h" -#include "RefCounted.h" -#include "Vector.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/Vector.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/text/StringConcatenate.h b/Source/JavaScriptCore/wtf/text/StringConcatenate.h index 08d67dcf0..479ed8ca2 100644 --- a/Source/JavaScriptCore/wtf/text/StringConcatenate.h +++ b/Source/JavaScriptCore/wtf/text/StringConcatenate.h @@ -27,7 +27,7 @@ #define StringConcatenate_h #ifndef WTFString_h -#include "AtomicString.h" +#include <wtf/text/AtomicString.h> #endif // This macro is helpful for testing how many intermediate Strings are created while evaluating an @@ -960,5 +960,5 @@ String makeString(StringType1 string1, StringType2 string2, StringType3 string3, using WTF::makeString; -#include "StringOperators.h" +#include <wtf/text/StringOperators.h> #endif diff --git a/Source/JavaScriptCore/wtf/text/StringHash.h b/Source/JavaScriptCore/wtf/text/StringHash.h index 1b7a2ee2c..acc97b995 100644 --- a/Source/JavaScriptCore/wtf/text/StringHash.h +++ b/Source/JavaScriptCore/wtf/text/StringHash.h @@ -22,8 +22,8 @@ #ifndef StringHash_h #define StringHash_h -#include "AtomicString.h" -#include "WTFString.h" +#include <wtf/text/AtomicString.h> +#include <wtf/text/WTFString.h> #include <wtf/Forward.h> #include <wtf/HashTraits.h> #include <wtf/StringHasher.h> diff --git a/Source/JavaScriptCore/wtf/text/WTFString.h b/Source/JavaScriptCore/wtf/text/WTFString.h index edc842154..85e223f9e 100644 --- a/Source/JavaScriptCore/wtf/text/WTFString.h +++ b/Source/JavaScriptCore/wtf/text/WTFString.h @@ -25,8 +25,8 @@ // This file would be called String.h, but that conflicts with <string.h> // on systems without case-sensitive file systems. -#include "ASCIIFastPath.h" -#include "StringImpl.h" +#include <wtf/text/ASCIIFastPath.h> +#include <wtf/text/StringImpl.h> #ifdef __OBJC__ #include <objc/objc.h> @@ -646,5 +646,5 @@ using WTF::isSpaceOrNewline; using WTF::reverseFind; using WTF::ShouldRoundDecimalPlaces; -#include "AtomicString.h" +#include <wtf/text/AtomicString.h> #endif diff --git a/Source/JavaScriptCore/wtf/unicode/CharacterNames.h b/Source/JavaScriptCore/wtf/unicode/CharacterNames.h index 4acb5f0b1..78b7bf7b9 100644 --- a/Source/JavaScriptCore/wtf/unicode/CharacterNames.h +++ b/Source/JavaScriptCore/wtf/unicode/CharacterNames.h @@ -26,7 +26,7 @@ #ifndef CharacterNames_h #define CharacterNames_h -#include "Unicode.h" +#include <wtf/unicode/Unicode.h> namespace WTF { namespace Unicode { diff --git a/Source/JavaScriptCore/wtf/unicode/UTF8.h b/Source/JavaScriptCore/wtf/unicode/UTF8.h index bc2497b72..59f6994be 100644 --- a/Source/JavaScriptCore/wtf/unicode/UTF8.h +++ b/Source/JavaScriptCore/wtf/unicode/UTF8.h @@ -26,7 +26,7 @@ #ifndef WTF_UTF8_h #define WTF_UTF8_h -#include "Unicode.h" +#include <wtf/unicode/Unicode.h> namespace WTF { namespace Unicode { diff --git a/Source/JavaScriptCore/wtf/unicode/glib/UnicodeGLib.h b/Source/JavaScriptCore/wtf/unicode/glib/UnicodeGLib.h index 7bff934ba..8ad532917 100644 --- a/Source/JavaScriptCore/wtf/unicode/glib/UnicodeGLib.h +++ b/Source/JavaScriptCore/wtf/unicode/glib/UnicodeGLib.h @@ -25,9 +25,9 @@ #ifndef UnicodeGLib_h #define UnicodeGLib_h -#include "GOwnPtr.h" -#include "ScriptCodesFromICU.h" -#include "UnicodeMacrosFromICU.h" +#include <wtf/gobject/GOwnPtr.h> +#include <wtf/unicode/ScriptCodesFromICU.h> +#include <wtf/unicode/UnicodeMacrosFromICU.h> #include <glib.h> #include <pango/pango.h> diff --git a/Source/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h b/Source/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h index e4f39b292..a2d1ad4c1 100644 --- a/Source/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h +++ b/Source/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h @@ -23,8 +23,8 @@ #ifndef WTF_UNICODE_QT4_H #define WTF_UNICODE_QT4_H -#include "ScriptCodesFromICU.h" -#include "UnicodeMacrosFromICU.h" +#include <wtf/unicode/ScriptCodesFromICU.h> +#include <wtf/unicode/UnicodeMacrosFromICU.h> #include <QChar> #include <QString> diff --git a/Source/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.h b/Source/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.h index af6ff0748..1663fc969 100644 --- a/Source/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.h +++ b/Source/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.h @@ -24,8 +24,8 @@ #ifndef WTF_UnicodeWinCE_h #define WTF_UnicodeWinCE_h -#include "ScriptCodesFromICU.h" -#include "UnicodeMacrosFromICU.h" +#include <wtf/unicode/ScriptCodesFromICU.h> +#include <wtf/unicode/UnicodeMacrosFromICU.h> #include "ce_unicode.h" diff --git a/Source/JavaScriptCore/wtf/url/api/ParsedURL.cpp b/Source/JavaScriptCore/wtf/url/api/ParsedURL.cpp index 3c1519136..f69162a67 100644 --- a/Source/JavaScriptCore/wtf/url/api/ParsedURL.cpp +++ b/Source/JavaScriptCore/wtf/url/api/ParsedURL.cpp @@ -33,13 +33,21 @@ namespace WTF { -ParsedURL::ParsedURL(const URLString& spec) - : m_spec(spec) +ParsedURL::ParsedURL(const String& urlString) + : m_spec(urlString) { // FIXME: Handle non-standard URLs. - if (spec.string().isEmpty()) + if (urlString.isEmpty()) return; - URLParser<UChar>::parseStandardURL(spec.string().characters(), spec.string().length(), m_segments); + URLParser<UChar>::parseStandardURL(urlString.characters(), urlString.length(), m_segments); +} + +ParsedURL ParsedURL::isolatedCopy() const +{ + ParsedURL copy; + copy.m_segments = this->m_segments; + copy.m_spec = URLString(this->m_spec.string().isolatedCopy()); + return copy; } String ParsedURL::scheme() const @@ -82,11 +90,22 @@ String ParsedURL::fragment() const return segment(m_segments.fragment); } +String ParsedURL::baseAsString() const +{ + // FIXME: Add WTFURL Implementation. + return String(); +} + String ParsedURL::segment(const URLComponent& component) const { + ASSERT(isValid()); + if (!component.isValid()) return String(); - return m_spec.string().substring(component.begin(), component.length()); + + String segment = m_spec.string().substring(component.begin(), component.length()); + ASSERT_WITH_MESSAGE(!segment.isEmpty(), "A valid URL component should not be empty."); + return segment; } } diff --git a/Source/JavaScriptCore/wtf/url/api/ParsedURL.h b/Source/JavaScriptCore/wtf/url/api/ParsedURL.h index 023589564..2bb3330cf 100644 --- a/Source/JavaScriptCore/wtf/url/api/ParsedURL.h +++ b/Source/JavaScriptCore/wtf/url/api/ParsedURL.h @@ -28,27 +28,35 @@ #if USE(WTFURL) -#include "URLSegments.h" -#include "URLString.h" +#include <wtf/url/api/URLString.h> +#include <wtf/url/src/URLSegments.h> namespace WTF { class URLComponent; +// ParsedURL represents a valid URL decomposed by components. class ParsedURL { public: - explicit ParsedURL(const URLString&); - // FIXME: Add a method for parsing non-canonicalized URLs. + ParsedURL() { }; + WTF_EXPORT_PRIVATE explicit ParsedURL(const String&); + + WTF_EXPORT_PRIVATE ParsedURL isolatedCopy() const; + + bool isValid() const { return !m_spec.string().isEmpty(); } + + // Return a URL component or a null String if the component is undefined for the URL. + WTF_EXPORT_PRIVATE String scheme() const; + WTF_EXPORT_PRIVATE String username() const; + WTF_EXPORT_PRIVATE String password() const; + WTF_EXPORT_PRIVATE String host() const; + WTF_EXPORT_PRIVATE String port() const; + WTF_EXPORT_PRIVATE String path() const; + WTF_EXPORT_PRIVATE String query() const; + WTF_EXPORT_PRIVATE String fragment() const; - String scheme() const; - String username() const; - String password() const; - String host() const; - String port() const; - String path() const; - String query() const; - String fragment() const; + WTF_EXPORT_PRIVATE String baseAsString() const; URLString spec() { return m_spec; } diff --git a/Source/JavaScriptCore/wtf/url/api/URLString.h b/Source/JavaScriptCore/wtf/url/api/URLString.h index 329f51e2f..9ae30d7a9 100644 --- a/Source/JavaScriptCore/wtf/url/api/URLString.h +++ b/Source/JavaScriptCore/wtf/url/api/URLString.h @@ -28,7 +28,7 @@ #if USE(WTFURL) -#include "WTFString.h" +#include <wtf/text/WTFString.h> namespace WTF { diff --git a/Source/JavaScriptCore/wtf/wince/FastMallocWinCE.h b/Source/JavaScriptCore/wtf/wince/FastMallocWinCE.h index d91a5f2c9..3601249cf 100644 --- a/Source/JavaScriptCore/wtf/wince/FastMallocWinCE.h +++ b/Source/JavaScriptCore/wtf/wince/FastMallocWinCE.h @@ -26,7 +26,7 @@ #ifdef __cplusplus #include <new> -#include "MemoryManager.h" +#include <wtf/wince/MemoryManager.h> extern "C" { #endif |