chromium/v8/src/objects/object-macros.h

// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Note 1: Any file that includes this one should include object-macros-undef.h
// at the bottom.

// Note 2: This file is deliberately missing the include guards (the undeffing
// approach wouldn't work otherwise).
//
// PRESUBMIT_INTENTIONALLY_MISSING_INCLUDE_GUARD

// The accessors with RELAXED_, ACQUIRE_, and RELEASE_ prefixes should be used
// for fields that can be written to and read from multiple threads at the same
// time. See comments in src/base/atomicops.h for the memory ordering sematics.

#include "src/base/memory.h"

// V8 objects are defined as:
//
//     V8_OBJECT class Foo : public Base {
//       ...
//     } V8_OBJECT_END;
//
// These macros are to enable packing down to 4-byte alignment (i.e. int32
// alignment, since we have int32 fields), and to add warnings which ensure that
// there is no unwanted within-object padding.
#if V8_CC_GNU

#define V8_OBJECT_PUSH
#define V8_OBJECT_POP

#define V8_OBJECT

// GCC wants this pragma to be a new statement, but we prefer to have
// V8_OBJECT_END look like part of the definition. Insert a semicolon before the
// pragma to make gcc happy, and use static_assert(true) to swallow the next
// semicolon.
#define V8_OBJECT_END

#define V8_OBJECT_INNER_CLASS
#define V8_OBJECT_INNER_CLASS_END

#elif V8_CC_MSVC
#define V8_OBJECT_PUSH
#define V8_OBJECT_POP

#define V8_OBJECT
#define V8_OBJECT_END

#define V8_OBJECT_INNER_CLASS
#define V8_OBJECT_INNER_CLASS_END
#else
#error Unsupported compiler
#endif

// Since this changes visibility, it should always be last in a class
// definition.
#define OBJECT_CONSTRUCTORS

#define OBJECT_CONSTRUCTORS_IMPL

#define NEVER_READ_ONLY_SPACE

// TODO(leszeks): Add checks in the factory that we never allocate these
// objects in RO space.
#define NEVER_READ_ONLY_SPACE_IMPL

#define DECL_PRIMITIVE_GETTER

#define DECL_PRIMITIVE_SETTER

#define DECL_PRIMITIVE_ACCESSORS

#define DECL_BOOLEAN_ACCESSORS

#define DECL_INT_ACCESSORS

#define DECL_INT32_ACCESSORS

#define DECL_SANDBOXED_POINTER_ACCESSORS

#define DECL_UINT16_ACCESSORS

#define DECL_INT16_ACCESSORS

#define DECL_UINT8_ACCESSORS

#define DECL_RELAXED_PRIMITIVE_ACCESSORS

#define DECL_RELAXED_INT32_ACCESSORS

#define DECL_RELAXED_UINT32_ACCESSORS(name)

#define DECL_RELAXED_UINT16_ACCESSORS

#define DECL_RELAXED_UINT8_ACCESSORS(name)

#define DECL_GETTER

#define DEF_GETTER

#define DEF_RELAXED_GETTER

#define DEF_ACQUIRE_GETTER

#define DEF_HEAP_OBJECT_PREDICATE

#define TQ_FIELD_TYPE

#define DECL_FIELD_OFFSET_TQ

#define DECL_SETTER

#define DECL_ACCESSORS

#define DECL_ACCESSORS_LOAD_TAG

#define DECL_ACCESSORS_STORE_TAG

#define DECL_RELAXED_GETTER

#define DECL_RELAXED_SETTER

#define DECL_RELAXED_ACCESSORS

#define DECL_ACQUIRE_GETTER

#define DECL_RELEASE_SETTER

#define DECL_RELEASE_ACQUIRE_ACCESSORS

#define DECL_RELEASE_ACQUIRE_WEAK_ACCESSORS

#define DEF_PRIMITIVE_ACCESSORS

#define INT_ACCESSORS

#define INT32_ACCESSORS

#define UINT16_ACCESSORS

#define UINT8_ACCESSORS

#define RELAXED_INT32_ACCESSORS

#define RELAXED_UINT32_ACCESSORS(holder, name, offset)

#define RELAXED_UINT16_ACCESSORS

#define RELAXED_UINT8_ACCESSORS(holder, name, offset)

#define ACCESSORS_CHECKED2

#define ACCESSORS_CHECKED

#define ACCESSORS

// TODO(jgruber): Eventually, all accessors should be ported to the NOCAGE
// variant (which doesn't define a PtrComprCageBase overload). Once that's
// done, remove the cage-ful macros (e.g. ACCESSORS) and rename the cage-less
// macros (e.g. ACCESSORS_NOCAGE).
#define ACCESSORS_NOCAGE

#define RENAME_TORQUE_ACCESSORS

#define RENAME_PRIMITIVE_TORQUE_ACCESSORS

#define ACCESSORS_RELAXED_CHECKED2

#define ACCESSORS_RELAXED_CHECKED

#define ACCESSORS_RELAXED

// Similar to ACCESSORS_RELAXED above but with respective relaxed tags.
#define RELAXED_ACCESSORS_CHECKED2

#define RELAXED_ACCESSORS_CHECKED

#define RELAXED_ACCESSORS

#define RELEASE_ACQUIRE_GETTER_CHECKED(holder, name, type, offset,          \
                                       get_condition)

#define RELEASE_ACQUIRE_SETTER_CHECKED(holder, name, type, offset, \
                                       set_condition)

#define RELEASE_ACQUIRE_ACCESSORS_CHECKED2

#define RELEASE_ACQUIRE_ACCESSORS_CHECKED

#define RELEASE_ACQUIRE_ACCESSORS

#define WEAK_ACCESSORS_CHECKED2

#define WEAK_ACCESSORS_CHECKED

#define WEAK_ACCESSORS

#define RELEASE_ACQUIRE_WEAK_ACCESSORS_CHECKED2

#define RELEASE_ACQUIRE_WEAK_ACCESSORS_CHECKED

#define RELEASE_ACQUIRE_WEAK_ACCESSORS

// Getter that returns a Smi as an int and writes an int as a Smi.
#define SMI_ACCESSORS_CHECKED

#define SMI_ACCESSORS

#define DECL_RELEASE_ACQUIRE_INT_ACCESSORS

#define RELEASE_ACQUIRE_SMI_ACCESSORS

#define DECL_RELAXED_INT_ACCESSORS(name)

#define RELAXED_SMI_ACCESSORS

#define BOOL_GETTER

#define BOOL_ACCESSORS

#define DECL_RELAXED_BOOL_ACCESSORS

#define RELAXED_BOOL_ACCESSORS

// Host objects in ReadOnlySpace can't define the isolate-less accessor.
#define DECL_EXTERNAL_POINTER_ACCESSORS_MAYBE_READ_ONLY_HOST

// Host objects in ReadOnlySpace can't define the isolate-less accessor.
#define EXTERNAL_POINTER_ACCESSORS_MAYBE_READ_ONLY_HOST

#define DECL_EXTERNAL_POINTER_ACCESSORS

#define EXTERNAL_POINTER_ACCESSORS

#define DECL_TRUSTED_POINTER_GETTERS(name, type)

#define DECL_TRUSTED_POINTER_SETTERS(name, type)

#define DECL_TRUSTED_POINTER_ACCESSORS(name, type)

#define TRUSTED_POINTER_ACCESSORS(holder, name, type, offset, tag)

#define DECL_CODE_POINTER_ACCESSORS(name)
#define CODE_POINTER_ACCESSORS(holder, name, offset)

// Accessors for "protected" pointers, i.e. references from one trusted object
// to another trusted object. For these pointers it can be assumed that neither
// the pointer nor the pointed-to object can be manipulated by an attacker.
#define DECL_PROTECTED_POINTER_ACCESSORS(name, type)

#define PROTECTED_POINTER_ACCESSORS(holder, name, type, offset)

#define DECL_RELEASE_ACQUIRE_PROTECTED_POINTER_ACCESSORS(name, type)

#define RELEASE_ACQUIRE_PROTECTED_POINTER_ACCESSORS(holder, name, type,      \
                                                    offset)

#define BIT_FIELD_ACCESSORS2

#define BIT_FIELD_ACCESSORS

#define RELAXED_INT16_ACCESSORS

#define FIELD_ADDR

#define SEQ_CST_READ_FIELD

#define ACQUIRE_READ_FIELD

#define RELAXED_READ_FIELD

#define RELAXED_READ_WEAK_FIELD

#define WRITE_FIELD

#define SEQ_CST_WRITE_FIELD

#define RELEASE_WRITE_FIELD

#define RELAXED_WRITE_FIELD

#define RELAXED_WRITE_WEAK_FIELD

#define SEQ_CST_SWAP_FIELD(p, offset, value)

#define SEQ_CST_COMPARE_AND_SWAP_FIELD(p, offset, expected, value)

#ifdef V8_DISABLE_WRITE_BARRIERS
#define WRITE_BARRIER
#define WRITE_BARRIER_CPP
#else
#define WRITE_BARRIER
#endif

#ifdef V8_DISABLE_WRITE_BARRIERS
#define WEAK_WRITE_BARRIER
#else
#define WEAK_WRITE_BARRIER
#endif

#ifdef V8_DISABLE_WRITE_BARRIERS
#define EPHEMERON_KEY_WRITE_BARRIER
#elif V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS
#define EPHEMERON_KEY_WRITE_BARRIER
#else
#define EPHEMERON_KEY_WRITE_BARRIER
#endif

#ifdef V8_DISABLE_WRITE_BARRIERS
#define INDIRECT_POINTER_WRITE_BARRIER
#else
#define INDIRECT_POINTER_WRITE_BARRIER(object, offset, tag, value)
#endif

#ifdef V8_DISABLE_WRITE_BARRIERS
#define JS_DISPATCH_HANDLE_WRITE_BARRIER
#else
#define JS_DISPATCH_HANDLE_WRITE_BARRIER(object, handle)
#endif

#ifdef V8_DISABLE_WRITE_BARRIERS
#define CONDITIONAL_WRITE_BARRIER
#elif V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS
#define CONDITIONAL_WRITE_BARRIER
#else
#define CONDITIONAL_WRITE_BARRIER
#endif

#ifdef V8_DISABLE_WRITE_BARRIERS
#define CONDITIONAL_WEAK_WRITE_BARRIER
#elif V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS
#define CONDITIONAL_WEAK_WRITE_BARRIER
#else
#define CONDITIONAL_WEAK_WRITE_BARRIER
#endif

#ifdef V8_DISABLE_WRITE_BARRIERS
#define CONDITIONAL_EPHEMERON_KEY_WRITE_BARRIER
#else
#define CONDITIONAL_EPHEMERON_KEY_WRITE_BARRIER
#endif

#ifdef V8_DISABLE_WRITE_BARRIERS
#define CONDITIONAL_INDIRECT_POINTER_WRITE_BARRIER
#else
#define CONDITIONAL_INDIRECT_POINTER_WRITE_BARRIER(object, offset, tag, value, \
                                                   mode)
#endif

#ifdef V8_ENABLE_SANDBOX
#define CONDITIONAL_TRUSTED_POINTER_WRITE_BARRIER(object, offset, tag, value, \
                                                  mode)
#else
#define CONDITIONAL_TRUSTED_POINTER_WRITE_BARRIER
#endif  // V8_ENABLE_SANDBOX
#define CONDITIONAL_CODE_POINTER_WRITE_BARRIER(object, offset, value, mode)

#define CONDITIONAL_PROTECTED_POINTER_WRITE_BARRIER(object, offset, value, \
                                                    mode)

#ifdef V8_DISABLE_WRITE_BARRIERS
#define CONDITIONAL_JS_DISPATCH_HANDLE_WRITE_BARRIER
#else
#define CONDITIONAL_JS_DISPATCH_HANDLE_WRITE_BARRIER(object, handle, mode)
#endif

#define ACQUIRE_READ_INT8_FIELD

#define ACQUIRE_READ_INT32_FIELD

#define RELAXED_WRITE_INT8_FIELD
#define RELAXED_READ_INT8_FIELD

#define RELAXED_WRITE_UINT8_FIELD(p, offset, value)
#define RELAXED_READ_UINT8_FIELD(p, offset)

#define RELAXED_READ_UINT16_FIELD

#define RELAXED_WRITE_UINT16_FIELD

#define RELAXED_READ_INT16_FIELD

#define RELAXED_WRITE_INT16_FIELD

#define RELAXED_READ_UINT32_FIELD

#define ACQUIRE_READ_UINT32_FIELD

#define RELAXED_WRITE_UINT32_FIELD

#define RELEASE_WRITE_INT8_FIELD

#define RELEASE_WRITE_UINT32_FIELD

#define RELAXED_READ_INT32_FIELD

#if defined(V8_HOST_ARCH_64_BIT)
#define RELAXED_READ_INT64_FIELD(p, offset)
#endif

#define RELEASE_WRITE_INT32_FIELD

#define RELAXED_WRITE_INT32_FIELD

static_assert;

#define RELAXED_READ_INT_FIELD

#define RELAXED_WRITE_INT_FIELD

static_assert;

#define RELAXED_READ_UINT_FIELD

#define RELAXED_WRITE_UINT_FIELD

#define RELAXED_READ_BYTE_FIELD

#define ACQUIRE_READ_BYTE_FIELD

#define RELAXED_WRITE_BYTE_FIELD

#define RELEASE_WRITE_BYTE_FIELD

#ifdef OBJECT_PRINT
#define DECL_PRINTER
#else
#define DECL_PRINTER
#endif

#ifdef VERIFY_HEAP
#define DECL_VERIFIER
#define EXPORT_DECL_VERIFIER
#define DECL_STATIC_VERIFIER(Name)
#define EXPORT_DECL_STATIC_VERIFIER(Name)
#else
#define DECL_VERIFIER
#define EXPORT_DECL_VERIFIER
#define DECL_STATIC_VERIFIER
#define EXPORT_DECL_STATIC_VERIFIER
#endif

#define DEFINE_DEOPT_ELEMENT_ACCESSORS

#define DEFINE_DEOPT_ENTRY_ACCESSORS

#define TQ_OBJECT_CONSTRUCTORS

#define TQ_OBJECT_CONSTRUCTORS_IMPL

#define TQ_CPP_OBJECT_DEFINITION_ASSERTS