From 010f089971c5255c8f6850caef671bcac759f1b7 Mon Sep 17 00:00:00 2001 From: "bmeurer@chromium.org" Date: Mon, 20 Oct 2014 12:04:22 +0000 Subject: [PATCH] Remove (untested) code for unsupported compilers. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/656143004 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24735 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- BUILD.gn | 2 - include/v8config.h | 13 +++--- src/base/compiler-specific.h | 2 - src/base/platform/platform-win32.cc | 18 +------- src/base/platform/platform.h | 34 +-------------- src/base/win32-math.cc | 82 ------------------------------------ src/base/win32-math.h | 42 ------------------ src/preparser.cc | 10 ----- src/utils.h | 2 +- test/cctest/cctest.cc | 16 +++---- test/cctest/test-log-stack-tracer.cc | 4 +- test/cctest/test-serialize.cc | 4 +- tools/gyp/v8.gyp | 4 -- 13 files changed, 22 insertions(+), 211 deletions(-) delete mode 100644 src/base/win32-math.cc delete mode 100644 src/base/win32-math.h diff --git a/BUILD.gn b/BUILD.gn index 56fded6..c8b0292 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1318,8 +1318,6 @@ source_set("v8_libbase") { sources += [ "src/base/platform/platform-win32.cc", "src/base/win32-headers.h", - "src/base/win32-math.cc", - "src/base/win32-math.h", ] defines += [ "_CRT_RAND_S" ] # for rand_s() diff --git a/include/v8config.h b/include/v8config.h index 87de994..2f6c688 100644 --- a/include/v8config.h +++ b/include/v8config.h @@ -178,6 +178,7 @@ // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported +// V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported @@ -186,7 +187,6 @@ // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported // V8_HAS___FINAL - __final supported in non-C++11 mode // V8_HAS___FORCEINLINE - __forceinline supported -// V8_HAS_SEALED - MSVC style sealed marker supported // // Note that testing for compilers and/or features must be done using #if // not #ifdef. For example, to test for Intel C++ Compiler, use: @@ -214,6 +214,7 @@ # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) +# define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow)) # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow)) @@ -251,6 +252,7 @@ # define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0)) # define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0)) # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) +# define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0)) # define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0)) // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality @@ -277,14 +279,11 @@ # define V8_HAS___ALIGNOF 1 -// Override control was added with Visual Studio 2005, but -// Visual Studio 2010 and earlier spell "final" as "sealed". -# define V8_HAS_CXX11_FINAL (_MSC_VER >= 1700) -# define V8_HAS_CXX11_OVERRIDE (_MSC_VER >= 1400) -# define V8_HAS_SEALED (_MSC_VER >= 1400) +# define V8_HAS_CXX11_FINAL 1 +# define V8_HAS_CXX11_OVERRIDE 1 # define V8_HAS_DECLSPEC_ALIGN 1 -# define V8_HAS_DECLSPEC_DEPRECATED (_MSC_VER >= 1300) +# define V8_HAS_DECLSPEC_DEPRECATED 1 # define V8_HAS_DECLSPEC_NOINLINE 1 # define V8_HAS___FORCEINLINE 1 diff --git a/src/base/compiler-specific.h b/src/base/compiler-specific.h index fccac9f..9755fc1 100644 --- a/src/base/compiler-specific.h +++ b/src/base/compiler-specific.h @@ -37,8 +37,6 @@ #define FINAL final #elif V8_HAS___FINAL #define FINAL __final -#elif V8_HAS_SEALED -#define FINAL sealed #else #define FINAL /* NOT SUPPORTED */ #endif diff --git a/src/base/platform/platform-win32.cc b/src/base/platform/platform-win32.cc index 10f89de..9b554b2 100644 --- a/src/base/platform/platform-win32.cc +++ b/src/base/platform/platform-win32.cc @@ -15,9 +15,7 @@ #endif // MINGW_HAS_SECURE_API #endif // __MINGW32__ -#ifdef _MSC_VER #include -#endif #include "src/base/win32-headers.h" @@ -28,16 +26,6 @@ #include "src/base/platform/time.h" #include "src/base/utils/random-number-generator.h" -#ifdef _MSC_VER - -// Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually -// defined in strings.h. -int strncasecmp(const char* s1, const char* s2, int n) { - return _strnicmp(s1, s2, n); -} - -#endif // _MSC_VER - // Extra functions for MinGW. Most of these are the _s functions which are in // the Microsoft Visual Studio C++ CRT. @@ -832,7 +820,7 @@ void OS::Abort() { void OS::DebugBreak() { -#ifdef _MSC_VER +#if V8_CC_MSVC // To avoid Visual Studio runtime support the following code can be used // instead // __asm { int 3 } @@ -1175,11 +1163,7 @@ void OS::SignalCodeMovingGC() { } double OS::nan_value() { -#ifdef _MSC_VER return std::numeric_limits::quiet_NaN(); -#else // _MSC_VER - return NAN; -#endif // _MSC_VER } diff --git a/src/base/platform/platform.h b/src/base/platform/platform.h index 10aba90..0bf1027 100644 --- a/src/base/platform/platform.h +++ b/src/base/platform/platform.h @@ -21,7 +21,7 @@ #ifndef V8_BASE_PLATFORM_PLATFORM_H_ #define V8_BASE_PLATFORM_PLATFORM_H_ -#include +#include #include #include @@ -33,36 +33,6 @@ #include "src/base/qnx-math.h" #endif -// Microsoft Visual C++ specific stuff. -#if V8_LIBC_MSVCRT - -#include "src/base/win32-headers.h" -#include "src/base/win32-math.h" - -int strncasecmp(const char* s1, const char* s2, int n); - -// Visual C++ 2013 and higher implement this function. -#if (_MSC_VER < 1800) -inline int lrint(double flt) { - int intgr; -#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 - __asm { - fld flt - fistp intgr - }; -#else - intgr = static_cast(flt + 0.5); - if ((intgr & 1) != 0 && intgr - flt == 0.5) { - // If the number is halfway between two integers, round to the even one. - intgr--; - } -#endif - return intgr; -} -#endif // _MSC_VER < 1800 - -#endif // V8_LIBC_MSVCRT - namespace v8 { namespace base { @@ -71,7 +41,7 @@ namespace base { #ifndef V8_NO_FAST_TLS -#if defined(_MSC_VER) && (V8_HOST_ARCH_IA32) +#if V8_CC_MSVC && V8_HOST_ARCH_IA32 #define V8_FAST_TLS_SUPPORTED 1 diff --git a/src/base/win32-math.cc b/src/base/win32-math.cc deleted file mode 100644 index d6fc78b..0000000 --- a/src/base/win32-math.cc +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2011 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Extra POSIX/ANSI routines for Win32 when using Visual Studio C++. Please -// refer to The Open Group Base Specification for specification of the correct -// semantics for these functions. -// (http://www.opengroup.org/onlinepubs/000095399/) -#if defined(_MSC_VER) && (_MSC_VER < 1800) - -#include "src/base/win32-headers.h" -#include // Required for DBL_MAX and on Win32 for finite() -#include // Required for INT_MAX etc. -#include -#include "src/base/win32-math.h" - -#include "src/base/logging.h" - - -namespace std { - -// Test for a NaN (not a number) value - usually defined in math.h -int isnan(double x) { - return _isnan(x); -} - - -// Test for infinity - usually defined in math.h -int isinf(double x) { - return (_fpclass(x) & (_FPCLASS_PINF | _FPCLASS_NINF)) != 0; -} - - -// Test for finite value - usually defined in math.h -int isfinite(double x) { - return _finite(x); -} - - -// Test if x is less than y and both nominal - usually defined in math.h -int isless(double x, double y) { - return isnan(x) || isnan(y) ? 0 : x < y; -} - - -// Test if x is greater than y and both nominal - usually defined in math.h -int isgreater(double x, double y) { - return isnan(x) || isnan(y) ? 0 : x > y; -} - - -// Classify floating point number - usually defined in math.h -int fpclassify(double x) { - // Use the MS-specific _fpclass() for classification. - int flags = _fpclass(x); - - // Determine class. We cannot use a switch statement because - // the _FPCLASS_ constants are defined as flags. - if (flags & (_FPCLASS_PN | _FPCLASS_NN)) return FP_NORMAL; - if (flags & (_FPCLASS_PZ | _FPCLASS_NZ)) return FP_ZERO; - if (flags & (_FPCLASS_PD | _FPCLASS_ND)) return FP_SUBNORMAL; - if (flags & (_FPCLASS_PINF | _FPCLASS_NINF)) return FP_INFINITE; - - // All cases should be covered by the code above. - DCHECK(flags & (_FPCLASS_SNAN | _FPCLASS_QNAN)); - return FP_NAN; -} - - -// Test sign - usually defined in math.h -int signbit(double x) { - // We need to take care of the special case of both positive - // and negative versions of zero. - if (x == 0) - return _fpclass(x) & _FPCLASS_NZ; - else - return x < 0; -} - -} // namespace std - -#endif // _MSC_VER diff --git a/src/base/win32-math.h b/src/base/win32-math.h deleted file mode 100644 index e1c0350..0000000 --- a/src/base/win32-math.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2011 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Extra POSIX/ANSI routines for Win32 when using Visual Studio C++. Please -// refer to The Open Group Base Specification for specification of the correct -// semantics for these functions. -// (http://www.opengroup.org/onlinepubs/000095399/) - -#ifndef V8_BASE_WIN32_MATH_H_ -#define V8_BASE_WIN32_MATH_H_ - -#ifndef _MSC_VER -#error Wrong environment, expected MSVC. -#endif // _MSC_VER - -// MSVC 2013+ provides implementations of all standard math functions. -#if (_MSC_VER < 1800) -enum { - FP_NAN, - FP_INFINITE, - FP_ZERO, - FP_SUBNORMAL, - FP_NORMAL -}; - - -namespace std { - -int isfinite(double x); -int isinf(double x); -int isnan(double x); -int isless(double x, double y); -int isgreater(double x, double y); -int fpclassify(double x); -int signbit(double x); - -} // namespace std - -#endif // _MSC_VER < 1800 - -#endif // V8_BASE_WIN32_MATH_H_ diff --git a/src/preparser.cc b/src/preparser.cc index 847d2c2..65a45b4 100644 --- a/src/preparser.cc +++ b/src/preparser.cc @@ -19,16 +19,6 @@ #include "src/unicode.h" #include "src/utils.h" -#if V8_LIBC_MSVCRT && (_MSC_VER < 1800) -namespace std { - -// Usually defined in math.h, but not in MSVC until VS2013+. -// Abstracted to work -int isfinite(double value); - -} // namespace std -#endif - namespace v8 { namespace internal { diff --git a/src/utils.h b/src/utils.h index 58bcb3a..e2e10fd 100644 --- a/src/utils.h +++ b/src/utils.h @@ -156,7 +156,7 @@ T Abs(T a) { // Floor(-0.0) == 0.0 inline double Floor(double x) { -#ifdef _MSC_VER +#if V8_CC_MSVC if (x == 0) return x; // Fix for issue 3477. #endif return std::floor(x); diff --git a/test/cctest/cctest.cc b/test/cctest/cctest.cc index d6b1308..170aa5a 100644 --- a/test/cctest/cctest.cc +++ b/test/cctest/cctest.cc @@ -34,12 +34,12 @@ #include "test/cctest/profiler-extension.h" #include "test/cctest/trace-extension.h" -#if (defined(_WIN32) || defined(_WIN64)) +#if V8_OS_WIN #include // NOLINT -#if defined(_MSC_VER) +#if V8_CC_MSVC #include -#endif // defined(_MSC_VER) -#endif // defined(_WIN32) || defined(_WIN64) +#endif +#endif enum InitializationState {kUnset, kUnintialized, kInitialized}; static InitializationState initialization_state_ = kUnset; @@ -145,12 +145,12 @@ static void SuggestTestHarness(int tests) { int main(int argc, char* argv[]) { -#if (defined(_WIN32) || defined(_WIN64)) +#if V8_OS_WIN UINT new_flags = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; UINT existing_flags = SetErrorMode(new_flags); SetErrorMode(existing_flags | new_flags); -#if defined(_MSC_VER) +#if V8_CC_MSVC _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); @@ -158,8 +158,8 @@ int main(int argc, char* argv[]) { _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); _set_error_mode(_OUT_TO_STDERR); -#endif // _MSC_VER -#endif // defined(_WIN32) || defined(_WIN64) +#endif // V8_CC_MSVC +#endif // V8_OS_WIN v8::V8::InitializeICU(); v8::Platform* platform = v8::platform::CreateDefaultPlatform(); diff --git a/test/cctest/test-log-stack-tracer.cc b/test/cctest/test-log-stack-tracer.cc index 334a201..714ad69 100644 --- a/test/cctest/test-log-stack-tracer.cc +++ b/test/cctest/test-log-stack-tracer.cc @@ -235,9 +235,9 @@ TEST(PureJSStackTrace) { static void CFuncDoTrace(byte dummy_parameter) { Address fp; -#ifdef __GNUC__ +#if V8_HAS_BUILTIN_FRAME_ADDRESS fp = reinterpret_cast
(__builtin_frame_address(0)); -#elif defined _MSC_VER +#elif V8_CC_MSVC // Approximate a frame pointer address. We compile without base pointers, // so we can't trust ebp/rbp. fp = &dummy_parameter - 2 * sizeof(void*); // NOLINT diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc index 5dd1170..e73e426 100644 --- a/test/cctest/test-serialize.cc +++ b/test/cctest/test-serialize.cc @@ -245,7 +245,7 @@ static void ReserveSpaceForSnapshot(Deserializer* deserializer, name.Dispose(); int new_size, pointer_size, data_size, code_size, map_size, cell_size, property_cell_size, lo_size; -#ifdef _MSC_VER +#if V8_CC_MSVC // Avoid warning about unsafe fscanf from MSVC. // Please note that this is only fine if %c and %s are not being used. #define fscanf fscanf_s @@ -258,7 +258,7 @@ static void ReserveSpaceForSnapshot(Deserializer* deserializer, CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size)); CHECK_EQ(1, fscanf(fp, "property cell %d\n", &property_cell_size)); CHECK_EQ(1, fscanf(fp, "lo %d\n", &lo_size)); -#ifdef _MSC_VER +#if V8_CC_MSVC #undef fscanf #endif fclose(fp); diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 028b5d5..b8317cb 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -1442,8 +1442,6 @@ 'sources': [ '../../src/base/platform/platform-win32.cc', '../../src/base/win32-headers.h', - '../../src/base/win32-math.cc', - '../../src/base/win32-math.h' ], }], ], @@ -1454,8 +1452,6 @@ 'sources': [ '../../src/base/platform/platform-win32.cc', '../../src/base/win32-headers.h', - '../../src/base/win32-math.cc', - '../../src/base/win32-math.h' ], 'msvs_disabled_warnings': [4351, 4355, 4800], 'link_settings': { -- 2.7.4