V8 Project
macros.h File Reference
#include <cstring>
#include "include/v8stdint.h"
#include "src/base/build_config.h"
#include "src/base/compiler-specific.h"
#include "src/base/logging.h"
+ Include dependency graph for macros.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CompileAssert< bool >
 
class  StaticAssertion< true >
 
class  StaticAssertionHelper< int >
 

Macros

#define OFFSET_OF(type, field)    (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4)
 
#define ARRAYSIZE_UNSAFE(a)
 
#define arraysize(array)   (sizeof(ArraySizeHelper(array)))
 
#define COMPILE_ASSERT(expr, msg)
 
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
 
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
 
#define INLINE(declarator)   V8_INLINE declarator
 
#define NO_INLINE(declarator)   V8_NOINLINE declarator
 
#define MUST_USE_RESULT   WARN_UNUSED_RESULT
 
#define DISABLE_ASAN
 
#define V8_IMMEDIATE_CRASH()   ((void(*)())0)()
 
#define SEMI_STATIC_JOIN(a, b)   SEMI_STATIC_JOIN_HELPER(a, b)
 
#define SEMI_STATIC_JOIN_HELPER(a, b)   a##b
 
#define STATIC_ASSERT(test)
 
#define IS_POWER_OF_TWO(x)   ((x) != 0 && (((x) & ((x) - 1)) == 0))
 
#define V8_UINT64_C(x)   (x ## ULL)
 
#define V8_INT64_C(x)   (x ## LL)
 
#define V8_INTPTR_C(x)   (x)
 
#define V8_PTR_PREFIX   ""
 
#define V8PRIxPTR   V8_PTR_PREFIX "x"
 
#define V8PRIdPTR   V8_PTR_PREFIX "d"
 
#define V8PRIuPTR   V8_PTR_PREFIX "u"
 
#define V8_2PART_UINT64_C(a, b)   (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
 

Functions

template<typename T , size_t N>
char(& ArraySizeHelper (T(&array)[N]))[N]
 
template<typename T , size_t N>
char(& ArraySizeHelper (const T(&array)[N]))[N]
 
template<class Dest , class Source >
Dest bit_cast (Source const &source)
 
template<typename T >
void USE (T)
 
template<typename T >
intptr_t OffsetFrom (T x)
 
template<typename T >
T AddressFrom (intptr_t x)
 
template<typename T >
T RoundDown (T x, intptr_t m)
 
template<typename T >
T RoundUp (T x, intptr_t m)
 

Macro Definition Documentation

◆ arraysize

#define arraysize (   array)    (sizeof(ArraySizeHelper(array)))

Definition at line 86 of file macros.h.

◆ ARRAYSIZE_UNSAFE

#define ARRAYSIZE_UNSAFE (   a)
Value:
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))

Definition at line 62 of file macros.h.

◆ COMPILE_ASSERT

#define COMPILE_ASSERT (   expr,
  msg 
)
Value:
msg[static_cast<bool>(expr) ? 1 : -1] ALLOW_UNUSED
#define ALLOW_UNUSED

Definition at line 131 of file macros.h.

◆ DISABLE_ASAN

#define DISABLE_ASAN

Definition at line 280 of file macros.h.

◆ DISALLOW_COPY_AND_ASSIGN

#define DISALLOW_COPY_AND_ASSIGN (   TypeName)
Value:
TypeName(const TypeName&) V8_DELETE; \
void operator=(const TypeName&) V8_DELETE
#define V8_DELETE
Definition: v8config.h:363

Definition at line 244 of file macros.h.

◆ DISALLOW_IMPLICIT_CONSTRUCTORS

#define DISALLOW_IMPLICIT_CONSTRUCTORS (   TypeName)
Value:
TypeName() V8_DELETE; \
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:244

Definition at line 255 of file macros.h.

◆ INLINE

#define INLINE (   declarator )    V8_INLINE declarator

Definition at line 261 of file macros.h.

◆ IS_POWER_OF_TWO

#define IS_POWER_OF_TWO (   x)    ((x) != 0 && (((x) & ((x) - 1)) == 0))

Definition at line 325 of file macros.h.

◆ MUST_USE_RESULT

#define MUST_USE_RESULT   WARN_UNUSED_RESULT

Definition at line 266 of file macros.h.

◆ NO_INLINE

#define NO_INLINE (   declarator)    V8_NOINLINE declarator

Definition at line 262 of file macros.h.

◆ OFFSET_OF

#define OFFSET_OF (   type,
  field 
)     (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4)

Definition at line 22 of file macros.h.

◆ SEMI_STATIC_JOIN

#define SEMI_STATIC_JOIN (   a,
 
)    SEMI_STATIC_JOIN_HELPER(a, b)

Definition at line 303 of file macros.h.

◆ SEMI_STATIC_JOIN_HELPER

#define SEMI_STATIC_JOIN_HELPER (   a,
 
)    a##b

Definition at line 304 of file macros.h.

◆ STATIC_ASSERT

#define STATIC_ASSERT (   test)
Value:
typedef \
StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \
SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__) ALLOW_UNUSED
#define SEMI_STATIC_JOIN(a, b)
Definition: macros.h:303

Definition at line 311 of file macros.h.

◆ V8_2PART_UINT64_C

#define V8_2PART_UINT64_C (   a,
 
)    (((static_cast<uint64_t>(a) << 32) + 0x##b##u))

Definition at line 376 of file macros.h.

◆ V8_IMMEDIATE_CRASH

#define V8_IMMEDIATE_CRASH ( )    ((void(*)())0)()

Definition at line 287 of file macros.h.

◆ V8_INT64_C

#define V8_INT64_C (   x)    (x ## LL)

Definition at line 358 of file macros.h.

◆ V8_INTPTR_C

#define V8_INTPTR_C (   x)    (x)

Definition at line 359 of file macros.h.

◆ V8_PTR_PREFIX

#define V8_PTR_PREFIX   ""

Definition at line 360 of file macros.h.

◆ V8_UINT64_C

#define V8_UINT64_C (   x)    (x ## ULL)

Definition at line 357 of file macros.h.

◆ V8PRIdPTR

#define V8PRIdPTR   V8_PTR_PREFIX "d"

Definition at line 364 of file macros.h.

◆ V8PRIuPTR

#define V8PRIuPTR   V8_PTR_PREFIX "u"

Definition at line 365 of file macros.h.

◆ V8PRIxPTR

#define V8PRIxPTR   V8_PTR_PREFIX "x"

Definition at line 363 of file macros.h.

Function Documentation

◆ AddressFrom()

template<typename T >
T AddressFrom ( intptr_t  x)
inline

Definition at line 392 of file macros.h.

392  {
393  return static_cast<T>(static_cast<T>(0) + x);
394 }
#define T(name, string, precedence)
Definition: token.cc:25

References T.

◆ ArraySizeHelper() [1/2]

template<typename T , size_t N>
char(& ArraySizeHelper ( const T(&)  array[N]) )[N]

◆ ArraySizeHelper() [2/2]

template<typename T , size_t N>
char(& ArraySizeHelper ( T(&)  array[N]) )[N]

◆ bit_cast()

template<class Dest , class Source >
Dest bit_cast ( Source const &  source)
inline

Definition at line 233 of file macros.h.

233  {
234  COMPILE_ASSERT(sizeof(Dest) == sizeof(Source), VerifySizesAreEqual);
235 
236  Dest dest;
237  memcpy(&dest, &source, sizeof(dest));
238  return dest;
239 }
#define COMPILE_ASSERT(expr, msg)
Definition: macros.h:131

References COMPILE_ASSERT.

◆ OffsetFrom()

template<typename T >
intptr_t OffsetFrom ( T  x)
inline

◆ RoundDown()

template<typename T >
T RoundDown ( T  x,
intptr_t  m 
)
inline

Definition at line 399 of file macros.h.

399  {
401  return AddressFrom<T>(OffsetFrom(x) & -m);
402 }
#define DCHECK(condition)
Definition: logging.h:205
intptr_t OffsetFrom(T x)
Definition: macros.h:383
#define IS_POWER_OF_TWO(x)
Definition: macros.h:325

References DCHECK, IS_POWER_OF_TWO, and OffsetFrom().

Referenced by v8::internal::Zone::NewExpand(), v8::internal::PagedSpace::PagedSpace(), v8::internal::Space::RoundSizeDownToObjectAlignment(), v8::internal::MapSpace::RoundSizeDownToObjectAlignment(), v8::internal::CellSpace::RoundSizeDownToObjectAlignment(), v8::internal::PropertyCellSpace::RoundSizeDownToObjectAlignment(), and v8::internal::SemiSpace::SetUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RoundUp()

template<typename T >
T RoundUp ( T  x,
intptr_t  m 
)
inline

Definition at line 407 of file macros.h.

407  {
408  return RoundDown<T>(static_cast<T>(x + m - 1), m);
409 }

References T.

Referenced by v8::base::OS::Allocate(), and v8::base::VirtualMemory::VirtualMemory().

+ Here is the caller graph for this function:

◆ USE()

template<typename T >
void USE ( T  )
inline

Definition at line 322 of file macros.h.

322 { }

Referenced by v8::internal::OutputStreamWriter::AddNumberImpl(), v8::internal::Dictionary< Derived, Shape, Key >::AtPut(), v8::internal::HOptimizedGraphBuilder::BindIfLive(), v8::internal::Assembler::BitN(), v8::internal::BUILTIN(), v8::internal::RegExpImpl::CompileIrregexp(), v8::internal::OptimizingCompilerThread::CompileNext(), v8::internal::ParserBase< Traits >::Consume(), v8::base::Thread::CreateThreadLocalKey(), v8::base::Thread::DeleteThreadLocalKey(), v8::internal::Deoptimizer::DoComputeJSFrame(), v8::internal::Deoptimizer::DoComputeOutputFrames(), v8::internal::DoubleToPrecisionCString(), v8::internal::EmitUseLookupTable(), v8::base::OS::Free(), v8::internal::MemoryAllocator::FreeMemory(), v8::internal::Deoptimizer::TableEntryGenerator::GeneratePrologue(), v8::internal::OptimizedFrame::GetInlineCount(), v8::internal::JSReceiver::GetKeys(), v8::internal::Handle< T >::Handle(), v8::internal::HOptimizedGraphBuilder::HandleGlobalVariableAssignment(), v8::internal::HeapSnapshot::HeapSnapshot(), v8::internal::Assembler::ImmR(), v8::internal::Assembler::ImmRotate(), v8::internal::Assembler::ImmS(), v8::internal::Assembler::ImmSetBits(), v8::internal::SimulatorStack::JsLimitFromCLimit(), v8::internal::Assembler::LoadPairNonTemporalOpFor(), v8::internal::Assembler::LoadPairOpFor(), v8::internal::LowLevelLogger::LogWriteBytes(), v8::internal::HOptimizedGraphBuilder::LookupAndMakeLive(), v8::TypeSwitch::match(), v8::internal::MaybeHandle< T >::MaybeHandle(), v8::internal::MemsetPointer(), v8::internal::compiler::Instruction::New(), v8::internal::Parser::ParseExportDeclaration(), v8::internal::Parser::ParseModuleUrl(), v8::internal::JSObject::PrepareSlowElementsForSort(), v8::base::VirtualMemory::Release(), v8::internal::SamplerThread::RemoveActiveSampler(), v8::internal::RUNTIME_FUNCTION(), v8::internal::TypeFeedbackOracle::SetInfo(), v8::Function::SetName(), v8::base::Thread::SetThreadLocal(), v8::internal::StoreBuffer::SetUp(), v8::base::Thread::Start(), v8::internal::Assembler::StorePairNonTemporalOpFor(), v8::internal::Assembler::StorePairOpFor(), v8::internal::Unique< T >::Unique(), v8::internal::SharedFunctionInfo::VerifyBailoutId(), v8::base::VirtualMemory::VirtualMemory(), v8::internal::Log::WriteToFile(), v8::base::Thread::YieldCPU(), and v8::base::VirtualMemory::~VirtualMemory().

+ Here is the caller graph for this function: