1// Copyright 2014 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef V8_BASE_BUILD_CONFIG_H_ 6#define V8_BASE_BUILD_CONFIG_H_ 7 8#include "include/v8config.h" 9 10// Processor architecture detection. For more info on what's defined, see: 11// http://msdn.microsoft.com/en-us/library/b0084kay.aspx 12// http://www.agner.org/optimize/calling_conventions.pdf 13// or with gcc, run: "echo | gcc -E -dM -" 14#if defined(_M_X64) || defined(__x86_64__) 15#if defined(__native_client__) 16// For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8 17// generates ARM machine code, together with a portable ARM simulator 18// compiled for the host architecture in question. 19// 20// Since Native Client is ILP-32 on all architectures we use 21// V8_HOST_ARCH_IA32 on both 32- and 64-bit x86. 22#define V8_HOST_ARCH_IA32 1 23#define V8_HOST_ARCH_32_BIT 1 24#else 25#define V8_HOST_ARCH_X64 1 26#if defined(__x86_64__) && __SIZEOF_POINTER__ == 4 // Check for x32. 27#define V8_HOST_ARCH_32_BIT 1 28#else 29#define V8_HOST_ARCH_64_BIT 1 30#endif 31#endif // __native_client__ 32#elif defined(_M_IX86) || defined(__i386__) 33#define V8_HOST_ARCH_IA32 1 34#define V8_HOST_ARCH_32_BIT 1 35#elif defined(__AARCH64EL__) 36#define V8_HOST_ARCH_ARM64 1 37#define V8_HOST_ARCH_64_BIT 1 38#elif defined(__ARMEL__) 39#define V8_HOST_ARCH_ARM 1 40#define V8_HOST_ARCH_32_BIT 1 41#elif defined(__mips64) 42#define V8_HOST_ARCH_MIPS64 1 43#define V8_HOST_ARCH_64_BIT 1 44#elif defined(__MIPSEB__) || defined(__MIPSEL__) 45#define V8_HOST_ARCH_MIPS 1 46#define V8_HOST_ARCH_32_BIT 1 47#else 48#error "Host architecture was not detected as supported by v8" 49#endif 50 51#if defined(__ARM_ARCH_7A__) || \ 52 defined(__ARM_ARCH_7R__) || \ 53 defined(__ARM_ARCH_7__) 54# define CAN_USE_ARMV7_INSTRUCTIONS 1 55# ifndef CAN_USE_VFP3_INSTRUCTIONS 56# define CAN_USE_VFP3_INSTRUCTIONS 57# endif 58#endif 59 60 61// Target architecture detection. This may be set externally. If not, detect 62// in the same way as the host architecture, that is, target the native 63// environment as presented by the compiler. 64#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_X87 && \ 65 !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && \ 66 !V8_TARGET_ARCH_MIPS64 67#if defined(_M_X64) || defined(__x86_64__) 68#define V8_TARGET_ARCH_X64 1 69#elif defined(_M_IX86) || defined(__i386__) 70#define V8_TARGET_ARCH_IA32 1 71#elif defined(__AARCH64EL__) 72#define V8_TARGET_ARCH_ARM64 1 73#elif defined(__ARMEL__) 74#define V8_TARGET_ARCH_ARM 1 75#elif defined(__mips64) 76#define V8_TARGET_ARCH_MIPS64 1 77#elif defined(__MIPSEB__) || defined(__MIPSEL__) 78#define V8_TARGET_ARCH_MIPS 1 79#else 80#error Target architecture was not detected as supported by v8 81#endif 82#endif 83 84// Determine architecture pointer size. 85#if V8_TARGET_ARCH_IA32 86#define V8_TARGET_ARCH_32_BIT 1 87#elif V8_TARGET_ARCH_X64 88#if !V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_64_BIT 89#if defined(__x86_64__) && __SIZEOF_POINTER__ == 4 // Check for x32. 90#define V8_TARGET_ARCH_32_BIT 1 91#else 92#define V8_TARGET_ARCH_64_BIT 1 93#endif 94#endif 95#elif V8_TARGET_ARCH_ARM 96#define V8_TARGET_ARCH_32_BIT 1 97#elif V8_TARGET_ARCH_ARM64 98#define V8_TARGET_ARCH_64_BIT 1 99#elif V8_TARGET_ARCH_MIPS 100#define V8_TARGET_ARCH_32_BIT 1 101#elif V8_TARGET_ARCH_MIPS64 102#define V8_TARGET_ARCH_64_BIT 1 103#elif V8_TARGET_ARCH_X87 104#define V8_TARGET_ARCH_32_BIT 1 105#else 106#error Unknown target architecture pointer size 107#endif 108 109// Check for supported combinations of host and target architectures. 110#if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32 111#error Target architecture ia32 is only supported on ia32 host 112#endif 113#if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT && \ 114 !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_64_BIT)) 115#error Target architecture x64 is only supported on x64 host 116#endif 117#if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT && \ 118 !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_32_BIT)) 119#error Target architecture x32 is only supported on x64 host with x32 support 120#endif 121#if (V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM)) 122#error Target architecture arm is only supported on arm and ia32 host 123#endif 124#if (V8_TARGET_ARCH_ARM64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64)) 125#error Target architecture arm64 is only supported on arm64 and x64 host 126#endif 127#if (V8_TARGET_ARCH_MIPS && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_MIPS)) 128#error Target architecture mips is only supported on mips and ia32 host 129#endif 130#if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64)) 131#error Target architecture mips64 is only supported on mips64 and x64 host 132#endif 133 134// Determine architecture endianness. 135#if V8_TARGET_ARCH_IA32 136#define V8_TARGET_LITTLE_ENDIAN 1 137#elif V8_TARGET_ARCH_X64 138#define V8_TARGET_LITTLE_ENDIAN 1 139#elif V8_TARGET_ARCH_ARM 140#define V8_TARGET_LITTLE_ENDIAN 1 141#elif V8_TARGET_ARCH_ARM64 142#define V8_TARGET_LITTLE_ENDIAN 1 143#elif V8_TARGET_ARCH_MIPS 144#if defined(__MIPSEB__) 145#define V8_TARGET_BIG_ENDIAN 1 146#else 147#define V8_TARGET_LITTLE_ENDIAN 1 148#endif 149#elif V8_TARGET_ARCH_MIPS64 150#define V8_TARGET_LITTLE_ENDIAN 1 151#elif V8_TARGET_ARCH_X87 152#define V8_TARGET_LITTLE_ENDIAN 1 153#else 154#error Unknown target architecture endianness 155#endif 156 157// Number of bits to represent the page size for paged spaces. The value of 20 158// gives 1Mb bytes per page. 159const int kPageSizeBits = 20; 160 161#endif // V8_BASE_BUILD_CONFIG_H_ 162