blob: 3eaf4a1acf788c86fc832cc89c3ab83ba954b005 [file] [log] [blame]
//===--- ReferenceCounting.h ------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_AST_REFERENCE_COUNTING_H
#define SWIFT_AST_REFERENCE_COUNTING_H
namespace swift {
/// The kind of reference counting implementation a heap object uses.
enum class ReferenceCounting : uint8_t {
/// The object uses native Swift reference counting.
Native,
/// The object uses ObjC reference counting.
///
/// When ObjC interop is enabled, native Swift class objects are also ObjC
/// reference counting compatible. Swift non-class heap objects are never
/// ObjC reference counting compatible.
///
/// Blocks are always ObjC reference counting compatible.
ObjC,
/// The object uses _Block_copy/_Block_release reference counting.
///
/// This is a strict subset of ObjC; all blocks are also ObjC reference
/// counting compatible. The block is assumed to have already been moved to
/// the heap so that _Block_copy returns the same object back.
Block,
/// The object has an unknown reference counting implementation.
///
/// This uses maximally-compatible reference counting entry points in the
/// runtime.
Unknown,
/// Cases prior to this one are binary-compatible with Unknown reference
/// counting.
LastUnknownCompatible = Unknown,
/// The object has an unknown reference counting implementation and
/// the reference value may contain extra bits that need to be masked.
///
/// This uses maximally-compatible reference counting entry points in the
/// runtime, with a masking layer on top. A bit inside the pointer is used
/// to signal native Swift refcounting.
Bridge,
/// The object uses ErrorType's reference counting entry points.
Error,
};
} // end namespace swift
#endif