Commit e3901e91 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Revert new OS and CC detection and related changes since r15923.

Revert "Attempt to fix leftover test breakage on Mac."
Revert "Fix d8 build error when V8_SHARED is unset on Linux."
Revert "Fix V8_GNUC_PREREQ macro."
Revert "Fix typo."
Revert "Implement correct OS and CC detection."

TBR=svenpanne@chromium.org,danno@chromium.org

Review URL: https://codereview.chromium.org/21022003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15932 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 83727682
......@@ -28,8 +28,6 @@
#ifndef V8_COMPILER_INTRINSICS_H_
#define V8_COMPILER_INTRINSICS_H_
#include "globals.h"
namespace v8 {
namespace internal {
......@@ -47,8 +45,7 @@ class CompilerIntrinsics {
INLINE(static int CountSetBits(uint32_t value));
};
#if V8_CC_GNU
#ifdef __GNUC__
int CompilerIntrinsics::CountTrailingZeros(uint32_t value) {
return __builtin_ctz(value);
}
......@@ -61,7 +58,7 @@ int CompilerIntrinsics::CountSetBits(uint32_t value) {
return __builtin_popcount(value);
}
#elif V8_CC_MSVC
#elif defined(_MSC_VER)
#pragma intrinsic(_BitScanForward)
#pragma intrinsic(_BitScanReverse)
......
......@@ -366,10 +366,12 @@ static Handle<Value> GetStdout(int child_fd,
// We're disabling usage of waitid in Mac OS X because it doens't work for us:
// a parent process hangs on waiting while a child process is already a zombie.
// See http://code.google.com/p/v8/issues/detail?id=401.
#if defined(WNOWAIT) && !V8_OS_ANDROID && !V8_OS_DARWN && \
!V8_OS_NETBSD && !V8_OS_FREEBSD
#if defined(WNOWAIT) && !defined(ANDROID) && !defined(__APPLE__) \
&& !defined(__NetBSD__)
#if !defined(__FreeBSD__)
#define HAS_WAITID 1
#endif
#endif
// Get exit status of child.
......
......@@ -42,7 +42,7 @@
namespace v8 {
namespace internal {
#if V8_OS_DARWIN
#ifdef __APPLE__
#define __MACH_O
class MachO;
class MachOSection;
......
......@@ -28,120 +28,46 @@
#ifndef V8_GLOBALS_H_
#define V8_GLOBALS_H_
// ----------------------------------------------------------------------------
// Operating system detection (V8_OS_x)
//
// ANDROID - Android
// BSD4 - Any BSD 4.4 system
// CYGWIN - Cygwin
// DARWIN - Darwin / Mac OS X
// FREEBSD - FreeBSD
// LINUX - Linux
// NACL - Native Client
// NETBSD - NetBSD
// OPENBSD - OpenBSD
// SOLARIS - Solaris
// UNIX - Any UNIX BSD/SYSV system
// WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
#if defined(ANDROID) || defined(__ANDROID__)
# define V8_OS_ANDROID 1
# define V8_OS_LINUX 1
# define V8_OS_UNIX 1
#elif defined(__APPLE__) && defined(__MACH__)
# define V8_OS_DARWIN 1
# define V8_OS_BSD4 1
# define V8_OS_UNIX 1
#elif defined(__CYGWIN__)
# define V8_OS_CYGWIN 1
# define V8_OS_UNIX 1
#elif defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
# define V8_OS_WIN32 1
# define V8_OS_WIN64 1
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || \
(defined(__MWERKS__) && defined(__INTEL__))
# define V8_OS_WIN32 1
#elif defined(__sun) || defined(sun)
# define V8_OS_SOLARIS 1
# define V8_OS_UNIX 1
#elif defined(__native_client__)
# define V8_OS_NACL 1
#elif defined(__linux__) || defined(__linux)
# define V8_OS_LINUX 1
# define V8_OS_UNIX 1
#elif defined(__FreeBSD__) || defined(__DragonFly__)
# define V8_OS_FREEBSD 1
# define V8_OS_BSD4 1
# define V8_OS_UNIX 1
#elif defined(__NetBSD__)
# define V8_OS_NETBSD 1
# define V8_OS_BSD4 1
# define V8_OS_UNIX 1
#elif defined(__OpenBSD__)
# define V8_OS_OPENBSD 1
# define V8_OS_BSD4 1
# define V8_OS_UNIX 1
#else
# error Operating system was not detected as supported by v8
#endif
// Define V8_INFINITY
#define V8_INFINITY INFINITY
// GCC specific stuff
#ifdef __GNUC__
// ----------------------------------------------------------------------------
// Compiler detection (V8_CC_x)
//
// CLANG - C++ front-end for the LLVM compiler
// GNU - GNU C++ or compatible
// INTEL - Intel C++ for Linux or Windows
// MINGW - Minimalistic GNU for Windows Compiler
// MIPS - MIPSpro C++
// MSVC - Microsoft Visual C/C++ or compatible
// RVCT - ARM Realview Compiler Suite
#define __GNUC_VERSION_FOR_INFTY__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
#if defined(_MSC_VER)
# define V8_CC_MSVC 1
# if defined(__INTEL_COMPILER)
# define V8_CC_INTEL 1
# endif
#elif defined(__GNUC__)
# define V8_CC_GNU 1
# define V8_GNUC_PREREQ(major, minor) \
(__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
# if defined(__MINGW64__)
# define V8_CC_MINGW 1
# define V8_CC_MINGW64 1
# elif defined(__MINGW32__)
# define V8_CC_MINGW 1
# define V8_CC_MINGW32 1
# elif defined(__ARMCC__) || defined(__CC_ARM)
# define V8_CC_RVCT 1 // ARM Realview Compiler Suite also masquerades as GCC
# elif defined(__INTEL_COMPILER)
# define V8_CC_INTEL 1 // Intel C++ also masquerades as GCC 3.2.0
# elif defined(__clang__)
# define V8_CC_CLANG 1 // Clang also masquerades as GCC 4.2.1
# endif
#elif defined(__ARMCC__) || defined(__CC_ARM)
# define V8_CC_RVCT 1
#elif defined(__INTEL_COMPILER)
# define V8_CC_INTEL 1
#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C)
# define V8_CC_SUN 1
#else
# error Compiler was not detected as supported by v8
// Unfortunately, the INFINITY macro cannot be used with the '-pedantic'
// warning flag and certain versions of GCC due to a bug:
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931
// For now, we use the more involved template-based version from <limits>, but
// only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x)
// __GNUC_PREREQ is not defined in GCC for Mac OS X, so we define our own macro
#if __GNUC_VERSION_FOR_INFTY__ >= 29600 && __GNUC_VERSION_FOR_INFTY__ < 40100
#include <limits>
#undef V8_INFINITY
#define V8_INFINITY std::numeric_limits<double>::infinity()
#endif
#undef __GNUC_VERSION_FOR_INFTY__
#ifndef V8_GNUC_PREREQ
#define V8_GNUC_PREREQ(major, minor) 0
#endif // __GNUC__
#ifdef _MSC_VER
#undef V8_INFINITY
#define V8_INFINITY HUGE_VAL
#endif
// ----------------------------------------------------------------------------
#include "../include/v8stdint.h"
namespace v8 {
namespace internal {
// Processor architecture detection. For more info on what's defined, see:
// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
// http://www.agner.org/optimize/calling_conventions.pdf
// or with gcc, run: "echo | gcc -E -dM -"
#if defined(_M_X64) || defined(__x86_64__)
#if V8_OS_NACL
#if defined(__native_client__)
// For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8
// generates ARM machine code, together with a portable ARM simulator
// compiled for the host architecture in question.
......@@ -155,7 +81,7 @@
#define V8_HOST_ARCH_X64 1
#define V8_HOST_ARCH_64_BIT 1
#define V8_HOST_CAN_READ_UNALIGNED 1
#endif // V8_OS_NACL
#endif // __native_client__
#elif defined(_M_IX86) || defined(__i386__)
#define V8_HOST_ARCH_IA32 1
#define V8_HOST_ARCH_32_BIT 1
......@@ -175,7 +101,7 @@
defined(__ARM_ARCH_7__)
# define CAN_USE_ARMV7_INSTRUCTIONS 1
# ifndef CAN_USE_VFP3_INSTRUCTIONS
# define CAN_USE_VFP3_INSTRUCTIONS 1
# define CAN_USE_VFP3_INSTRUCTIONS
# endif
#endif
......@@ -185,13 +111,13 @@
// environment as presented by the compiler.
#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && \
!V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS
#if V8_HOST_ARCH_X64
#if defined(_M_X64) || defined(__x86_64__)
#define V8_TARGET_ARCH_X64 1
#elif V8_HOST_ARCH_IA32
#elif defined(_M_IX86) || defined(__i386__)
#define V8_TARGET_ARCH_IA32 1
#elif V8_HOST_ARCH_ARM
#elif defined(__ARMEL__)
#define V8_TARGET_ARCH_ARM 1
#elif V8_HOST_ARCH_MIPS
#elif defined(__MIPSEL__)
#define V8_TARGET_ARCH_MIPS 1
#else
#error Target architecture was not detected as supported by v8
......@@ -237,27 +163,6 @@
#error Unknown target architecture endiannes
#endif
// Define V8_INFINITY
#if V8_CC_GNU && V8_GNUC_PREREQ(2, 96) && !V8_GNUC_PREREQ(4, 1)
// Unfortunately, the INFINITY macro cannot be used with the '-pedantic'
// warning flag and certain versions of GCC due to a bug:
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931
// For now, we use the more involved template-based version from <limits>, but
// only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x)
#include <limits>
#define V8_INFINITY std::numeric_limits<double>::infinity()
#elif V8_CC_MSVC
#define V8_INFINITY HUGE_VAL
#else
#define V8_INFINITY INFINITY
#endif
#include "../include/v8stdint.h"
namespace v8 {
namespace internal {
// Support for alternative bool type. This is only enabled if the code is
// compiled with USE_MYBOOL defined. This catches some nasty type bugs.
// For instance, 'bool b = "false";' results in b == true! This is a hidden
......@@ -282,12 +187,12 @@ typedef byte* Address;
// than defining __STDC_CONSTANT_MACROS before including <stdint.h>, and it
// works on compilers that don't have it (like MSVC).
#if V8_HOST_ARCH_64_BIT
#if V8_CC_MSVC
#if defined(_MSC_VER)
#define V8_UINT64_C(x) (x ## UI64)
#define V8_INT64_C(x) (x ## I64)
#define V8_INTPTR_C(x) (x ## I64)
#define V8_PTR_PREFIX "ll"
#elif V8_CC_MINGW64
#elif defined(__MINGW64__)
#define V8_UINT64_C(x) (x ## ULL)
#define V8_INT64_C(x) (x ## LL)
#define V8_INTPTR_C(x) (x ## LL)
......@@ -313,11 +218,16 @@ typedef byte* Address;
#define V8PRIuPTR V8_PTR_PREFIX "u"
// Fix for Mac OS X defining uintptr_t as "unsigned long":
#if V8_OS_DARWIN
#if defined(__APPLE__) && defined(__MACH__)
#undef V8PRIxPTR
#define V8PRIxPTR "lx"
#endif
#if (defined(__APPLE__) && defined(__MACH__)) || \
defined(__FreeBSD__) || defined(__OpenBSD__)
#define USING_BSD_ABI
#endif
// -----------------------------------------------------------------------------
// Constants
......@@ -448,15 +358,15 @@ F FUNCTION_CAST(Address addr) {
// Define used for helping GCC to make better inlining. Don't bother for debug
// builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation
// errors in debug build.
#if V8_CC_GNU && !defined(DEBUG)
#if V8_GNUC_PREREQ(4, 0)
#if defined(__GNUC__) && !defined(DEBUG)
#if (__GNUC__ >= 4)
#define INLINE(header) inline header __attribute__((always_inline))
#define NO_INLINE(header) header __attribute__((noinline))
#else
#define INLINE(header) inline __attribute__((always_inline)) header
#define NO_INLINE(header) __attribute__((noinline)) header
#endif
#elif V8_CC_MSVC && !defined(DEBUG)
#elif defined(_MSC_VER) && !defined(DEBUG)
#define INLINE(header) __forceinline header
#define NO_INLINE(header) header
#else
......@@ -465,7 +375,7 @@ F FUNCTION_CAST(Address addr) {
#endif
#if V8_GNUC_PREREQ(4, 0)
#if defined(__GNUC__) && __GNUC__ >= 4
#define MUST_USE_RESULT __attribute__ ((warn_unused_result))
#else
#define MUST_USE_RESULT
......
......@@ -1933,7 +1933,7 @@ void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid,
// If false, it is returned as a pointer to a preallocated by caller memory
// region. Pointer to this region should be passed to a function as an
// implicit first argument.
#if V8_OS_BSD4 || V8_OS_CYGWIN || V8_CC_MINGW32
#if defined(USING_BSD_ABI) || defined(__MINGW32__) || defined(__CYGWIN__)
static const bool kReturnHandlesDirectly = true;
#else
static const bool kReturnHandlesDirectly = false;
......
......@@ -39,7 +39,7 @@ namespace internal {
SaveContext::SaveContext(Isolate* isolate) : prev_(isolate->save_context()) {
if (isolate->context() != NULL) {
context_ = Handle<Context>(isolate->context());
#if V8_GNUC_PREREQ(4, 1) && !V8_GNUC_PREREQ(4, 3)
#if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300
dummy_ = Handle<Context>(isolate->context());
#endif
}
......
......@@ -1414,7 +1414,7 @@ class SaveContext BASE_EMBEDDED {
private:
Handle<Context> context_;
#if V8_GNUC_PREREQ(4, 1) && !V8_GNUC_PREREQ(4, 3)
#if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300
Handle<Context> dummy_;
#endif
SaveContext* prev_;
......
......@@ -111,9 +111,9 @@ struct LeakyInstanceTrait {
// Traits that define how an instance is allocated and accessed.
// TODO(kalmard): __alignof__ is only defined for GCC >= 4.3.
// Fix alignment issue on MIPS with other compilers.
#if V8_GNUC_PREREQ(4, 3)
// TODO(kalmard): __alignof__ is only defined for GCC > 4.2. Fix alignment issue
// on MIPS with other compilers.
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
#define LAZY_ALIGN(x) __attribute__((aligned(__alignof__(x))))
#else
#define LAZY_ALIGN(x)
......
......@@ -39,13 +39,13 @@ namespace internal {
// Result is undefined if input is zero.
int IntegerLog2(uint32_t value);
#if V8_CC_GNU
#if defined(__GNUC__)
inline int IntegerLog2(uint32_t value) {
return 31 - __builtin_clz(value);
}
#elif V8_CC_MSVC
#elif defined(_MSC_VER)
#pragma intrinsic(_BitScanReverse)
......
......@@ -28,8 +28,6 @@
// Platform specific code for Linux goes here. For the POSIX comaptible parts
// the implementation is in platform-posix.cc.
#include "platform.h"
#include <pthread.h>
#include <semaphore.h>
#include <signal.h>
......@@ -59,8 +57,8 @@
// GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
// Old versions of the C library <signal.h> didn't define the type.
#if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
V8_HOST_ARCH_ARM && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
#if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
#include <asm/sigcontext.h>
#endif
......@@ -69,6 +67,7 @@
#include "v8.h"
#include "platform-posix.h"
#include "platform.h"
#include "v8threads.h"
#include "vm-state-inl.h"
......@@ -80,7 +79,7 @@ namespace internal {
static Mutex* limit_mutex = NULL;
#if V8_HOST_ARCH_ARM
#ifdef __arm__
static bool CPUInfoContainsString(const char * search_string) {
const char* file_name = "/proc/cpuinfo";
// This is written as a straight shot one pass parser
......@@ -223,23 +222,39 @@ bool OS::ArmUsingHardFloat() {
// GCC versions 4.4 and below don't support hard-fp.
// GCC versions 4.5 may support hard-fp without defining __ARM_PCS or
// __ARM_PCS_VFP.
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#if GCC_VERSION >= 40600
#if defined(__ARM_PCS_VFP)
return true;
#elif V8_CC_GNU && (V8_GNUC_PREREQ(4, 6) || !V8_GNUC_PREREQ(4, 5))
#else
return false;
#endif
#elif GCC_VERSION < 40500
return false;
#else
#if defined(__ARM_PCS_VFP)
return true;
#elif defined(__ARM_PCS) || defined(__SOFTFP) || !defined(__VFP_FP__)
return false;
#else
#error "Your version of GCC does not report the FP ABI compiled for." \
"Please report it on this issue" \
"http://code.google.com/p/v8/issues/detail?id=2140"
#endif
#endif
#undef GCC_VERSION
}
#endif // V8_HOST_ARCH_ARM
#endif // def __arm__
#if V8_HOST_ARCH_MIPS
#ifdef __mips__
bool OS::MipsCpuHasFeature(CpuFeature feature) {
const char* search_string = NULL;
const char* file_name = "/proc/cpuinfo";
......@@ -290,7 +305,7 @@ bool OS::MipsCpuHasFeature(CpuFeature feature) {
// Did not find string in the proc file.
return false;
}
#endif // V8_HOST_ARCH_MIPS
#endif // def __mips__
const char* OS::LocalTimezone(double time) {
......
......@@ -33,7 +33,7 @@
#include <dlfcn.h>
#include <pthread.h>
#if V8_OS_FREEBSD || V8_OS_OPENBSD
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <pthread_np.h> // for pthread_set_name_np
#endif
#include <sched.h> // for sched_yield
......@@ -47,9 +47,11 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#if V8_OS_LINUX
#if defined(__linux__)
#include <sys/prctl.h> // for prctl
#elif V8_OS_BSD4
#endif
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || \
defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/sysctl.h> // for sysctl
#endif
......@@ -59,7 +61,7 @@
#undef MAP_TYPE
#if V8_OS_ANDROID && !defined(V8_ANDROID_LOG_STDOUT)
#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
#define LOG_TAG "v8"
#include <android/log.h>
#endif
......@@ -77,7 +79,7 @@ static const pthread_t kNoThread = (pthread_t) 0;
uint64_t OS::CpuFeaturesImpliedByPlatform() {
#if V8_OS_DARWIN
#if defined(__APPLE__)
// Mac OS X requires all these to install so we can assume they are present.
// These constants are defined by the CPUid instructions.
const uint64_t one = 1;
......@@ -133,10 +135,10 @@ void OS::Free(void* address, const size_t size) {
// Get rid of writable permission on code allocations.
void OS::ProtectCode(void* address, const size_t size) {
#if V8_OS_CYGWIN
#if defined(__CYGWIN__)
DWORD old_protect;
VirtualProtect(address, size, PAGE_EXECUTE_READ, &old_protect);
#elif V8_OS_NACL
#elif defined(__native_client__)
// The Native Client port of V8 uses an interpreter, so
// code pages don't need PROT_EXEC.
mprotect(address, size, PROT_READ);
......@@ -148,7 +150,7 @@ void OS::ProtectCode(void* address, const size_t size) {
// Create guard pages.
void OS::Guard(void* address, const size_t size) {
#if V8_OS_CYGWIN
#if defined(__CYGWIN__)
DWORD oldprotect;
VirtualProtect(address, size, PAGE_READONLY | PAGE_GUARD, &oldprotect);
#else
......@@ -158,7 +160,7 @@ void OS::Guard(void* address, const size_t size) {
void* OS::GetRandomMmapAddr() {
#if V8_OS_NACL
#if defined(__native_client__)
// TODO(bradchen): restore randomization once Native Client gets
// smarter about using mmap address hints.
// See http://code.google.com/p/nativeclient/issues/3341
......@@ -169,7 +171,7 @@ void* OS::GetRandomMmapAddr() {
// CpuFeatures::Probe. We don't care about randomization in this case because
// the code page is immediately freed.
if (isolate != NULL) {
#if V8_HOST_ARCH_64_BIT
#if V8_TARGET_ARCH_X64
uint64_t rnd1 = V8::RandomPrivate(isolate);
uint64_t rnd2 = V8::RandomPrivate(isolate);
uint64_t raw_addr = (rnd1 << 32) ^ rnd2;
......@@ -182,7 +184,7 @@ void* OS::GetRandomMmapAddr() {
raw_addr &= 0x3ffff000;
#if V8_OS_SOLARIS
# ifdef __sun
// For our Solaris/illumos mmap hint, we pick a random address in the bottom
// half of the top half of the address space (that is, the third quarter).
// Because we do not MAP_FIXED, this will be treated only as a hint -- the
......@@ -193,13 +195,13 @@ void* OS::GetRandomMmapAddr() {
// no hint at all. The high hint prevents the break from getting hemmed in
// at low values, ceding half of the address space to the system heap.
raw_addr += 0x80000000;
#else
# else
// The range 0x20000000 - 0x60000000 is relatively unpopulated across a
// variety of ASLR modes (PAE kernel, NX compat mode, etc) and on macos
// 10.6 and 10.7.
raw_addr += 0x20000000;
#endif // V8_OS_SOLARIS
#endif // V8_HOST_ARCH_64_BIT
# endif
#endif
return reinterpret_cast<void*>(raw_addr);
}
return NULL;
......@@ -237,11 +239,11 @@ void OS::DebugBreak() {
#elif V8_HOST_ARCH_MIPS
asm("break");
#elif V8_HOST_ARCH_IA32
#if V8_OS_NACL
#if defined(__native_client__)
asm("hlt");
#else
asm("int $3");
#endif // V8_OS_NACL
#endif // __native_client__
#elif V8_HOST_ARCH_X64
asm("int $3");
#else
......@@ -384,7 +386,7 @@ void OS::Print(const char* format, ...) {
void OS::VPrint(const char* format, va_list args) {
#if V8_OS_ANDROID && !defined(V8_ANDROID_LOG_STDOUT)
#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
__android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args);
#else
vprintf(format, args);
......@@ -401,7 +403,7 @@ void OS::FPrint(FILE* out, const char* format, ...) {
void OS::VFPrint(FILE* out, const char* format, va_list args) {
#if V8_OS_ANDROID && !defined(V8_ANDROID_LOG_STDOUT)
#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
__android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args);
#else
vfprintf(out, format, args);
......@@ -418,7 +420,7 @@ void OS::PrintError(const char* format, ...) {
void OS::VPrintError(const char* format, va_list args) {
#if V8_OS_ANDROID && !defined(V8_ANDROID_LOG_STDOUT)
#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
__android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, args);
#else
vfprintf(stderr, format, args);
......@@ -470,7 +472,7 @@ void OS::MemMove(void* dest, const void* src, size_t size) {
(*memmove_function)(dest, src, size);
}
#elif V8_HOST_ARCH_ARM
#elif defined(V8_HOST_ARCH_ARM)
void OS::MemCopyUint16Uint8Wrapper(uint16_t* dest,
const uint8_t* src,
size_t chars) {
......@@ -498,7 +500,7 @@ void OS::PostSetUp() {
if (generated_memmove != NULL) {
memmove_function = generated_memmove;
}
#elif V8_HOST_ARCH_ARM
#elif defined(V8_HOST_ARCH_ARM)
OS::memcopy_uint8_function =
CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper);
OS::memcopy_uint16_uint8_function =
......@@ -551,12 +553,12 @@ Thread::~Thread() {
static void SetThreadName(const char* name) {
#if V8_OS_FREEBSD || V8_OS_OPENBSD
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
pthread_set_name_np(pthread_self(), name);
#elif V8_OS_NETBSD
#elif defined(__NetBSD__)
STATIC_ASSERT(Thread::kMaxThreadNameLength <= PTHREAD_MAX_NAMELEN_NP);
pthread_setname_np(pthread_self(), "%s", name);
#elif V8_OS_DARWIN
#elif defined(__APPLE__)
// pthread_setname_np is only available in 10.6 or later, so test
// for it at runtime.
int (*dynamic_pthread_setname_np)(const char*);
......@@ -603,7 +605,7 @@ void Thread::Start() {
result = pthread_attr_init(&attr);
ASSERT_EQ(0, result);
// Native client uses default stack size.
#if !V8_OS_NACL
#if !defined(__native_client__)
if (stack_size_ > 0) {
result = pthread_attr_setstacksize(&attr, static_cast<size_t>(stack_size_));
ASSERT_EQ(0, result);
......@@ -631,7 +633,7 @@ void Thread::YieldCPU() {
static Thread::LocalStorageKey PthreadKeyToLocalKey(pthread_key_t pthread_key) {
#if V8_OS_CYGWIN
#if defined(__CYGWIN__)
// We need to cast pthread_key_t to Thread::LocalStorageKey in two steps
// because pthread_key_t is a pointer type on Cygwin. This will probably not
// work on 64-bit platforms, but Cygwin doesn't support 64-bit anyway.
......@@ -645,7 +647,7 @@ static Thread::LocalStorageKey PthreadKeyToLocalKey(pthread_key_t pthread_key) {
static pthread_key_t LocalKeyToPthreadKey(Thread::LocalStorageKey local_key) {
#if V8_OS_CYGWIN
#if defined(__CYGWIN__)
STATIC_ASSERT(sizeof(Thread::LocalStorageKey) == sizeof(pthread_key_t));
intptr_t ptr_key = static_cast<intptr_t>(local_key);
return reinterpret_cast<pthread_key_t>(ptr_key);
......
......@@ -28,13 +28,13 @@
#ifndef V8_PLATFORM_POSIX_H_
#define V8_PLATFORM_POSIX_H_
#include "platform.h"
#if !V8_OS_ANDROID
#if !defined(ANDROID)
#include <cxxabi.h>
#endif
#include <stdio.h>
#include "platform.h"
namespace v8 {
namespace internal {
......@@ -58,7 +58,7 @@ struct POSIXBacktraceHelper {
char mangled[201];
if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) {// NOLINT
char* demangled = NULL;
#if !V8_OS_ANDROID
#if !defined(ANDROID)
int status;
size_t length;
demangled = abi::__cxa_demangle(mangled, NULL, &length, &status);
......
......@@ -48,7 +48,7 @@
#include "simulator.h"
#include "vm-state-inl.h"
#if V8_CC_MSVC
#ifdef _MSC_VER
// Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually
// defined in strings.h.
......@@ -56,7 +56,7 @@ int strncasecmp(const char* s1, const char* s2, int n) {
return _strnicmp(s1, s2, n);
}
#endif // V8_CC_MSVC
#endif // _MSC_VER
// Extra functions for MinGW. Most of these are the _s functions which are in
......@@ -169,7 +169,7 @@ void OS::MemMove(void* dest, const void* src, size_t size) {
#endif // V8_TARGET_ARCH_IA32
#if V8_OS_WIN64
#ifdef _WIN64
typedef double (*ModuloFunction)(double, double);
static ModuloFunction modulo_function = NULL;
// Defined in codegen-x64.cc.
......@@ -185,7 +185,8 @@ double modulo(double x, double y) {
// on all architectures we currently support.
return (*modulo_function)(x, y);
}
#else
#else // Win32
double modulo(double x, double y) {
// Workaround MS fmod bugs. ECMA-262 says:
// dividend is finite and divisor is an infinity => result equals dividend
......@@ -196,7 +197,8 @@ double modulo(double x, double y) {
}
return x;
}
#endif // V8_OS_WIN64
#endif // _WIN64
#define UNARY_MATH_FUNCTION(name, generator) \
......@@ -226,7 +228,7 @@ void lazily_initialize_fast_exp() {
void MathSetup() {
#if V8_OS_WIN64
#ifdef _WIN64
init_modulo_function();
#endif
init_fast_sin_function();
......@@ -1007,11 +1009,11 @@ void OS::Abort() {
void OS::DebugBreak() {
#if V8_CC_MSVC
#ifdef _MSC_VER
__debugbreak();
#else
::DebugBreak();
#endif // V8_CC_MSVC
#endif
}
......@@ -1359,7 +1361,7 @@ int OS::StackWalk(Vector<OS::StackFrame> frames) {
// Initialize the stack walking
STACKFRAME64 stack_frame;
memset(&stack_frame, 0, sizeof(stack_frame));
#if V8_OS_WIN64
#ifdef _WIN64
stack_frame.AddrPC.Offset = context.Rip;
stack_frame.AddrFrame.Offset = context.Rbp;
stack_frame.AddrStack.Offset = context.Rsp;
......@@ -1468,21 +1470,21 @@ uint64_t OS::CpuFeaturesImpliedByPlatform() {
double OS::nan_value() {
#if V8_CC_MSVC
#ifdef _MSC_VER
// Positive Quiet NaN with no payload (aka. Indeterminate) has all bits
// in mask set, so value equals mask.
static const __int64 nanval = kQuietNaNMask;
return *reinterpret_cast<const double*>(&nanval);
#else // V8_CC_MSVC
#else // _MSC_VER
return NAN;
#endif // V8_CC_MSVC
#endif // _MSC_VER
}
int OS::ActivationFrameAlignment() {
#if V8_OS__WIN64
#ifdef _WIN64
return 16; // Windows 64-bit ABI requires the stack to be 16-byte aligned.
#elif V8_CC_MINGW
#elif defined(__MINGW32__)
// With gcc 4.4 the tree vectorization optimizer can generate code
// that requires 16 byte alignment such as movdqa on x86.
return 16;
......
......@@ -44,8 +44,6 @@
#ifndef V8_PLATFORM_H_
#define V8_PLATFORM_H_
#include <stdarg.h>
#ifdef __sun
# ifndef signbit
namespace std {
......@@ -54,6 +52,16 @@ int signbit(double x);
# endif
#endif
// GCC specific stuff
#ifdef __GNUC__
// Needed for va_list on at least MinGW and Android.
#include <stdarg.h>
#define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
#endif // __GNUC__
// Windows specific stuff.
#ifdef WIN32
......@@ -124,7 +132,7 @@ class Socket;
#ifndef V8_NO_FAST_TLS
#if V8_CC_MSVC && V8_HOST_ARCH_IA32
#if defined(_MSC_VER) && V8_HOST_ARCH_IA32
#define V8_FAST_TLS_SUPPORTED 1
......@@ -146,7 +154,7 @@ inline intptr_t InternalGetExistingThreadLocal(intptr_t index) {
kPointerSize * (index - kMaxInlineSlots));
}
#elif V8_OS_DARWIN && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64)
#elif defined(__APPLE__) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64)
#define V8_FAST_TLS_SUPPORTED 1
......@@ -377,7 +385,7 @@ class OS {
// the platform doesn't care. Guaranteed to be a power of two.
static int ActivationFrameAlignment();
#if V8_TARGET_ARCH_IA32
#if defined(V8_TARGET_ARCH_IA32)
// Limit below which the extra overhead of the MemCopy function is likely
// to outweigh the benefits of faster copying.
static const int kMinComplexMemCopy = 64;
......@@ -391,7 +399,7 @@ class OS {
static void MemCopy(void* dest, const void* src, size_t size) {
MemMove(dest, src, size);
}
#elif V8_HOST_ARCH_ARM
#elif defined(V8_HOST_ARCH_ARM)
typedef void (*MemCopyUint8Function)(uint8_t* dest,
const uint8_t* src,
size_t size);
......
......@@ -42,7 +42,7 @@
#include "unicode.h"
#include "utils.h"
#if V8_CC_MSVC
#ifdef _MSC_VER
namespace std {
// Usually defined in math.h, but not in MSVC.
......
......@@ -27,11 +27,9 @@
#include "sampler.h"
#if V8_OS_DARWIN
#include <mach/mach.h>
#elif V8_OS_UNIX && !V8_OS_CYGWIN
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) \
|| defined(__NetBSD__) || defined(__sun) || defined(__ANDROID__) \
|| defined(__native_client__)
#define USE_SIGNALS
......@@ -40,19 +38,23 @@
#include <signal.h>
#include <sys/time.h>
#include <sys/syscall.h>
#if !V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)
#if !defined(__ANDROID__) || defined(__BIONIC_HAVE_UCONTEXT_T)
#include <ucontext.h>
#endif
#include <unistd.h>
// GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
// Old versions of the C library <signal.h> didn't define the type.
#if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
V8_HOST_ARCH_ARM && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
#if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
#include <asm/sigcontext.h>
#endif
#elif V8_OS_CYGWIN || V8_OS_WIN32
#elif defined(__MACH__)
#include <mach/mach.h>
#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
#include "win32-headers.h"
......@@ -70,7 +72,7 @@
#include "vm-state-inl.h"
#if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T)
#if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T)
// Not all versions of Android's C library provide ucontext_t.
// Detect this and provide custom but compatible definitions. Note that these
......@@ -79,7 +81,7 @@
//
// See http://code.google.com/p/android/issues/detail?id=34784
#if V8_HOST_ARCH_ARM
#if defined(__arm__)
typedef struct sigcontext mcontext_t;
......@@ -91,7 +93,7 @@ typedef struct ucontext {
// Other fields are not used by V8, don't define them here.
} ucontext_t;
#elif V8_HOST_ARCH_MIPS
#elif defined(__mips__)
// MIPS version of sigcontext, for Android bionic.
typedef struct {
uint32_t regmask;
......@@ -122,7 +124,7 @@ typedef struct ucontext {
// Other fields are not used by V8, don't define them here.
} ucontext_t;
#elif V8_HOST_ARCH_IA32
#elif defined(__i386__)
// x86 version for Android.
typedef struct {
uint32_t gregs[19];
......@@ -142,7 +144,7 @@ typedef struct ucontext {
enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 };
#endif
#endif // V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T)
#endif // __ANDROID__ && !defined(__BIONIC_HAVE_UCONTEXT_T)
namespace v8 {
......@@ -175,7 +177,7 @@ class Sampler::PlatformData : public PlatformDataCommon {
pthread_t vm_tid_;
};
#elif V8_OS_DARWIN
#elif defined(__MACH__)
class Sampler::PlatformData : public PlatformDataCommon {
public:
......@@ -195,7 +197,7 @@ class Sampler::PlatformData : public PlatformDataCommon {
thread_act_t profiled_thread_;
};
#elif V8_OS_CYGWIN || V8_OS_WIN32
#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
// ----------------------------------------------------------------------------
// Win32 profiler support. On Cygwin we use the same sampler implementation as
......@@ -299,7 +301,7 @@ bool SignalHandler::signal_handler_installed_ = false;
void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
void* context) {
#if V8_OS_NACL
#if defined(__native_client__)
// As Native Client does not support signal handling, profiling
// is disabled.
return;
......@@ -329,7 +331,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
// Extracting the sample from the context is extremely machine dependent.
ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
mcontext_t& mcontext = ucontext->uc_mcontext;
#if V8_OS_LINUX
#if defined(__linux__) || defined(__ANDROID__)
#if V8_HOST_ARCH_IA32
state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]);
state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]);
......@@ -357,7 +359,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
state.sp = reinterpret_cast<Address>(mcontext.gregs[29]);
state.fp = reinterpret_cast<Address>(mcontext.gregs[30]);
#endif // V8_HOST_ARCH_*
#elif V8_OS_FREEBSD
#elif defined(__FreeBSD__)
#if V8_HOST_ARCH_IA32
state.pc = reinterpret_cast<Address>(mcontext.mc_eip);
state.sp = reinterpret_cast<Address>(mcontext.mc_esp);
......@@ -371,7 +373,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
state.sp = reinterpret_cast<Address>(mcontext.mc_r13);
state.fp = reinterpret_cast<Address>(mcontext.mc_r11);
#endif // V8_HOST_ARCH_*
#elif V8_OS_NETBSD
#elif defined(__NetBSD__)
#if V8_HOST_ARCH_IA32
state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]);
state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]);
......@@ -381,7 +383,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]);
state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]);
#endif // V8_HOST_ARCH_*
#elif V8_OS_OPENBSD
#elif defined(__OpenBSD__)
USE(mcontext);
#if V8_HOST_ARCH_IA32
state.pc = reinterpret_cast<Address>(ucontext->sc_eip);
......@@ -392,11 +394,11 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
state.sp = reinterpret_cast<Address>(ucontext->sc_rsp);
state.fp = reinterpret_cast<Address>(ucontext->sc_rbp);
#endif // V8_HOST_ARCH_*
#elif V8_OS_SOLARIS
#elif defined(__sun)
state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]);
state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]);
state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]);
#endif // V8_OS_SOLARIS
#endif // __sun
#endif // USE_SIMULATOR
sampler->SampleStack(state);
#endif // __native_client__
......@@ -491,7 +493,7 @@ class SamplerThread : public Thread {
pthread_kill(tid, SIGPROF);
}
#elif V8_OS_DARWIN
#elif defined(__MACH__)
void SampleContext(Sampler* sampler) {
thread_act_t profiled_thread = sampler->platform_data()->profiled_thread();
......@@ -544,7 +546,7 @@ class SamplerThread : public Thread {
thread_resume(profiled_thread);
}
#elif V8_OS_CYGWIN || V8_OS_WIN32
#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
void SampleContext(Sampler* sampler) {
HANDLE profiled_thread = sampler->platform_data()->profiled_thread();
......
......@@ -47,7 +47,7 @@ static void ReserveSpaceForSnapshot(Deserializer* deserializer,
CHECK_NE(NULL, fp);
int new_size, pointer_size, data_size, code_size, map_size, cell_size,
property_cell_size;
#if V8_CC_MSVC
#ifdef _MSC_VER
// 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
......@@ -59,7 +59,7 @@ static void ReserveSpaceForSnapshot(Deserializer* deserializer,
CHECK_EQ(1, fscanf(fp, "map %d\n", &map_size));
CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size));
CHECK_EQ(1, fscanf(fp, "property cell %d\n", &property_cell_size));
#if V8_CC_MSVC
#ifdef _MSC_VER
#undef fscanf
#endif
fclose(fp);
......
......@@ -176,7 +176,7 @@ static void ReadDiyFp(Vector<const char> buffer,
static bool DoubleStrtod(Vector<const char> trimmed,
int exponent,
double* result) {
#if (V8_TARGET_ARCH_IA32 || defined(USE_SIMULATOR)) && !V8_CC_MSVC
#if (V8_TARGET_ARCH_IA32 || defined(USE_SIMULATOR)) && !defined(_MSC_VER)
// On x86 the floating-point stack can be 64 or 80 bits wide. If it is
// 80 bits wide (as is the case on Linux) then double-rounding occurs and the
// result is not accurate.
......
......@@ -37,11 +37,11 @@ namespace internal {
// ----------------------------------------------------------------------------
// I/O support.
#if V8_GNUC_PREREQ(4, 0)
#if __GNUC__ >= 4
// On gcc we can ask the compiler to check the types of %d-style format
// specifiers and their associated arguments. TODO(erikcorry) fix this
// so it works on MacOSX.
#if V8_OS_DARWIN
#if defined(__MACH__) && defined(__APPLE__)
#define PRINTF_CHECKING
#define FPRINTF_CHECKING
#else // MacOsX.
......@@ -262,7 +262,7 @@ inline void MemsetPointer(T** dest, U* value, int counter) {
#elif V8_HOST_ARCH_X64
#define STOS "stosq"
#endif
#if V8_OS_NACL
#if defined(__native_client__)
// This STOS sequence does not validate for x86_64 Native Client.
// Here we #undef STOS to force use of the slower C version.
// TODO(bradchen): Profile V8 and implement a faster REP STOS
......@@ -270,7 +270,7 @@ inline void MemsetPointer(T** dest, U* value, int counter) {
#undef STOS
#endif
#if V8_CC_GNU && defined(STOS)
#if defined(__GNUC__) && defined(STOS)
asm volatile(
"cld;"
"rep ; " STOS
......@@ -317,7 +317,7 @@ template <typename sourcechar, typename sinkchar>
INLINE(static void CopyCharsUnsigned(sinkchar* dest,
const sourcechar* src,
int chars));
#if V8_HOST_ARCH_ARM
#if defined(V8_HOST_ARCH_ARM)
INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars));
INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint8_t* src, int chars));
INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, int chars));
......@@ -380,7 +380,7 @@ void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, int chars) {
}
#if V8_HOST_ARCH_ARM
#if defined(V8_HOST_ARCH_ARM)
void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars) {
switch (static_cast<unsigned>(chars)) {
case 0:
......
......@@ -473,7 +473,7 @@ TEST(AssemblerMultiByteNop) {
}
#if V8_CC_GNU
#ifdef __GNUC__
#define ELEMENT_COUNT 4
void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) {
......@@ -561,7 +561,7 @@ TEST(StackAlignmentForSSE2) {
}
#undef ELEMENT_COUNT
#endif // V8_CC_GNU
#endif // __GNUC__
#undef __
......@@ -436,7 +436,7 @@ TEST(AssemblerMultiByteNop) {
}
#if V8_CC_GNU
#ifdef __GNUC__
#define ELEMENT_COUNT 4
void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) {
......@@ -521,7 +521,7 @@ TEST(StackAlignmentForSSE2) {
}
#undef ELEMENT_COUNT
#endif // V8_CC_GNU
#endif // __GNUC__
#undef __
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment