[CP] [to #55730303] fix: fix a PL JIT core when memory is insufficient
This commit is contained in:
@ -352,7 +352,8 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ObLLVMHelper(common::ObIAllocator &allocator)
|
ObLLVMHelper(common::ObIAllocator &allocator)
|
||||||
: allocator_(allocator),
|
: is_inited_(false),
|
||||||
|
allocator_(allocator),
|
||||||
jc_(NULL),
|
jc_(NULL),
|
||||||
jit_(NULL) {}
|
jit_(NULL) {}
|
||||||
virtual ~ObLLVMHelper();
|
virtual ~ObLLVMHelper();
|
||||||
@ -457,6 +458,7 @@ private:
|
|||||||
static int init_llvm();
|
static int init_llvm();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool is_inited_;
|
||||||
common::ObIAllocator &allocator_;
|
common::ObIAllocator &allocator_;
|
||||||
core::JitContext *jc_;
|
core::JitContext *jc_;
|
||||||
core::ObOrcJit *jit_;
|
core::ObOrcJit *jit_;
|
||||||
|
@ -505,7 +505,10 @@ int ObLLVMHelper::init()
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
OB_LLVM_MALLOC_GUARD("PlJit");
|
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;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
LOG_WARN("failed to alloc memory for jit context", K(ret));
|
LOG_WARN("failed to alloc memory for jit context", K(ret));
|
||||||
#ifndef ORC2
|
#ifndef ORC2
|
||||||
@ -513,10 +516,24 @@ int ObLLVMHelper::init()
|
|||||||
#else
|
#else
|
||||||
} else if (nullptr == (jit_ = core::ObOrcJit::create(allocator_))) {
|
} else if (nullptr == (jit_ = core::ObOrcJit::create(allocator_))) {
|
||||||
#endif
|
#endif
|
||||||
|
jc_->~JitContext();
|
||||||
|
allocator_.free(jc_);
|
||||||
|
jc_ = nullptr;
|
||||||
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
LOG_WARN("failed to alloc memory for jit", K(ret));
|
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 {
|
} else {
|
||||||
jc_->InitializeModule(*jit_);
|
is_inited_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
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()
|
ObPLFunction::~ObPLFunction()
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
@ -227,18 +227,7 @@ class ObPLCompileUnit : public ObPLCacheObject
|
|||||||
{
|
{
|
||||||
friend class ::test::MockCacheObjectFactory;
|
friend class ::test::MockCacheObjectFactory;
|
||||||
public:
|
public:
|
||||||
ObPLCompileUnit(sql::ObLibCacheNameSpace ns, lib::MemoryContext &mem_context)
|
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
|
|
||||||
}
|
|
||||||
virtual ~ObPLCompileUnit();
|
virtual ~ObPLCompileUnit();
|
||||||
|
|
||||||
inline bool get_can_cached() { return can_cached_; }
|
inline bool get_can_cached() { return can_cached_; }
|
||||||
|
Reference in New Issue
Block a user