From d11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 11 Jan 2012 10:03:25 +0100 Subject: Imported WebKit commit 75bb2fc5882d2e1b3d5572c2961507996cbca5e3 (http://svn.webkit.org/repository/webkit/trunk@104681) --- Source/JavaScriptCore/wtf/Assertions.cpp | 46 +++++++++++++++++++++++- Source/JavaScriptCore/wtf/ByteArray.h | 2 +- Source/JavaScriptCore/wtf/CMakeLists.txt | 10 +----- Source/JavaScriptCore/wtf/DateMath.cpp | 1 + Source/JavaScriptCore/wtf/Functional.h | 20 +++++++++++ Source/JavaScriptCore/wtf/ListHashSet.h | 2 +- Source/JavaScriptCore/wtf/OwnFastMallocPtr.h | 53 ---------------------------- Source/JavaScriptCore/wtf/TypeTraits.cpp | 13 +++++++ Source/JavaScriptCore/wtf/TypeTraits.h | 46 ++++++++++++++++++++++++ Source/JavaScriptCore/wtf/text/StringImpl.h | 1 - Source/JavaScriptCore/wtf/wtf.pro | 1 - 11 files changed, 128 insertions(+), 67 deletions(-) delete mode 100644 Source/JavaScriptCore/wtf/OwnFastMallocPtr.h (limited to 'Source/JavaScriptCore/wtf') diff --git a/Source/JavaScriptCore/wtf/Assertions.cpp b/Source/JavaScriptCore/wtf/Assertions.cpp index de062ce25..3da67effe 100644 --- a/Source/JavaScriptCore/wtf/Assertions.cpp +++ b/Source/JavaScriptCore/wtf/Assertions.cpp @@ -98,7 +98,7 @@ static void vprintf_stderr_common(const char* format, va_list args) // Fall through to write to stderr in the same manner as other platforms. #elif PLATFORM(BLACKBERRY) - BlackBerry::Platform::logV(BlackBerry::Platform::LogLevelInfo, format, args); + BlackBerry::Platform::logStreamV(format, args); #elif HAVE(ISDEBUGGERPRESENT) if (IsDebuggerPresent()) { size_t size = 1024; @@ -133,7 +133,9 @@ static void vprintf_stderr_common(const char* format, va_list args) } while (size > 1024); } #endif +#if !PLATFORM(BLACKBERRY) vfprintf(stderr, format, args); +#endif } #if COMPILER(CLANG) || (COMPILER(GCC) && GCC_VERSION_AT_LEAST(4, 6, 0)) @@ -194,8 +196,26 @@ static void printCallSite(const char* file, int line, const char* function) #endif } +#if PLATFORM(BLACKBERRY) +struct WTFLogLocker { + WTFLogLocker(BlackBerry::Platform::MessageLogLevel logLevel) + { + BlackBerry::Platform::lockLogging(logLevel); + } + + ~WTFLogLocker() + { + BlackBerry::Platform::unlockLogging(); + } +}; +#endif + void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion) { +#if PLATFORM(BLACKBERRY) + WTFLogLocker locker(BlackBerry::Platform::LogLevelCritical); +#endif + if (assertion) printf_stderr_common("ASSERTION FAILED: %s\n", assertion); else @@ -205,6 +225,10 @@ void WTFReportAssertionFailure(const char* file, int line, const char* function, void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) { +#if PLATFORM(BLACKBERRY) + WTFLogLocker locker(BlackBerry::Platform::LogLevelCritical); +#endif + va_list args; va_start(args, format); vprintf_stderr_with_prefix("ASSERTION FAILED: ", format, args); @@ -215,6 +239,10 @@ void WTFReportAssertionFailureWithMessage(const char* file, int line, const char void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion) { +#if PLATFORM(BLACKBERRY) + WTFLogLocker locker(BlackBerry::Platform::LogLevelCritical); +#endif + printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion); printCallSite(file, line, function); } @@ -275,6 +303,10 @@ void WTFReportBacktrace() void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) { +#if PLATFORM(BLACKBERRY) + WTFLogLocker locker(BlackBerry::Platform::LogLevelCritical); +#endif + va_list args; va_start(args, format); vprintf_stderr_with_prefix("FATAL ERROR: ", format, args); @@ -285,6 +317,10 @@ void WTFReportFatalError(const char* file, int line, const char* function, const void WTFReportError(const char* file, int line, const char* function, const char* format, ...) { +#if PLATFORM(BLACKBERRY) + WTFLogLocker locker(BlackBerry::Platform::LogLevelWarn); +#endif + va_list args; va_start(args, format); vprintf_stderr_with_prefix("ERROR: ", format, args); @@ -298,6 +334,10 @@ void WTFLog(WTFLogChannel* channel, const char* format, ...) if (channel->state != WTFLogChannelOn) return; +#if PLATFORM(BLACKBERRY) + WTFLogLocker locker(BlackBerry::Platform::LogLevelInfo); +#endif + va_list args; va_start(args, format); vprintf_stderr_with_trailing_newline(format, args); @@ -309,6 +349,10 @@ void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChann if (channel->state != WTFLogChannelOn) return; +#if PLATFORM(BLACKBERRY) + WTFLogLocker locker(BlackBerry::Platform::LogLevelInfo); +#endif + va_list args; va_start(args, format); vprintf_stderr_with_trailing_newline(format, args); diff --git a/Source/JavaScriptCore/wtf/ByteArray.h b/Source/JavaScriptCore/wtf/ByteArray.h index 009ec5850..6964a33df 100644 --- a/Source/JavaScriptCore/wtf/ByteArray.h +++ b/Source/JavaScriptCore/wtf/ByteArray.h @@ -97,7 +97,7 @@ namespace WTF { // MSVC can't handle correctly unsized array. // warning C4200: nonstandard extension used : zero-sized array in struct/union // Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array -#if COMPILER(MSVC) && !COMPILER(INTEL) +#if (COMPILER(MSVC) || COMPILER(SUNCC)) && !COMPILER(INTEL) unsigned char m_data[INT_MAX]; #else unsigned char m_data[]; diff --git a/Source/JavaScriptCore/wtf/CMakeLists.txt b/Source/JavaScriptCore/wtf/CMakeLists.txt index 6d1cee899..52d3e3c4d 100644 --- a/Source/JavaScriptCore/wtf/CMakeLists.txt +++ b/Source/JavaScriptCore/wtf/CMakeLists.txt @@ -56,7 +56,6 @@ SET(WTF_HEADERS OSAllocator.h OSRandomSource.h OwnArrayPtr.h - OwnFastMallocPtr.h OwnPtr.h OwnPtrCommon.h PageAllocation.h @@ -187,12 +186,12 @@ SET(WTF_INCLUDE_DIRECTORIES "${JAVASCRIPTCORE_DIR}/wtf/unicode" "${JAVASCRIPTCORE_DIR}/wtf/dtoa" "${JavaScriptCore_INCLUDE_DIRECTORIES}" + "${THIRDPARTY_DIR}" ) SET(WTF_LIBRARIES ) - IF (ENABLE_FAST_MALLOC) LIST(APPEND WTF_SOURCES TCSystemAlloc.cpp @@ -201,15 +200,8 @@ ELSE () ADD_DEFINITIONS(-DUSE_SYSTEM_MALLOC=1) ENDIF() - -SET(WTF_PORT_FLAGS ) INCLUDE_IF_EXISTS(${JAVASCRIPTCORE_DIR}/wtf/Platform${PORT}.cmake) -LIST(APPEND WTF_INCLUDE_DIRECTORIES - "${CMAKE_BINARY_DIR}" - "${CMAKE_SOURCE_DIR}/Source/ThirdParty" -) - WEBKIT_WRAP_SOURCELIST(${WTF_SOURCES}) INCLUDE_DIRECTORIES(${WTF_INCLUDE_DIRECTORIES}) ADD_DEFINITIONS(-DBUILDING_WTF) diff --git a/Source/JavaScriptCore/wtf/DateMath.cpp b/Source/JavaScriptCore/wtf/DateMath.cpp index 86bd99527..dc503ca2a 100644 --- a/Source/JavaScriptCore/wtf/DateMath.cpp +++ b/Source/JavaScriptCore/wtf/DateMath.cpp @@ -961,6 +961,7 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT else offset = o * 60 * sgn; } else { // GMT+05:00 + ++dateString; // skip the ':' long o2; if (!parseLong(dateString, &newPosStr, 10, &o2)) return std::numeric_limits::quiet_NaN(); diff --git a/Source/JavaScriptCore/wtf/Functional.h b/Source/JavaScriptCore/wtf/Functional.h index 86d6203cf..bd0f3e282 100644 --- a/Source/JavaScriptCore/wtf/Functional.h +++ b/Source/JavaScriptCore/wtf/Functional.h @@ -136,6 +136,26 @@ private: R (*m_function)(P1, P2); }; +template +class FunctionWrapper { +public: + typedef R ResultType; + static const bool shouldRefFirstParameter = false; + + explicit FunctionWrapper(R (*function)(P1, P2, P3)) + : m_function(function) + { + } + + R operator()(P1 p1, P2 p2, P3 p3) + { + return m_function(p1, p2, p3); + } + +private: + R (*m_function)(P1, P2, P3); +}; + template class FunctionWrapper { public: diff --git a/Source/JavaScriptCore/wtf/ListHashSet.h b/Source/JavaScriptCore/wtf/ListHashSet.h index 3b413406d..32bd23832 100644 --- a/Source/JavaScriptCore/wtf/ListHashSet.h +++ b/Source/JavaScriptCore/wtf/ListHashSet.h @@ -375,7 +375,7 @@ namespace WTF { private: typedef ListHashSet ListHashSetType; typedef ListHashSetReverseIterator reverse_iterator; - typedef ListHashSetConstIterator const_reverse_iterator; + typedef ListHashSetConstReverseIterator const_reverse_iterator; typedef ListHashSetNode Node; typedef ValueArg ValueType; typedef ValueType& ReferenceType; diff --git a/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h b/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h deleted file mode 100644 index 183bfec8f..000000000 --- a/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2009 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 - * 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 OwnFastMallocPtr_h -#define OwnFastMallocPtr_h - -#include "FastMalloc.h" -#include - -namespace WTF { - - template class OwnFastMallocPtr { - WTF_MAKE_NONCOPYABLE(OwnFastMallocPtr); - public: - explicit OwnFastMallocPtr(T* ptr) : m_ptr(ptr) - { - } - - ~OwnFastMallocPtr() - { - fastFree(const_cast(static_cast(const_cast(m_ptr)))); - } - - T* get() const { return m_ptr; } - T* release() { T* ptr = m_ptr; m_ptr = 0; return ptr; } - - private: - T* m_ptr; - }; - -} // namespace WTF - -using WTF::OwnFastMallocPtr; - -#endif // OwnFastMallocPtr_h diff --git a/Source/JavaScriptCore/wtf/TypeTraits.cpp b/Source/JavaScriptCore/wtf/TypeTraits.cpp index afeaa5e4c..7cea256b7 100644 --- a/Source/JavaScriptCore/wtf/TypeTraits.cpp +++ b/Source/JavaScriptCore/wtf/TypeTraits.cpp @@ -139,4 +139,17 @@ COMPILE_ASSERT((!IsSameType::Type>::value), WTF_Test_R COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_RemoveReference_int); COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_RemoveReference_int_reference); + +typedef int IntArray[]; +typedef int IntArraySized[4]; + +COMPILE_ASSERT((IsArray::value), WTF_Test_IsArray_int_array); +COMPILE_ASSERT((IsArray::value), WTF_Test_IsArray_int_sized_array); + +COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_RemoveExtent_int_array); +COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_RemoveReference_int_sized_array); + +COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_DecayArray_int_array); +COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_DecayArray_int_sized_array); + } // namespace WTF diff --git a/Source/JavaScriptCore/wtf/TypeTraits.h b/Source/JavaScriptCore/wtf/TypeTraits.h index 6c7466acc..34e8b79a3 100644 --- a/Source/JavaScriptCore/wtf/TypeTraits.h +++ b/Source/JavaScriptCore/wtf/TypeTraits.h @@ -35,10 +35,14 @@ namespace WTF { // The following are provided in this file: // + // Conditional::Type + // // IsInteger::value // IsPod::value, see the definition for a note about its limitations // IsConvertibleToInteger::value // + // IsArray::value + // // IsSameType::value // // RemovePointer::Type @@ -46,9 +50,15 @@ namespace WTF { // RemoveConst::Type // RemoveVolatile::Type // RemoveConstVolatile::Type + // RemoveExtent::Type + // + // DecayArray::Type // // COMPILE_ASSERT's in TypeTraits.cpp illustrate their usage and what they do. + template struct Conditional { typedef If Type; }; + template struct Conditional { typedef Then Type; }; + template struct IsInteger { static const bool value = false; }; template<> struct IsInteger { static const bool value = true; }; template<> struct IsInteger { static const bool value = true; }; @@ -104,6 +114,20 @@ namespace WTF { static const bool value = IsInteger::value || IsConvertibleToDouble::value, T>::value; }; + + template struct IsArray { + static const bool value = false; + }; + + template struct IsArray { + static const bool value = true; + }; + + template struct IsArray { + static const bool value = true; + }; + + template struct IsSameType { static const bool value = false; }; @@ -182,6 +206,28 @@ namespace WTF { typedef T Type; }; + template struct RemoveExtent { + typedef T Type; + }; + + template struct RemoveExtent { + typedef T Type; + }; + + template struct RemoveExtent { + typedef T Type; + }; + + template struct DecayArray { + typedef typename RemoveReference::Type U; + public: + typedef typename Conditional< + IsArray::value, + typename RemoveExtent::Type*, + typename RemoveConstVolatile::Type + >::Type Type; + }; + #if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) // GCC's libstdc++ 20070724 and later supports C++ TR1 type_traits in the std namespace. diff --git a/Source/JavaScriptCore/wtf/text/StringImpl.h b/Source/JavaScriptCore/wtf/text/StringImpl.h index a3008e1d3..003c44ce6 100644 --- a/Source/JavaScriptCore/wtf/text/StringImpl.h +++ b/Source/JavaScriptCore/wtf/text/StringImpl.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/Source/JavaScriptCore/wtf/wtf.pro b/Source/JavaScriptCore/wtf/wtf.pro index e59d118e2..234348f2b 100644 --- a/Source/JavaScriptCore/wtf/wtf.pro +++ b/Source/JavaScriptCore/wtf/wtf.pro @@ -90,7 +90,6 @@ HEADERS += \ OSAllocator.h \ OSRandomSource.h \ OwnArrayPtr.h \ - OwnFastMallocPtr.h \ OwnPtr.h \ OwnPtrCommon.h \ PackedIntVector.h \ -- cgit v1.2.1