mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 02:38:07 +08:00
[orc-rt] Add ResourceManager interface.
The ResourceManager interface can be used to implement ownership for resources allocated to JIT'd code, e.g. memory and metadata registrations (frame info, language runtime metadata, etc.). Resources can be *deallocated*, meaning that they should be cleaned up (memory released, registrations deregistered, etc.), or they can be *detached*, meaning that cleanup should be performed automatically when the ResourceManager itself is destroyed. The intent is to allow JIT'd code to continue running after the llvm::orc::ExecutionSession that produced it is disconnected / destroyed.
This commit is contained in:
@@ -12,6 +12,7 @@ set(ORC_RT_HEADERS
|
||||
orc-rt/IntervalSet.h
|
||||
orc-rt/Math.h
|
||||
orc-rt/MemoryFlags.h
|
||||
orc-rt/ResourceManager.h
|
||||
orc-rt/RTTI.h
|
||||
orc-rt/ScopeExit.h
|
||||
orc-rt/SimplePackedSerialization.h
|
||||
|
||||
44
orc-rt/include/orc-rt/ResourceManager.h
Normal file
44
orc-rt/include/orc-rt/ResourceManager.h
Normal file
@@ -0,0 +1,44 @@
|
||||
//===- ResourceManager.h -- Interface for JIT resource managers -*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// ResourceManager class and related APIs.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef ORC_RT_RESOURCEMANAGER_H
|
||||
#define ORC_RT_RESOURCEMANAGER_H
|
||||
|
||||
#include "orc-rt/Error.h"
|
||||
#include "orc-rt/move_only_function.h"
|
||||
|
||||
namespace orc_rt {
|
||||
|
||||
/// A ResourceManager manages resources (e.g. JIT'd memory) to support a JIT
|
||||
/// session.
|
||||
class ResourceManager {
|
||||
public:
|
||||
using OnCompleteFn = move_only_function<void(Error)>;
|
||||
|
||||
virtual ~ResourceManager();
|
||||
|
||||
/// The detach method will be called if the controller disconnects from the
|
||||
/// session without shutting the session down.
|
||||
///
|
||||
/// Since no further requests for allocation will be made, the ResourceManager
|
||||
/// may discard any book-keeping data-structures used to support allocation.
|
||||
/// E.g. a JIT memory manager may discard its free-list, since no further
|
||||
/// JIT'd allocations will happen.
|
||||
virtual void detach(OnCompleteFn OnComplete) = 0;
|
||||
|
||||
/// The shutdown operation will be called at the end of the session.
|
||||
/// The ResourceManager should release all held resources.
|
||||
virtual void shutdown(OnCompleteFn OnComplete) = 0;
|
||||
};
|
||||
} // namespace orc_rt
|
||||
|
||||
#endif // ORC_RT_RESOURCEMANAGER_H
|
||||
@@ -1,6 +1,7 @@
|
||||
set(files
|
||||
orc-rt-executor.cpp
|
||||
AllocAction.cpp
|
||||
ResourceManager.cpp
|
||||
RTTI.cpp
|
||||
)
|
||||
|
||||
|
||||
19
orc-rt/lib/executor/ResourceManager.cpp
Normal file
19
orc-rt/lib/executor/ResourceManager.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
//===- ResourceManager.cpp ------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Contains the implementation of APIs in the orc-rt/ResourceManager.h header.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "orc-rt/ResourceManager.h"
|
||||
|
||||
namespace orc_rt {
|
||||
|
||||
ResourceManager::~ResourceManager() = default;
|
||||
|
||||
} // namespace orc_rt
|
||||
Reference in New Issue
Block a user