|
|
|||
File indexing completed on 2026-05-10 08:43:51
0001 //===- AllocationActions.h -- JITLink allocation support calls -*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // Structures for making memory allocation support calls. 0010 // 0011 //===----------------------------------------------------------------------===// 0012 0013 #ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_ALLOCATIONACTIONS_H 0014 #define LLVM_EXECUTIONENGINE_ORC_SHARED_ALLOCATIONACTIONS_H 0015 0016 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h" 0017 #include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h" 0018 #include "llvm/Support/Memory.h" 0019 0020 #include <vector> 0021 0022 namespace llvm { 0023 namespace orc { 0024 namespace shared { 0025 0026 /// A pair of WrapperFunctionCalls, one to be run at finalization time, one to 0027 /// be run at deallocation time. 0028 /// 0029 /// AllocActionCallPairs should be constructed for paired operations (e.g. 0030 /// __register_ehframe and __deregister_ehframe for eh-frame registration). 0031 /// See comments for AllocActions for execution ordering. 0032 /// 0033 /// For unpaired operations one or the other member can be left unused, as 0034 /// AllocationActionCalls with an FnAddr of zero will be skipped. 0035 struct AllocActionCallPair { 0036 WrapperFunctionCall Finalize; 0037 WrapperFunctionCall Dealloc; 0038 }; 0039 0040 /// A vector of allocation actions to be run for this allocation. 0041 /// 0042 /// Finalize allocations will be run in order at finalize time. Dealloc 0043 /// actions will be run in reverse order at deallocation time. 0044 using AllocActions = std::vector<AllocActionCallPair>; 0045 0046 /// Returns the number of deallocaton actions in the given AllocActions array. 0047 /// 0048 /// This can be useful if clients want to pre-allocate room for deallocation 0049 /// actions with the rest of their memory. 0050 inline size_t numDeallocActions(const AllocActions &AAs) { 0051 return llvm::count_if( 0052 AAs, [](const AllocActionCallPair &P) { return !!P.Dealloc; }); 0053 } 0054 0055 /// Run finalize actions. 0056 /// 0057 /// If any finalize action fails then the corresponding dealloc actions will be 0058 /// run in reverse order (not including the deallocation action for the failed 0059 /// finalize action), and the error for the failing action will be returned. 0060 /// 0061 /// If all finalize actions succeed then a vector of deallocation actions will 0062 /// be returned. The dealloc actions should be run by calling 0063 /// runDeallocationActions. If this function succeeds then the AA argument will 0064 /// be cleared before the function returns. 0065 Expected<std::vector<WrapperFunctionCall>> 0066 runFinalizeActions(AllocActions &AAs); 0067 0068 /// Run deallocation actions. 0069 /// Dealloc actions will be run in reverse order (from last element of DAs to 0070 /// first). 0071 Error runDeallocActions(ArrayRef<WrapperFunctionCall> DAs); 0072 0073 using SPSAllocActionCallPair = 0074 SPSTuple<SPSWrapperFunctionCall, SPSWrapperFunctionCall>; 0075 0076 template <> 0077 class SPSSerializationTraits<SPSAllocActionCallPair, 0078 AllocActionCallPair> { 0079 using AL = SPSAllocActionCallPair::AsArgList; 0080 0081 public: 0082 static size_t size(const AllocActionCallPair &AAP) { 0083 return AL::size(AAP.Finalize, AAP.Dealloc); 0084 } 0085 0086 static bool serialize(SPSOutputBuffer &OB, 0087 const AllocActionCallPair &AAP) { 0088 return AL::serialize(OB, AAP.Finalize, AAP.Dealloc); 0089 } 0090 0091 static bool deserialize(SPSInputBuffer &IB, 0092 AllocActionCallPair &AAP) { 0093 return AL::deserialize(IB, AAP.Finalize, AAP.Dealloc); 0094 } 0095 }; 0096 0097 } // end namespace shared 0098 } // end namespace orc 0099 } // end namespace llvm 0100 0101 #endif // LLVM_EXECUTIONENGINE_ORC_SHARED_ALLOCATIONACTIONS_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|