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

Deuglify V8_INLINE and V8_NOINLINE.

R=dslomov@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16641 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b60b8c3b
This diff is collapsed.
...@@ -298,23 +298,27 @@ ...@@ -298,23 +298,27 @@
// Helper macros // Helper macros
// A macro used to make better inlining. Don't bother for debug builds. // A macro used to make better inlining. Don't bother for debug builds.
// Use like:
// V8_INLINE int GetZero() { return 0; }
#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
# define V8_INLINE(declarator) inline __attribute__((always_inline)) declarator # define V8_INLINE inline __attribute__((always_inline))
#elif !defined(DEBUG) && V8_HAS___FORCEINLINE #elif !defined(DEBUG) && V8_HAS___FORCEINLINE
# define V8_INLINE(declarator) __forceinline declarator # define V8_INLINE __forceinline
#else #else
# define V8_INLINE(declarator) inline declarator # define V8_INLINE inline
#endif #endif
// A macro used to tell the compiler to never inline a particular function. // A macro used to tell the compiler to never inline a particular function.
// Don't bother for debug builds. // Don't bother for debug builds.
// Use like:
// V8_NOINLINE int GetMinusOne() { return -1; }
#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE
# define V8_NOINLINE(declarator) __attribute__((noinline)) declarator # define V8_NOINLINE __attribute__((noinline))
#elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE #elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE
# define V8_NOINLINE(declarator) __declspec(noinline) declarator # define V8_NOINLINE __declspec(noinline)
#else #else
# define V8_NOINLINE(declarator) declarator # define V8_NOINLINE /* NOT SUPPORTED */
#endif #endif
......
...@@ -54,7 +54,7 @@ namespace internal { ...@@ -54,7 +54,7 @@ namespace internal {
// Define __cpuid() for non-MSVC compilers. // Define __cpuid() for non-MSVC compilers.
#if !V8_CC_MSVC #if !V8_CC_MSVC
static V8_INLINE(void __cpuid(int cpu_info[4], int info_type)) { static V8_INLINE void __cpuid(int cpu_info[4], int info_type) {
#if defined(__i386__) && defined(__pic__) #if defined(__i386__) && defined(__pic__)
// Make sure to preserve ebx, which contains the pointer // Make sure to preserve ebx, which contains the pointer
// to the GOT in case we're generating PIC. // to the GOT in case we're generating PIC.
......
...@@ -342,9 +342,9 @@ F FUNCTION_CAST(Address addr) { ...@@ -342,9 +342,9 @@ F FUNCTION_CAST(Address addr) {
DISALLOW_COPY_AND_ASSIGN(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName)
// Newly written code should use V8_INLINE() and V8_NOINLINE() directly. // Newly written code should use V8_INLINE and V8_NOINLINE directly.
#define INLINE(declarator) V8_INLINE(declarator) #define INLINE(declarator) V8_INLINE declarator
#define NO_INLINE(declarator) V8_NOINLINE(declarator) #define NO_INLINE(declarator) V8_NOINLINE declarator
// Newly written code should use V8_WARN_UNUSED_RESULT. // Newly written code should use V8_WARN_UNUSED_RESULT.
......
...@@ -103,7 +103,7 @@ class ElapsedTimer V8_FINAL BASE_EMBEDDED { ...@@ -103,7 +103,7 @@ class ElapsedTimer V8_FINAL BASE_EMBEDDED {
} }
private: private:
V8_INLINE(static TimeTicks Now()) { static V8_INLINE TimeTicks Now() {
TimeTicks now = TimeTicks::HighResNow(); TimeTicks now = TimeTicks::HighResNow();
ASSERT(!now.IsNull()); ASSERT(!now.IsNull());
return now; return now;
......
...@@ -34,7 +34,7 @@ namespace internal { ...@@ -34,7 +34,7 @@ namespace internal {
#if V8_OS_POSIX #if V8_OS_POSIX
static V8_INLINE(void InitializeNativeHandle(pthread_mutex_t* mutex)) { static V8_INLINE void InitializeNativeHandle(pthread_mutex_t* mutex) {
int result; int result;
#if defined(DEBUG) #if defined(DEBUG)
// Use an error checking mutex in debug mode. // Use an error checking mutex in debug mode.
...@@ -55,7 +55,7 @@ static V8_INLINE(void InitializeNativeHandle(pthread_mutex_t* mutex)) { ...@@ -55,7 +55,7 @@ static V8_INLINE(void InitializeNativeHandle(pthread_mutex_t* mutex)) {
} }
static V8_INLINE(void InitializeRecursiveNativeHandle(pthread_mutex_t* mutex)) { static V8_INLINE void InitializeRecursiveNativeHandle(pthread_mutex_t* mutex) {
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
int result = pthread_mutexattr_init(&attr); int result = pthread_mutexattr_init(&attr);
ASSERT_EQ(0, result); ASSERT_EQ(0, result);
...@@ -69,28 +69,28 @@ static V8_INLINE(void InitializeRecursiveNativeHandle(pthread_mutex_t* mutex)) { ...@@ -69,28 +69,28 @@ static V8_INLINE(void InitializeRecursiveNativeHandle(pthread_mutex_t* mutex)) {
} }
static V8_INLINE(void DestroyNativeHandle(pthread_mutex_t* mutex)) { static V8_INLINE void DestroyNativeHandle(pthread_mutex_t* mutex) {
int result = pthread_mutex_destroy(mutex); int result = pthread_mutex_destroy(mutex);
ASSERT_EQ(0, result); ASSERT_EQ(0, result);
USE(result); USE(result);
} }
static V8_INLINE(void LockNativeHandle(pthread_mutex_t* mutex)) { static V8_INLINE void LockNativeHandle(pthread_mutex_t* mutex) {
int result = pthread_mutex_lock(mutex); int result = pthread_mutex_lock(mutex);
ASSERT_EQ(0, result); ASSERT_EQ(0, result);
USE(result); USE(result);
} }
static V8_INLINE(void UnlockNativeHandle(pthread_mutex_t* mutex)) { static V8_INLINE void UnlockNativeHandle(pthread_mutex_t* mutex) {
int result = pthread_mutex_unlock(mutex); int result = pthread_mutex_unlock(mutex);
ASSERT_EQ(0, result); ASSERT_EQ(0, result);
USE(result); USE(result);
} }
static V8_INLINE(bool TryLockNativeHandle(pthread_mutex_t* mutex)) { static V8_INLINE bool TryLockNativeHandle(pthread_mutex_t* mutex) {
int result = pthread_mutex_trylock(mutex); int result = pthread_mutex_trylock(mutex);
if (result == EBUSY) { if (result == EBUSY) {
return false; return false;
...@@ -101,32 +101,32 @@ static V8_INLINE(bool TryLockNativeHandle(pthread_mutex_t* mutex)) { ...@@ -101,32 +101,32 @@ static V8_INLINE(bool TryLockNativeHandle(pthread_mutex_t* mutex)) {
#elif V8_OS_WIN #elif V8_OS_WIN
static V8_INLINE(void InitializeNativeHandle(PCRITICAL_SECTION cs)) { static V8_INLINE void InitializeNativeHandle(PCRITICAL_SECTION cs) {
InitializeCriticalSection(cs); InitializeCriticalSection(cs);
} }
static V8_INLINE(void InitializeRecursiveNativeHandle(PCRITICAL_SECTION cs)) { static V8_INLINE void InitializeRecursiveNativeHandle(PCRITICAL_SECTION cs) {
InitializeCriticalSection(cs); InitializeCriticalSection(cs);
} }
static V8_INLINE(void DestroyNativeHandle(PCRITICAL_SECTION cs)) { static V8_INLINE void DestroyNativeHandle(PCRITICAL_SECTION cs) {
DeleteCriticalSection(cs); DeleteCriticalSection(cs);
} }
static V8_INLINE(void LockNativeHandle(PCRITICAL_SECTION cs)) { static V8_INLINE void LockNativeHandle(PCRITICAL_SECTION cs) {
EnterCriticalSection(cs); EnterCriticalSection(cs);
} }
static V8_INLINE(void UnlockNativeHandle(PCRITICAL_SECTION cs)) { static V8_INLINE void UnlockNativeHandle(PCRITICAL_SECTION cs) {
LeaveCriticalSection(cs); LeaveCriticalSection(cs);
} }
static V8_INLINE(bool TryLockNativeHandle(PCRITICAL_SECTION cs)) { static V8_INLINE bool TryLockNativeHandle(PCRITICAL_SECTION cs) {
return TryEnterCriticalSection(cs); return TryEnterCriticalSection(cs);
} }
......
...@@ -94,14 +94,14 @@ class Mutex V8_FINAL { ...@@ -94,14 +94,14 @@ class Mutex V8_FINAL {
int level_; int level_;
#endif #endif
V8_INLINE(void AssertHeldAndUnmark()) { V8_INLINE void AssertHeldAndUnmark() {
#ifdef DEBUG #ifdef DEBUG
ASSERT_EQ(1, level_); ASSERT_EQ(1, level_);
level_--; level_--;
#endif #endif
} }
V8_INLINE(void AssertUnheldAndMark()) { V8_INLINE void AssertUnheldAndMark() {
#ifdef DEBUG #ifdef DEBUG
ASSERT_EQ(0, level_); ASSERT_EQ(0, level_);
level_++; level_++;
......
...@@ -66,7 +66,7 @@ class Socket V8_FINAL { ...@@ -66,7 +66,7 @@ class Socket V8_FINAL {
// Set the value of the SO_REUSEADDR socket option. // Set the value of the SO_REUSEADDR socket option.
bool SetReuseAddress(bool reuse_address); bool SetReuseAddress(bool reuse_address);
V8_INLINE(bool IsValid()) const { V8_INLINE bool IsValid() const {
return native_handle_ != kInvalidNativeHandle; return native_handle_ != kInvalidNativeHandle;
} }
......
...@@ -54,7 +54,7 @@ namespace internal { ...@@ -54,7 +54,7 @@ namespace internal {
class RandomAddressGenerator V8_FINAL { class RandomAddressGenerator V8_FINAL {
public: public:
V8_INLINE(uintptr_t NextAddress()) { V8_INLINE uintptr_t NextAddress() {
LockGuard<Mutex> lock_guard(&mutex_); LockGuard<Mutex> lock_guard(&mutex_);
uintptr_t address = rng_.NextInt(); uintptr_t address = rng_.NextInt();
#if V8_HOST_ARCH_64_BIT #if V8_HOST_ARCH_64_BIT
...@@ -75,7 +75,7 @@ typedef LazyInstance<RandomAddressGenerator, ...@@ -75,7 +75,7 @@ typedef LazyInstance<RandomAddressGenerator,
#define LAZY_RANDOM_ADDRESS_GENERATOR_INITIALIZER LAZY_INSTANCE_INITIALIZER #define LAZY_RANDOM_ADDRESS_GENERATOR_INITIALIZER LAZY_INSTANCE_INITIALIZER
static V8_INLINE(void* GenerateRandomAddress()) { static V8_INLINE void* GenerateRandomAddress() {
#if V8_OS_NACL #if V8_OS_NACL
// TODO(bradchen): Restore randomization once Native Client gets smarter // TODO(bradchen): Restore randomization once Native Client gets smarter
// about using mmap address hints. // about using mmap address hints.
......
...@@ -193,7 +193,7 @@ class VirtualMemory V8_FINAL { ...@@ -193,7 +193,7 @@ class VirtualMemory V8_FINAL {
// Returns true if OS performs lazy commits, i.e. the memory allocation call // Returns true if OS performs lazy commits, i.e. the memory allocation call
// defers actual physical memory allocation till the first memory access. // defers actual physical memory allocation till the first memory access.
// Otherwise returns false. // Otherwise returns false.
static V8_INLINE(bool HasLazyCommits()) { static V8_INLINE bool HasLazyCommits() {
#if V8_OS_LINUX #if V8_OS_LINUX
return true; return true;
#else #else
......
...@@ -1092,7 +1092,7 @@ class MemoryAllocator { ...@@ -1092,7 +1092,7 @@ class MemoryAllocator {
// Returns an indication of whether a pointer is in a space that has // Returns an indication of whether a pointer is in a space that has
// been allocated by this MemoryAllocator. // been allocated by this MemoryAllocator.
V8_INLINE(bool IsOutsideAllocatedSpace(const void* address)) const { V8_INLINE bool IsOutsideAllocatedSpace(const void* address) const {
return address < lowest_ever_allocated_ || return address < lowest_ever_allocated_ ||
address >= highest_ever_allocated_; address >= highest_ever_allocated_;
} }
......
...@@ -59,7 +59,7 @@ class RandomNumberGenerator V8_FINAL { ...@@ -59,7 +59,7 @@ class RandomNumberGenerator V8_FINAL {
// that one int value is pseudorandomly generated and returned. // that one int value is pseudorandomly generated and returned.
// All 2^32 possible integer values are produced with (approximately) equal // All 2^32 possible integer values are produced with (approximately) equal
// probability. // probability.
V8_INLINE(int NextInt()) V8_WARN_UNUSED_RESULT { V8_INLINE int NextInt() V8_WARN_UNUSED_RESULT {
return Next(32); return Next(32);
} }
...@@ -76,7 +76,7 @@ class RandomNumberGenerator V8_FINAL { ...@@ -76,7 +76,7 @@ class RandomNumberGenerator V8_FINAL {
// |NextBoolean()| is that one boolean value is pseudorandomly generated and // |NextBoolean()| is that one boolean value is pseudorandomly generated and
// returned. The values true and false are produced with (approximately) equal // returned. The values true and false are produced with (approximately) equal
// probability. // probability.
V8_INLINE(bool NextBool()) V8_WARN_UNUSED_RESULT { V8_INLINE bool NextBool() V8_WARN_UNUSED_RESULT {
return Next(1) != 0; return Next(1) != 0;
} }
......
...@@ -12670,8 +12670,8 @@ struct CopyablePersistentTraits { ...@@ -12670,8 +12670,8 @@ struct CopyablePersistentTraits {
typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent; typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
static const bool kResetInDestructor = true; static const bool kResetInDestructor = true;
template<class S, class M> template<class S, class M>
V8_INLINE(static void Copy(const Persistent<S, M>& source, static V8_INLINE void Copy(const Persistent<S, M>& source,
CopyablePersistent* dest)) { CopyablePersistent* dest) {
// do nothing, just allow copy // do nothing, just allow copy
} }
}; };
......
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