From 3c33a8248ee9f262f6c793bedeac53286c1f6c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=80=9D=E7=9D=BF?= <20375038@buaa.edu.cn> Date: Tue, 19 Nov 2024 23:23:54 +0800 Subject: [PATCH] add mapleUT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB5DWB Signed-off-by: 吴思睿 <20375038@buaa.edu.cn> --- .../maple/test/maple_ir/intrinsics_test.cpp | 9 +++++++-- ecmascript/compiler/jit_compilation_env.cpp | 5 ++++- ecmascript/mem/jit_fort.cpp | 14 ++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ecmascript/compiler/codegen/maple/test/maple_ir/intrinsics_test.cpp b/ecmascript/compiler/codegen/maple/test/maple_ir/intrinsics_test.cpp index d1f32a432a..9fb61223b2 100644 --- a/ecmascript/compiler/codegen/maple/test/maple_ir/intrinsics_test.cpp +++ b/ecmascript/compiler/codegen/maple/test/maple_ir/intrinsics_test.cpp @@ -27,15 +27,20 @@ TEST(GetTypeFromArgTy_FUNC, t01) { struct IntrinDesc IntrinDesc_struc; IntrinArgType input_ls[] = {kArgTyVoid, kArgTyI8, kArgTyI16, kArgTyI32, kArgTyI64, kArgTyU8, - kArgTyU16, kArgTyU32, kArgTyU64, kArgTyU1, kArgTyPtr, kArgTyRef, + kArgTyU16, kArgTyU32, kArgTyU64, kArgTyU1, kArgTyA64, kArgTyF32, kArgTyF64}; + PrimType res_ls[] = { + PTY_void, PTY_i8, PTY_i16, PTY_i32, PTY_i64, PTY_u8, + PTY_u16, PTY_u32, PTY_u64, PTY_u1, + PTY_a64, PTY_f32, PTY_f64 + }; MIRType *mirtype_ptr; int n = sizeof(input_ls) / sizeof(input_ls[0]); for (int i = 0; i < n; i++) { mirtype_ptr = IntrinDesc_struc.GetTypeFromArgTy(input_ls[i]); ASSERT_TRUE(mirtype_ptr != nullptr); - mirtype_ptr->GetPrimType(); + EXPECT_EQ(mirtype_ptr->GetPrimType(), res_ls[i]); } } } // namespace diff --git a/ecmascript/compiler/jit_compilation_env.cpp b/ecmascript/compiler/jit_compilation_env.cpp index 12f9715a64..506999b39d 100644 --- a/ecmascript/compiler/jit_compilation_env.cpp +++ b/ecmascript/compiler/jit_compilation_env.cpp @@ -24,7 +24,10 @@ namespace panda::ecmascript { JitCompilationEnv::JitCompilationEnv(EcmaVM *jitVm, EcmaVM *jsVm, JSHandle &jsFunction) : CompilationEnv(jitVm), hostThread_(jsVm->GetJSThreadNoCheck()), jsFunction_(jsFunction) { - ptManager_ = hostThread_->GetCurrentEcmaContext()->GetPTManager(); + if (hostThread_ != nullptr && hostThread_->GetCurrentEcmaContext() != nullptr && + hostThread_->GetCurrentEcmaContext()->GetPTManager() != nullptr) { + ptManager_ = hostThread_->GetCurrentEcmaContext()->GetPTManager(); + } Method *method = Method::Cast(jsFunction->GetMethod().GetTaggedObject()); jsPandaFile_ = const_cast(method->GetJSPandaFile()); methodLiteral_ = method->GetMethodLiteral(); diff --git a/ecmascript/mem/jit_fort.cpp b/ecmascript/mem/jit_fort.cpp index 9e33a6de45..3736feb9d3 100644 --- a/ecmascript/mem/jit_fort.cpp +++ b/ecmascript/mem/jit_fort.cpp @@ -51,11 +51,17 @@ JitFort::~JitFort() { constexpr size_t numRegions = JIT_FORT_REG_SPACE_MAX / DEFAULT_REGION_SIZE; for (size_t i = 0; i < numRegions; i++) { - regions_[i]->DestroyFreeObjectSets(); - delete regions_[i]; + if (regions_[i] != nullptr) { + regions_[i]->DestroyFreeObjectSets(); + delete regions_[i]; + } + } + if (allocator_ != nullptr) { + delete allocator_; + } + if (memDescPool_ != nullptr) { + delete memDescPool_; } - delete allocator_; - delete memDescPool_; PageUnmap(jitFortMem_); }