aboutsummaryrefslogtreecommitdiff
path: root/clang/docs/Block-ABI-Apple.rst
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2018-07-20 17:10:32 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2018-07-20 17:10:32 +0000
commitdbfa453e4138bb977644929c69d1c71e5e8b4bee (patch)
treefd0755e09eefe0ed813945492b2886441d6e8334 /clang/docs/Block-ABI-Apple.rst
parentc358e51e9b9d42be542ae577d10b851e9358cd39 (diff)
downloadllvm-dbfa453e4138bb977644929c69d1c71e5e8b4bee.zip
llvm-dbfa453e4138bb977644929c69d1c71e5e8b4bee.tar.gz
llvm-dbfa453e4138bb977644929c69d1c71e5e8b4bee.tar.bz2
[CodeGen][ObjC] Make copying and disposing of a non-escaping block
no-ops. A non-escaping block on the stack will never be called after its lifetime ends, so it doesn't have to be copied to the heap. To prevent a non-escaping block from being copied to the heap, this patch sets field 'isa' of the block object to NSConcreteGlobalBlock and sets the BLOCK_IS_GLOBAL bit of field 'flags', which causes the runtime to treat the block as if it were a global block (calling _Block_copy on the block just returns the original block and calling _Block_release is a no-op). Also, a new flag bit 'BLOCK_IS_NOESCAPE' is added, which allows the runtime or tools to distinguish between true global blocks and non-escaping blocks. rdar://problem/39352313 Differential Revision: https://reviews.llvm.org/D49303 llvm-svn: 337580
Diffstat (limited to 'clang/docs/Block-ABI-Apple.rst')
-rw-r--r--clang/docs/Block-ABI-Apple.rst8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/docs/Block-ABI-Apple.rst b/clang/docs/Block-ABI-Apple.rst
index 7f49bbd..e48a24b 100644
--- a/clang/docs/Block-ABI-Apple.rst
+++ b/clang/docs/Block-ABI-Apple.rst
@@ -61,6 +61,14 @@ The following flags bits are in use thusly for a possible ABI.2010.3.16:
.. code-block:: c
enum {
+ // Set to true on blocks that have captures (and thus are not true
+ // global blocks) but are known not to escape for various other
+ // reasons. For backward compatiblity with old runtimes, whenever
+ // BLOCK_IS_NOESCAPE is set, BLOCK_IS_GLOBAL is set too. Copying a
+ // non-escaping block returns the original block and releasing such a
+ // block is a no-op, which is exactly how global blocks are handled.
+ BLOCK_IS_NOESCAPE = (1 << 23),
+
BLOCK_HAS_COPY_DISPOSE = (1 << 25),
BLOCK_HAS_CTOR = (1 << 26), // helpers have C++ code
BLOCK_IS_GLOBAL = (1 << 28),