From ea0b0f4c07959bc8efbe0fe1223b6b23452dea28 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 16 Nov 2012 16:52:18 -0800 Subject: [PATCH] Remove yarr/TypeTraits.h (bug 812678, r=luke). --- js/src/yarr/CheckedArithmetic.h | 3 +- js/src/yarr/TypeTraits.h | 261 -------------------------------- js/src/yarr/wtfbridge.h | 1 + 3 files changed, 2 insertions(+), 263 deletions(-) delete mode 100644 js/src/yarr/TypeTraits.h diff --git a/js/src/yarr/CheckedArithmetic.h b/js/src/yarr/CheckedArithmetic.h index b36d48600030..7449ef116f6c 100644 --- a/js/src/yarr/CheckedArithmetic.h +++ b/js/src/yarr/CheckedArithmetic.h @@ -28,7 +28,6 @@ #define CheckedArithmetic_h #include "assembler/wtf/Assertions.h" -#include "TypeTraits.h" #include #include "mozilla/StandardInteger.h" @@ -160,7 +159,7 @@ template struct BoundsChecker::value> struct BoundsCheckElider; +template ::result> struct BoundsCheckElider; template struct BoundsCheckElider { static bool inBounds(Source) { return true; } }; diff --git a/js/src/yarr/TypeTraits.h b/js/src/yarr/TypeTraits.h deleted file mode 100644 index f5ed5ad361f4..000000000000 --- a/js/src/yarr/TypeTraits.h +++ /dev/null @@ -1,261 +0,0 @@ - /* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2009, 2010 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 TypeTraits_h -#define TypeTraits_h - -#include "assembler/wtf/Platform.h" - -#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) -#include -#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__) -#include -#endif -#endif - -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 - // RemoveReference::Type - // 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; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; -#if WTF_COMPILER_MSVC || defined(_NATIVE_WCHAR_T_DEFINED) - template<> struct IsInteger { static const bool value = true; }; -#endif - - template struct IsFloatingPoint { static const bool value = false; }; - template<> struct IsFloatingPoint { static const bool value = true; }; - template<> struct IsFloatingPoint { static const bool value = true; }; - template<> struct IsFloatingPoint { static const bool value = true; }; - - template struct IsArithmetic { static const bool value = IsInteger::value || IsFloatingPoint::value; }; - - // IsPod is misnamed as it doesn't cover all plain old data (pod) types. - // Specifically, it doesn't allow for enums or for structs. - template struct IsPod { static const bool value = IsArithmetic::value; }; - template struct IsPod { static const bool value = true; }; - - template class IsConvertibleToInteger { - // Avoid "possible loss of data" warning when using Microsoft's C++ compiler - // by not converting int's to doubles. - template class IsConvertibleToDouble; - template class IsConvertibleToDouble { - public: - static const bool value = false; - }; - - template class IsConvertibleToDouble { - typedef char YesType; - struct NoType { - char padding[8]; - }; - - static YesType floatCheck(long double); - static NoType floatCheck(...); - static T& t; - public: - static const bool value = sizeof(floatCheck(t)) == sizeof(YesType); - }; - - public: - 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; - }; - - template struct IsSameType { - static const bool value = true; - }; - - template class IsSubclass { - typedef char YesType; - struct NoType { - char padding[8]; - }; - - static YesType subclassCheck(U*); - static NoType subclassCheck(...); - static T* t; - public: - static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType); - }; - - template class U> class IsSubclassOfTemplate { - typedef char YesType; - struct NoType { - char padding[8]; - }; - - template static YesType subclassCheck(U*); - static NoType subclassCheck(...); - static T* t; - public: - static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType); - }; - - template class OuterTemplate> struct RemoveTemplate { - typedef T Type; - }; - - template class OuterTemplate> struct RemoveTemplate, OuterTemplate> { - typedef T Type; - }; - - template struct RemoveConst { - typedef T Type; - }; - - template struct RemoveConst { - typedef T Type; - }; - - template struct RemoveVolatile { - typedef T Type; - }; - - template struct RemoveVolatile { - typedef T Type; - }; - - template struct RemoveConstVolatile { - typedef typename RemoveVolatile::Type>::Type Type; - }; - - template struct RemovePointer { - typedef T Type; - }; - - template struct RemovePointer { - typedef T Type; - }; - - template struct RemoveReference { - typedef T Type; - }; - - template struct RemoveReference { - 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 WTF_COMPILER_CLANG || GCC_VERSION_AT_LEAST(4, 6, 0) || (defined(_MSC_VER) && (_MSC_VER >= 1400) && (_MSC_VER < 1600) && !defined(__INTEL_COMPILER)) - // VC8 (VS2005) and later has __has_trivial_constructor and __has_trivial_destructor, - // but the implementation returns false for built-in types. We add the extra IsPod condition to - // work around this. - template struct HasTrivialConstructor { - static const bool value = __has_trivial_constructor(T) || IsPod >::value; - }; - template struct HasTrivialDestructor { - static const bool value = __has_trivial_destructor(T) || IsPod >::value; - }; -#elif (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. - // VC10 (VS2010) and later support C++ TR1 type_traits in the std::tr1 namespace. - template struct HasTrivialConstructor : public std::tr1::has_trivial_constructor { }; - template struct HasTrivialDestructor : public std::tr1::has_trivial_destructor { }; -#else - // For compilers that don't support detection of trivial constructors and destructors in classes, - // we use a template that returns true for any POD type that IsPod can detect (see IsPod caveats above), - // but false for all other types (which includes all classes). This will give false negatives, which can hurt - // performance, but avoids false positives, which would result in incorrect behavior. - template struct HasTrivialConstructor { - static const bool value = IsPod >::value; - }; - template struct HasTrivialDestructor { - static const bool value = IsPod >::value; - }; -#endif - -} // namespace WTF - -#endif // TypeTraits_h diff --git a/js/src/yarr/wtfbridge.h b/js/src/yarr/wtfbridge.h index a197c53b45b7..53c0161fb14f 100644 --- a/js/src/yarr/wtfbridge.h +++ b/js/src/yarr/wtfbridge.h @@ -20,6 +20,7 @@ #include "assembler/wtf/Platform.h" #include "assembler/jit/ExecutableAllocator.h" #include "CheckedArithmetic.h" +#include "js/TemplateLib.h" namespace JSC { namespace Yarr {