2012-02-22 12:26:36 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2008-11-05 19:18:10 +00:00
|
|
|
#ifndef V8_GLOBALS_H_
|
|
|
|
#define V8_GLOBALS_H_
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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
|
2011-09-07 12:39:53 +00:00
|
|
|
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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
|
2011-09-07 12:39:53 +00:00
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
#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
|
|
|
|
# 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
|
2011-09-07 12:39:53 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
#if V8_CC_GNU
|
|
|
|
# define V8_GNUC_PREREQ(major, minor) \
|
|
|
|
(__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
|
|
|
|
#else
|
|
|
|
# define V8_GNUC_PREREQ(major, minor) 0
|
|
|
|
#endif // V8_CC_GNU
|
2013-07-29 12:12:39 +00:00
|
|
|
|
2011-09-07 12:39:53 +00:00
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Compiler features
|
2011-09-07 12:39:53 +00:00
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
// C++11 deleted functions
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
# define V8_CXX_DELETED_FUNCTIONS 1
|
|
|
|
#elif V8_CC_CLANG
|
|
|
|
# define V8_CXX_DELETED_FUNCTIONS __has_feature(cxx_deleted_functions)
|
|
|
|
#else
|
|
|
|
# define V8_CXX_DELETED_FUNCTIONS (defined(__GXX_EXPERIMENTAL_CXX0X__) && \
|
|
|
|
V8_GNUC_PREREQ(4, 4))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// C++11 static_assert()
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
# define V8_CXX_STATIC_ASSERT 1
|
|
|
|
#elif V8_CC_CLANG
|
|
|
|
# define V8_CXX_STATIC_ASSERT (__has_extension(cxx_static_assert) || \
|
|
|
|
__has_feature(cxx_static_assert))
|
|
|
|
#else
|
|
|
|
# define V8_CXX_STATIC_ASSERT (defined(__GXX_EXPERIMENTAL_CXX0X__) && \
|
|
|
|
V8_GNUC_PREREQ(4, 3))
|
|
|
|
#endif
|
2013-07-29 12:12:39 +00:00
|
|
|
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Host architecture detection. For more info on what's defined, see:
|
2009-05-05 12:06:20 +00:00
|
|
|
// 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 -"
|
2013-07-30 10:36:58 +00:00
|
|
|
|
2009-05-05 12:06:20 +00:00
|
|
|
#if defined(_M_X64) || defined(__x86_64__)
|
2013-07-30 10:36:58 +00:00
|
|
|
# if V8_OS_NACL
|
2013-04-17 08:27:40 +00:00
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// Since Native Client is ILP-32 on all architectures we use
|
|
|
|
// V8_HOST_ARCH_IA32 on both 32- and 64-bit x86.
|
2013-07-30 10:36:58 +00:00
|
|
|
# define V8_HOST_ARCH_IA32 1
|
|
|
|
# define V8_HOST_ARCH_32_BIT 1
|
|
|
|
# define V8_HOST_CAN_READ_UNALIGNED 1
|
|
|
|
# else
|
|
|
|
# define V8_HOST_ARCH_X64 1
|
|
|
|
# define V8_HOST_ARCH_64_BIT 1
|
|
|
|
# define V8_HOST_CAN_READ_UNALIGNED 1
|
|
|
|
# endif // V8_OS_NACL
|
2009-05-05 12:06:20 +00:00
|
|
|
#elif defined(_M_IX86) || defined(__i386__)
|
2013-07-30 10:36:58 +00:00
|
|
|
# define V8_HOST_ARCH_IA32 1
|
|
|
|
# define V8_HOST_ARCH_32_BIT 1
|
|
|
|
# define V8_HOST_CAN_READ_UNALIGNED 1
|
2009-05-05 12:06:20 +00:00
|
|
|
#elif defined(__ARMEL__)
|
2013-07-30 10:36:58 +00:00
|
|
|
# define V8_HOST_ARCH_ARM 1
|
|
|
|
# define V8_HOST_ARCH_32_BIT 1
|
2011-03-28 13:05:36 +00:00
|
|
|
#elif defined(__MIPSEL__)
|
2013-07-30 10:36:58 +00:00
|
|
|
# define V8_HOST_ARCH_MIPS 1
|
|
|
|
# define V8_HOST_ARCH_32_BIT 1
|
2009-05-05 12:06:20 +00:00
|
|
|
#else
|
2013-07-30 10:36:58 +00:00
|
|
|
# error Host architecture was not detected as supported by v8
|
2009-08-31 12:40:37 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-10 15:32:39 +00:00
|
|
|
#if defined(__ARM_ARCH_7A__) || \
|
|
|
|
defined(__ARM_ARCH_7R__) || \
|
|
|
|
defined(__ARM_ARCH_7__)
|
|
|
|
# define CAN_USE_ARMV7_INSTRUCTIONS 1
|
|
|
|
# ifndef CAN_USE_VFP3_INSTRUCTIONS
|
2013-07-30 10:36:58 +00:00
|
|
|
# define CAN_USE_VFP3_INSTRUCTIONS 1
|
2013-07-10 15:32:39 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-17 15:41:35 +00:00
|
|
|
// Target architecture detection. This may be set externally. If not, detect
|
|
|
|
// in the same way as the host architecture, that is, target the native
|
|
|
|
// environment as presented by the compiler.
|
2013-07-30 10:36:58 +00:00
|
|
|
|
2013-06-28 15:34:48 +00:00
|
|
|
#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && \
|
|
|
|
!V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS
|
2013-07-30 10:36:58 +00:00
|
|
|
# if V8_HOST_ARCH_X64
|
|
|
|
# define V8_TARGET_ARCH_X64 1
|
|
|
|
# elif V8_HOST_ARCH_IA32
|
|
|
|
# define V8_TARGET_ARCH_IA32 1
|
|
|
|
# elif V8_HOST_ARCH_ARM
|
|
|
|
# define V8_TARGET_ARCH_ARM 1
|
|
|
|
# elif V8_HOST_ARCH_MIPS
|
|
|
|
# define V8_TARGET_ARCH_MIPS 1
|
|
|
|
# else
|
|
|
|
# error Target architecture was not detected as supported by v8
|
|
|
|
# endif
|
2010-05-17 15:41:35 +00:00
|
|
|
#endif
|
|
|
|
|
2010-04-26 10:59:14 +00:00
|
|
|
// Check for supported combinations of host and target architectures.
|
2013-06-28 15:34:48 +00:00
|
|
|
#if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32
|
2013-07-30 10:36:58 +00:00
|
|
|
# error Target architecture ia32 is only supported on ia32 host
|
|
|
|
#elif V8_TARGET_ARCH_X64 && !V8_HOST_ARCH_X64
|
|
|
|
# error Target architecture x64 is only supported on x64 host
|
|
|
|
#elif V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM)
|
|
|
|
# error Target architecture arm is only supported on arm and ia32 host
|
|
|
|
#elif V8_TARGET_ARCH_MIPS && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_MIPS)
|
|
|
|
# error Target architecture mips is only supported on mips and ia32 host
|
2010-04-26 10:59:14 +00:00
|
|
|
#endif
|
|
|
|
|
2010-10-25 16:40:41 +00:00
|
|
|
// Determine whether we are running in a simulated environment.
|
2010-10-26 08:12:17 +00:00
|
|
|
// Setting USE_SIMULATOR explicitly from the build script will force
|
|
|
|
// the use of a simulated environment.
|
|
|
|
#if !defined(USE_SIMULATOR)
|
2013-07-30 10:36:58 +00:00
|
|
|
# if V8_TARGET_ARCH_ARM && !V8_HOST_ARCH_ARM
|
|
|
|
# define USE_SIMULATOR 1
|
|
|
|
# elif V8_TARGET_ARCH_MIPS && !V8_HOST_ARCH_MIPS
|
|
|
|
# define USE_SIMULATOR 1
|
|
|
|
# endif
|
2010-10-26 08:12:17 +00:00
|
|
|
#endif
|
2010-10-25 16:40:41 +00:00
|
|
|
|
2013-06-21 13:02:38 +00:00
|
|
|
// Determine architecture endiannes (we only support little-endian).
|
2013-07-30 10:36:58 +00:00
|
|
|
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || \
|
|
|
|
V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
|
|
|
|
# define V8_TARGET_LITTLE_ENDIAN 1
|
2013-06-21 13:02:38 +00:00
|
|
|
#else
|
2013-07-30 10:36:58 +00:00
|
|
|
# error Unknown target architecture endiannes
|
2013-06-21 13:02:38 +00:00
|
|
|
#endif
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2009-05-05 10:21:28 +00:00
|
|
|
// Define our own macros for writing 64-bit constants. This is less fragile
|
|
|
|
// than defining __STDC_CONSTANT_MACROS before including <stdint.h>, and it
|
|
|
|
// works on compilers that don't have it (like MSVC).
|
2009-05-05 12:06:20 +00:00
|
|
|
#if V8_HOST_ARCH_64_BIT
|
2013-07-30 10:36:58 +00:00
|
|
|
# if V8_CC_MSVC
|
|
|
|
# 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_MINGW
|
|
|
|
# define V8_UINT64_C(x) (x ## ULL)
|
|
|
|
# define V8_INT64_C(x) (x ## LL)
|
|
|
|
# define V8_INTPTR_C(x) (x ## LL)
|
|
|
|
# define V8_PTR_PREFIX "I64"
|
|
|
|
# else
|
|
|
|
# define V8_UINT64_C(x) (x ## UL)
|
|
|
|
# define V8_INT64_C(x) (x ## L)
|
|
|
|
# define V8_INTPTR_C(x) (x ## L)
|
|
|
|
# define V8_PTR_PREFIX "l"
|
|
|
|
# endif
|
2009-05-07 10:31:14 +00:00
|
|
|
#else // V8_HOST_ARCH_64_BIT
|
2013-07-30 10:36:58 +00:00
|
|
|
# define V8_INTPTR_C(x) (x)
|
|
|
|
# define V8_PTR_PREFIX ""
|
2009-05-13 16:37:39 +00:00
|
|
|
#endif // V8_HOST_ARCH_64_BIT
|
2009-05-07 09:27:42 +00:00
|
|
|
|
2010-03-11 14:49:35 +00:00
|
|
|
// The following macro works on both 32 and 64-bit platforms.
|
|
|
|
// Usage: instead of writing 0x1234567890123456
|
|
|
|
// write V8_2PART_UINT64_C(0x12345678,90123456);
|
|
|
|
#define V8_2PART_UINT64_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
#if V8_OS_DARWIN
|
|
|
|
// Fix for Mac OS X defining uintptr_t as "unsigned long":
|
|
|
|
# define V8PRIxPTR "lx"
|
|
|
|
#else
|
|
|
|
# define V8PRIxPTR V8_PTR_PREFIX "x"
|
|
|
|
#endif // V8_OS_DARWIN
|
2009-05-12 10:33:40 +00:00
|
|
|
#define V8PRIdPTR V8_PTR_PREFIX "d"
|
2012-08-22 15:44:17 +00:00
|
|
|
#define V8PRIuPTR V8_PTR_PREFIX "u"
|
2009-05-04 13:29:29 +00:00
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Define V8_INFINITY
|
|
|
|
#if 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
|
2009-05-13 16:37:39 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
|
|
|
|
#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
|
|
|
|
// source of bugs.
|
|
|
|
// However, redefining the bool type does have some negative impact on some
|
|
|
|
// platforms. It gives rise to compiler warnings (i.e. with
|
|
|
|
// MSVC) in the API header files when mixing code that uses the standard
|
|
|
|
// bool with code that uses the redefined version.
|
|
|
|
// This does not actually belong in the platform code, but needs to be
|
|
|
|
// defined here because the platform code uses bool, and platform.h is
|
|
|
|
// include very early in the main include file.
|
|
|
|
|
|
|
|
#ifdef USE_MYBOOL
|
|
|
|
typedef unsigned int __my_bool__;
|
|
|
|
#define bool __my_bool__ // use 'indirection' to avoid name clashes
|
2013-07-29 12:12:39 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
typedef uint8_t byte;
|
|
|
|
typedef byte* Address;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Constants
|
|
|
|
|
|
|
|
const int KB = 1024;
|
|
|
|
const int MB = KB * KB;
|
|
|
|
const int GB = KB * KB * KB;
|
|
|
|
const int kMaxInt = 0x7FFFFFFF;
|
|
|
|
const int kMinInt = -kMaxInt - 1;
|
|
|
|
|
2009-04-27 11:16:59 +00:00
|
|
|
const uint32_t kMaxUInt32 = 0xFFFFFFFFu;
|
|
|
|
|
2013-07-23 13:46:10 +00:00
|
|
|
const int kCharSize = sizeof(char); // NOLINT
|
|
|
|
const int kShortSize = sizeof(short); // NOLINT
|
|
|
|
const int kIntSize = sizeof(int); // NOLINT
|
|
|
|
const int kDoubleSize = sizeof(double); // NOLINT
|
|
|
|
const int kIntptrSize = sizeof(intptr_t); // NOLINT
|
|
|
|
const int kPointerSize = sizeof(void*); // NOLINT
|
|
|
|
const int kRegisterSize = kPointerSize;
|
|
|
|
const int kPCOnStackSize = kRegisterSize;
|
|
|
|
const int kFPOnStackSize = kRegisterSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-07-13 13:50:27 +00:00
|
|
|
const int kDoubleSizeLog2 = 3;
|
|
|
|
|
2011-10-24 12:12:21 +00:00
|
|
|
// Size of the state of a the random number generator.
|
|
|
|
const int kRandomStateSize = 2 * kIntSize;
|
|
|
|
|
2009-05-05 12:06:20 +00:00
|
|
|
#if V8_HOST_ARCH_64_BIT
|
2009-05-04 13:29:29 +00:00
|
|
|
const int kPointerSizeLog2 = 3;
|
2009-06-17 11:50:33 +00:00
|
|
|
const intptr_t kIntptrSignBit = V8_INT64_C(0x8000000000000000);
|
2010-10-26 18:14:45 +00:00
|
|
|
const uintptr_t kUintptrAllBitsSet = V8_UINT64_C(0xFFFFFFFFFFFFFFFF);
|
2009-05-04 13:29:29 +00:00
|
|
|
#else
|
2008-07-03 15:10:15 +00:00
|
|
|
const int kPointerSizeLog2 = 2;
|
2009-06-17 11:50:33 +00:00
|
|
|
const intptr_t kIntptrSignBit = 0x80000000;
|
2010-10-26 18:14:45 +00:00
|
|
|
const uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu;
|
2009-05-04 13:29:29 +00:00
|
|
|
#endif
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
const int kBitsPerByte = 8;
|
|
|
|
const int kBitsPerByteLog2 = 3;
|
|
|
|
const int kBitsPerPointer = kPointerSize * kBitsPerByte;
|
|
|
|
const int kBitsPerInt = kIntSize * kBitsPerByte;
|
|
|
|
|
2010-03-23 13:38:04 +00:00
|
|
|
// IEEE 754 single precision floating point number bit layout.
|
|
|
|
const uint32_t kBinary32SignMask = 0x80000000u;
|
|
|
|
const uint32_t kBinary32ExponentMask = 0x7f800000u;
|
|
|
|
const uint32_t kBinary32MantissaMask = 0x007fffffu;
|
|
|
|
const int kBinary32ExponentBias = 127;
|
|
|
|
const int kBinary32MaxExponent = 0xFE;
|
|
|
|
const int kBinary32MinExponent = 0x01;
|
|
|
|
const int kBinary32MantissaBits = 23;
|
|
|
|
const int kBinary32ExponentShift = 23;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-09-26 12:44:36 +00:00
|
|
|
// Quiet NaNs have bits 51 to 62 set, possibly the sign bit, and no
|
|
|
|
// other bits set.
|
|
|
|
const uint64_t kQuietNaNMask = static_cast<uint64_t>(0xfff) << 51;
|
|
|
|
|
2013-01-09 10:30:54 +00:00
|
|
|
// Latin1/UTF-16 constants
|
2010-12-22 20:14:19 +00:00
|
|
|
// Code-point values in Unicode 4.0 are 21 bits wide.
|
2012-03-12 12:35:28 +00:00
|
|
|
// Code units in UTF-16 are 16 bits wide.
|
2010-12-22 20:14:19 +00:00
|
|
|
typedef uint16_t uc16;
|
|
|
|
typedef int32_t uc32;
|
2013-01-09 10:30:54 +00:00
|
|
|
const int kOneByteSize = kCharSize;
|
2010-12-22 20:14:19 +00:00
|
|
|
const int kUC16Size = sizeof(uc16); // NOLINT
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// The expression OFFSET_OF(type, field) computes the byte-offset
|
|
|
|
// of the specified field relative to the containing type. This
|
|
|
|
// corresponds to 'offsetof' (in stddef.h), except that it doesn't
|
|
|
|
// use 0 or NULL, which causes a problem with the compiler warnings
|
|
|
|
// we have enabled (which is also why 'offsetof' doesn't seem to work).
|
|
|
|
// Here we simply use the non-zero value 4, which seems to work.
|
|
|
|
#define OFFSET_OF(type, field) \
|
|
|
|
(reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4)
|
|
|
|
|
|
|
|
|
|
|
|
// The expression ARRAY_SIZE(a) is a compile-time constant of type
|
|
|
|
// size_t which represents the number of elements of the given
|
|
|
|
// array. You should only use ARRAY_SIZE on statically allocated
|
|
|
|
// arrays.
|
|
|
|
#define ARRAY_SIZE(a) \
|
|
|
|
((sizeof(a) / sizeof(*(a))) / \
|
|
|
|
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
|
|
|
|
|
|
|
|
|
|
|
|
// The USE(x) template is used to silence C++ compiler warnings
|
|
|
|
// issued for (yet) unused variables (typically parameters).
|
|
|
|
template <typename T>
|
2011-11-29 10:56:11 +00:00
|
|
|
inline void USE(T) { }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// FUNCTION_ADDR(f) gets the address of a C function f.
|
|
|
|
#define FUNCTION_ADDR(f) \
|
|
|
|
(reinterpret_cast<v8::internal::Address>(reinterpret_cast<intptr_t>(f)))
|
|
|
|
|
|
|
|
|
|
|
|
// FUNCTION_CAST<F>(addr) casts an address into a function
|
|
|
|
// of type F. Used to invoke generated code from within C.
|
|
|
|
template <typename F>
|
|
|
|
F FUNCTION_CAST(Address addr) {
|
|
|
|
return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
#if V8_CXX_DELETED_FUNCTIONS
|
|
|
|
# define DISALLOW_BY_DELETE = delete
|
2013-07-18 09:25:54 +00:00
|
|
|
#else
|
2013-07-30 10:36:58 +00:00
|
|
|
# define DISALLOW_BY_DELETE
|
2013-07-18 09:25:54 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// A macro to disallow the evil copy constructor and operator= functions
|
|
|
|
// This should be used in the private: declarations for a class
|
2013-07-18 09:25:54 +00:00
|
|
|
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
|
|
|
TypeName(const TypeName&) DISALLOW_BY_DELETE; \
|
|
|
|
void operator=(const TypeName&) DISALLOW_BY_DELETE
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// A macro to disallow all the implicit constructors, namely the
|
|
|
|
// default constructor, copy constructor and operator= functions.
|
|
|
|
//
|
|
|
|
// This should be used in the private: declarations for a class
|
|
|
|
// that wants to prevent anyone from instantiating it. This is
|
|
|
|
// especially useful for classes containing only static methods.
|
|
|
|
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
2013-07-18 09:25:54 +00:00
|
|
|
TypeName() DISALLOW_BY_DELETE; \
|
2008-08-28 09:55:41 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2010-08-31 08:05:42 +00:00
|
|
|
// Define used for helping GCC to make better inlining. Don't bother for debug
|
2009-02-09 15:06:07 +00:00
|
|
|
// builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation
|
|
|
|
// errors in debug build.
|
2013-07-30 10:36:58 +00:00
|
|
|
#if V8_GNUC_PREREQ(4, 0) && !defined(DEBUG)
|
|
|
|
# define INLINE(header) inline header __attribute__((always_inline))
|
|
|
|
# define NO_INLINE(header) header __attribute__((noinline))
|
|
|
|
#elif V8_CC_GNU && !defined(DEBUG)
|
|
|
|
# define INLINE(header) inline __attribute__((always_inline)) header
|
|
|
|
# define NO_INLINE(header) __attribute__((noinline)) header
|
|
|
|
#elif V8_CC_MSVC && !defined(DEBUG)
|
|
|
|
# define INLINE(header) __forceinline header
|
|
|
|
# define NO_INLINE(header) header
|
2008-07-03 15:10:15 +00:00
|
|
|
#else
|
2013-07-30 10:36:58 +00:00
|
|
|
# define INLINE(header) inline header
|
|
|
|
# define NO_INLINE(header) header
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif
|
|
|
|
|
2010-08-31 08:05:42 +00:00
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
#if V8_GNUC_PREREQ(4, 0)
|
2010-08-31 08:05:42 +00:00
|
|
|
#define MUST_USE_RESULT __attribute__ ((warn_unused_result))
|
|
|
|
#else
|
|
|
|
#define MUST_USE_RESULT
|
|
|
|
#endif
|
|
|
|
|
2012-08-21 14:21:53 +00:00
|
|
|
|
|
|
|
// Define DISABLE_ASAN macros.
|
|
|
|
#if defined(__has_feature)
|
|
|
|
#if __has_feature(address_sanitizer)
|
|
|
|
#define DISABLE_ASAN __attribute__((no_address_safety_analysis))
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_ASAN
|
|
|
|
#define DISABLE_ASAN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-11-15 13:23:30 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Forward declarations for frequently used classes
|
|
|
|
// (sorted alphabetically)
|
2010-08-31 08:05:42 +00:00
|
|
|
|
2010-11-15 13:23:30 +00:00
|
|
|
class FreeStoreAllocationPolicy;
|
|
|
|
template <typename T, class P = FreeStoreAllocationPolicy> class List;
|
2009-11-13 12:32:57 +00:00
|
|
|
|
2011-10-27 13:08:51 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Declarations for use in both the preparser and the rest of V8.
|
|
|
|
|
2011-11-24 15:17:04 +00:00
|
|
|
// The different language modes that V8 implements. ES5 defines two language
|
|
|
|
// modes: an unrestricted mode respectively a strict mode which are indicated by
|
|
|
|
// CLASSIC_MODE respectively STRICT_MODE in the enum. The harmony spec drafts
|
|
|
|
// for the next ES standard specify a new third mode which is called 'extended
|
|
|
|
// mode'. The extended mode is only available if the harmony flag is set. It is
|
|
|
|
// based on the 'strict mode' and adds new functionality to it. This means that
|
|
|
|
// most of the semantics of these two modes coincide.
|
|
|
|
//
|
|
|
|
// In the current draft the term 'base code' is used to refer to code that is
|
|
|
|
// neither in strict nor extended mode. However, the more distinguishing term
|
|
|
|
// 'classic mode' is used in V8 instead to avoid mix-ups.
|
|
|
|
|
|
|
|
enum LanguageMode {
|
|
|
|
CLASSIC_MODE,
|
|
|
|
STRICT_MODE,
|
|
|
|
EXTENDED_MODE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-21 11:10:06 +00:00
|
|
|
// A simple Maybe type, that can be passed by value.
|
|
|
|
template<class T>
|
|
|
|
struct Maybe {
|
|
|
|
Maybe() : has_value(false) {}
|
|
|
|
explicit Maybe(T t) : has_value(true), value(t) {}
|
|
|
|
Maybe(bool has, T t) : has_value(has), value(t) {}
|
|
|
|
|
|
|
|
bool has_value;
|
|
|
|
T value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-10-27 13:08:51 +00:00
|
|
|
// The Strict Mode (ECMA-262 5th edition, 4.2.2).
|
2011-11-24 15:17:04 +00:00
|
|
|
//
|
|
|
|
// This flag is used in the backend to represent the language mode. So far
|
|
|
|
// there is no semantic difference between the strict and the extended mode in
|
|
|
|
// the backend, so both modes are represented by the kStrictMode value.
|
2011-10-27 13:08:51 +00:00
|
|
|
enum StrictModeFlag {
|
|
|
|
kNonStrictMode,
|
2011-10-28 09:10:29 +00:00
|
|
|
kStrictMode
|
2011-10-27 13:08:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_GLOBALS_H_
|