[CP] [to #55730303] fix: fix a PL JIT core when memory is insufficient
This commit is contained in:
parent
eed677c16e
commit
852f63a7b3
@ -352,7 +352,8 @@ public:
|
||||
|
||||
public:
|
||||
ObLLVMHelper(common::ObIAllocator &allocator)
|
||||
: allocator_(allocator),
|
||||
: is_inited_(false),
|
||||
allocator_(allocator),
|
||||
jc_(NULL),
|
||||
jit_(NULL) {}
|
||||
virtual ~ObLLVMHelper();
|
||||
@ -457,6 +458,7 @@ private:
|
||||
static int init_llvm();
|
||||
|
||||
private:
|
||||
bool is_inited_;
|
||||
common::ObIAllocator &allocator_;
|
||||
core::JitContext *jc_;
|
||||
core::ObOrcJit *jit_;
|
||||
|
@ -505,7 +505,10 @@ int ObLLVMHelper::init()
|
||||
int ret = OB_SUCCESS;
|
||||
OB_LLVM_MALLOC_GUARD("PlJit");
|
||||
|
||||
if (nullptr == (jc_ = OB_NEWx(core::JitContext, (&allocator_)))) {
|
||||
if (is_inited_) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("ObLLVMHelper has been inited", K(ret), K(lbt()));
|
||||
} else if (nullptr == (jc_ = OB_NEWx(core::JitContext, (&allocator_)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory for jit context", K(ret));
|
||||
#ifndef ORC2
|
||||
@ -513,10 +516,24 @@ int ObLLVMHelper::init()
|
||||
#else
|
||||
} else if (nullptr == (jit_ = core::ObOrcJit::create(allocator_))) {
|
||||
#endif
|
||||
jc_->~JitContext();
|
||||
allocator_.free(jc_);
|
||||
jc_ = nullptr;
|
||||
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory for jit", K(ret));
|
||||
} else if (OB_FAIL(jc_->InitializeModule(*jit_))) {
|
||||
jit_->~ObOrcJit();
|
||||
allocator_.free(jit_);
|
||||
jit_ = nullptr;
|
||||
|
||||
jc_->~JitContext();
|
||||
allocator_.free(jc_);
|
||||
jc_ = nullptr;
|
||||
|
||||
LOG_WARN("failed to initialize module", K(ret));
|
||||
} else {
|
||||
jc_->InitializeModule(*jit_);
|
||||
is_inited_ = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -4148,6 +4148,20 @@ void ObPLCompileUnit::dump_deleted_log_info(const bool is_debug_log /* = true */
|
||||
}
|
||||
}
|
||||
|
||||
ObPLCompileUnit::ObPLCompileUnit(sql::ObLibCacheNameSpace ns,
|
||||
lib::MemoryContext &mem_context)
|
||||
: ObPLCacheObject(ns, mem_context), routine_table_(allocator_),
|
||||
type_table_(), helper_(allocator_), di_helper_(allocator_),
|
||||
can_cached_(true)
|
||||
{
|
||||
#ifndef USE_MCJIT
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(helper_.init())) {
|
||||
LOG_WARN("failed to init llvm helper", K(ret), K(helper_.get_jc()));
|
||||
}
|
||||
#endif // USE_MCJIT
|
||||
}
|
||||
|
||||
ObPLFunction::~ObPLFunction()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -227,18 +227,7 @@ class ObPLCompileUnit : public ObPLCacheObject
|
||||
{
|
||||
friend class ::test::MockCacheObjectFactory;
|
||||
public:
|
||||
ObPLCompileUnit(sql::ObLibCacheNameSpace ns, lib::MemoryContext &mem_context)
|
||||
: ObPLCacheObject(ns, mem_context),
|
||||
routine_table_(allocator_),
|
||||
type_table_(),
|
||||
helper_(allocator_),
|
||||
di_helper_(allocator_),
|
||||
can_cached_(true)
|
||||
{
|
||||
#ifndef USE_MCJIT
|
||||
helper_.init();
|
||||
#endif
|
||||
}
|
||||
ObPLCompileUnit(sql::ObLibCacheNameSpace ns, lib::MemoryContext &mem_context);
|
||||
virtual ~ObPLCompileUnit();
|
||||
|
||||
inline bool get_can_cached() { return can_cached_; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user