From 45bc94e9639c38bedf44f8e0d0aaa441a080b796 Mon Sep 17 00:00:00 2001 From: "tanzirui@huawei.com" Date: Sun, 10 Aug 2025 23:18:08 -0700 Subject: [PATCH] Revert "baseline bl opt" This reverts commit 2a829a7932b1769889eb130916a8ff0a9e197978. Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICSD31?from=project-issue Change-Id: I0c05d6ae482e00cdcf8d1c1f14720fd1a61d5709 Signed-off-by: tanzirui@huawei.com --- BUILD.gn | 1 - .../assembler/aarch64/assembler_aarch64.cpp | 2 +- .../assembler/aarch64/assembler_aarch64.h | 2 +- .../aarch64/macro_assembler_aarch64.cpp | 3 -- .../aarch64/macro_assembler_aarch64.h | 6 --- ecmascript/compiler/assembler/assembler.h | 24 ---------- .../compiler/assembler/macro_assembler.h | 2 - .../assembler/x64/macro_assembler_x64.h | 5 --- .../compiler/baseline/baseline_assembler.h | 5 --- .../compiler/baseline/baseline_compiler.cpp | 12 +---- .../compiler/baseline/baseline_compiler.h | 2 - ecmascript/compiler/file_generators.cpp | 9 +--- ecmascript/compiler/jit_compiler.cpp | 11 +---- ecmascript/compiler/jit_compiler.h | 3 +- ecmascript/jit/jit_task.cpp | 4 +- ecmascript/jit/jit_task.h | 6 --- ecmascript/jit/rewriter/reloc_rewriter.h | 31 ------------- .../jit/rewriter/reloc_rewriter_aarch64.cpp | 44 ------------------- .../jit/rewriter/reloc_rewriter_aarch64.h | 35 --------------- ecmascript/mem/dyn_chunk.h | 5 --- ecmascript/mem/machine_code.cpp | 15 ++----- ecmascript/mem/machine_code.h | 12 +---- ecmascript/object_factory.cpp | 8 ++-- ecmascript/object_factory.h | 5 +-- ecmascript/tests/machine_code_test.cpp | 12 ++--- libark_jsruntime.map | 1 - 26 files changed, 23 insertions(+), 242 deletions(-) delete mode 100644 ecmascript/jit/rewriter/reloc_rewriter.h delete mode 100644 ecmascript/jit/rewriter/reloc_rewriter_aarch64.cpp delete mode 100644 ecmascript/jit/rewriter/reloc_rewriter_aarch64.h diff --git a/BUILD.gn b/BUILD.gn index 7a00f3610d..148345e496 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -922,7 +922,6 @@ ecma_source = [ "ecmascript/interpreter/interpreter-inl.cpp", "ecmascript/interpreter/slow_runtime_stub.cpp", "ecmascript/intl/locale_helper.cpp", - "ecmascript/jit/rewriter/reloc_rewriter_aarch64.cpp", "ecmascript/jit/compile_decision.cpp", "ecmascript/jit/jit.cpp", "ecmascript/jit/jit_dfx.cpp", diff --git a/ecmascript/compiler/assembler/aarch64/assembler_aarch64.cpp b/ecmascript/compiler/assembler/aarch64/assembler_aarch64.cpp index f212d7daf3..6bc9cda990 100644 --- a/ecmascript/compiler/assembler/aarch64/assembler_aarch64.cpp +++ b/ecmascript/compiler/assembler/aarch64/assembler_aarch64.cpp @@ -926,7 +926,7 @@ void AssemblerAarch64::Bl(Label *label) Bl(offsetImm); } -void AssemblerAarch64::Bl(intptr_t imm) +void AssemblerAarch64::Bl(int32_t imm) { uint32_t code = CallOpCode::BL | ((imm << BRANCH_Imm26_LOWBITS) & BRANCH_Imm26_MASK); EmitU32(code); diff --git a/ecmascript/compiler/assembler/aarch64/assembler_aarch64.h b/ecmascript/compiler/assembler/aarch64/assembler_aarch64.h index e6a39e3e13..8e84f4e87d 100644 --- a/ecmascript/compiler/assembler/aarch64/assembler_aarch64.h +++ b/ecmascript/compiler/assembler/aarch64/assembler_aarch64.h @@ -339,7 +339,7 @@ public: void Br(const Register &rn); void Blr(const Register &rn); void Bl(Label *label); - void Bl(intptr_t imm); + void Bl(int32_t imm); void Cbz(const Register &rt, int32_t imm); void Cbz(const Register &rt, Label *label); void Cbnz(const Register &rt, int32_t imm); diff --git a/ecmascript/compiler/assembler/aarch64/macro_assembler_aarch64.cpp b/ecmascript/compiler/assembler/aarch64/macro_assembler_aarch64.cpp index f4bddfd957..a533e0a0ce 100644 --- a/ecmascript/compiler/assembler/aarch64/macro_assembler_aarch64.cpp +++ b/ecmascript/compiler/assembler/aarch64/macro_assembler_aarch64.cpp @@ -97,11 +97,8 @@ void MacroAssemblerAArch64::CallBuiltin(Address funcAddress, } MovParameterIntoParamReg(param, registerParamVec[i]); } - size_t startPc = assembler.GetCurPos(); assembler.Mov(LOCAL_SCOPE_REGISTER, aarch64::Immediate(funcAddress)); assembler.Blr(LOCAL_SCOPE_REGISTER); - size_t endPc = assembler.GetCurPos() - INSTRUCT_SIZE; - assembler.RecordRelocInfo(startPc, endPc, funcAddress); } void MacroAssemblerAArch64::SaveReturnRegister(const StackSlotOperand &dstStackSlot) diff --git a/ecmascript/compiler/assembler/aarch64/macro_assembler_aarch64.h b/ecmascript/compiler/assembler/aarch64/macro_assembler_aarch64.h index 0475a3c88c..34fc32f296 100644 --- a/ecmascript/compiler/assembler/aarch64/macro_assembler_aarch64.h +++ b/ecmascript/compiler/assembler/aarch64/macro_assembler_aarch64.h @@ -39,11 +39,6 @@ public: assembler.SetDoCodeSign(); } - RelocMap &GetRelocInfo() override - { - return assembler.GetRelocInfo(); - } - void Move(const StackSlotOperand &dstStackSlot, Immediate value) override; void Move(const StackSlotOperand &dstStackSlot, const StackSlotOperand &srcStackSlot) override; void Cmp(const StackSlotOperand &stackSlot, Immediate value) override; @@ -58,7 +53,6 @@ public: private: aarch64::AssemblerAarch64 assembler; const uint32_t PARAM_REGISTER_COUNT = 8; - static const int INSTRUCT_SIZE = 4; const std::vector registerParamVec { aarch64::Register(aarch64::X0), aarch64::Register(aarch64::X1), aarch64::Register(aarch64::X2), aarch64::Register(aarch64::X3), aarch64::Register(aarch64::X4), aarch64::Register(aarch64::X5), diff --git a/ecmascript/compiler/assembler/assembler.h b/ecmascript/compiler/assembler/assembler.h index 6333a62213..5107df8f05 100644 --- a/ecmascript/compiler/assembler/assembler.h +++ b/ecmascript/compiler/assembler/assembler.h @@ -26,14 +26,6 @@ namespace panda::ecmascript { #ifdef JIT_ENABLE_CODE_SIGN using namespace OHOS::Security::CodeSign; #endif - -using RelocMap = std::vector; -struct RelocInfo { - intptr_t startPc; - intptr_t endPc; - intptr_t dest; -}; - enum class Triple { TRIPLE_AMD64, TRIPLE_AARCH64, @@ -307,25 +299,9 @@ public: doCodeSign = true; } - RelocMap &GetRelocInfo() - { - return relocInfo_; - } - - void RecordRelocInfo(intptr_t startPc, intptr_t endPc, intptr_t imm) - { - relocInfo_.push_back({startPc, endPc, imm}); - } - - size_t GetCurPos() - { - return buffer_.GetSize(); - } - private: DynChunk buffer_; bool doCodeSign = false; - RelocMap relocInfo_; }; } // panda::ecmascript #endif // ECMASCRIPT_COMPILER_ASSEMBLER_H diff --git a/ecmascript/compiler/assembler/macro_assembler.h b/ecmascript/compiler/assembler/macro_assembler.h index ea75244b4d..6a81c49891 100644 --- a/ecmascript/compiler/assembler/macro_assembler.h +++ b/ecmascript/compiler/assembler/macro_assembler.h @@ -72,7 +72,6 @@ public: MacroAssembler() : allocator(NativeAreaAllocator()), chunk(&allocator) {} virtual ~MacroAssembler() = default; virtual uint8_t *GetBegin() const = 0; - virtual RelocMap &GetRelocInfo() = 0; virtual size_t GetBufferCurrentSize() const = 0; virtual void Move(const StackSlotOperand &dstStackSlot, Immediate value) = 0; virtual void Move(const StackSlotOperand &dstStackSlot, @@ -91,6 +90,5 @@ protected: Chunk chunk; static constexpr int32_t FUNCTION_OFFSET_FROM_SP = -72; // 72: includes 9 slots }; - } // namespace panda::ecmascript::kungfu #endif // ECMASCRIPT_COMPILER_ASSEMBLER_MACRO_ASSEMBLER_H diff --git a/ecmascript/compiler/assembler/x64/macro_assembler_x64.h b/ecmascript/compiler/assembler/x64/macro_assembler_x64.h index b390aef7a6..28c358cbd5 100644 --- a/ecmascript/compiler/assembler/x64/macro_assembler_x64.h +++ b/ecmascript/compiler/assembler/x64/macro_assembler_x64.h @@ -34,11 +34,6 @@ public: return assembler.GetCurrentPosition(); } - RelocMap &GetRelocInfo() override - { - return assembler.GetRelocInfo(); - } - void Move(const StackSlotOperand &dstStackSlot, Immediate value) override; void Move(const StackSlotOperand &dstStackSlot, const StackSlotOperand &srcStackSlot) override; void Cmp(const StackSlotOperand &stackSlot, Immediate value) override; diff --git a/ecmascript/compiler/baseline/baseline_assembler.h b/ecmascript/compiler/baseline/baseline_assembler.h index 8428eff90a..7a9f60fb4c 100644 --- a/ecmascript/compiler/baseline/baseline_assembler.h +++ b/ecmascript/compiler/baseline/baseline_assembler.h @@ -85,11 +85,6 @@ public: return macroAssembler->GetBegin(); } - RelocMap &GetRelocInfo() const - { - return macroAssembler->GetRelocInfo(); - } - size_t GetBufferSize() const { return macroAssembler->GetBufferCurrentSize(); diff --git a/ecmascript/compiler/baseline/baseline_compiler.cpp b/ecmascript/compiler/baseline/baseline_compiler.cpp index e505813c3b..ce8187ef43 100644 --- a/ecmascript/compiler/baseline/baseline_compiler.cpp +++ b/ecmascript/compiler/baseline/baseline_compiler.cpp @@ -184,11 +184,6 @@ bool BaselineCompiler::CollectMemoryCodeInfos(MachineCodeDesc &codeDesc) codeDesc.codeType = MachineCodeType::BASELINE_CODE; codeDesc.stackMapOrOffsetTableAddr = reinterpret_cast(nativePcOffsetTable.GetData()); codeDesc.stackMapOrOffsetTableSize = nativePcOffsetTable.GetSize(); - if (vm->GetJSOptions().GetTargetTriple() == TARGET_AARCH64) { - codeDesc.archType = MachineCodeArchType::AArch64; - } else { - codeDesc.archType = MachineCodeArchType::X86; - } #ifdef JIT_ENABLE_CODE_SIGN codeDesc.codeSigner = 0; JitSignCode *singleton = JitSignCode::GetInstance(); @@ -199,17 +194,12 @@ bool BaselineCompiler::CollectMemoryCodeInfos(MachineCodeDesc &codeDesc) } #endif if (Jit::GetInstance()->IsEnableJitFort() && Jit::GetInstance()->IsEnableAsyncCopyToFort() && - JitCompiler::AllocFromFortAndCopy(*compilationEnv, codeDesc, GetBaselineAssembler().GetRelocInfo()) == false) { + JitCompiler::AllocFromFortAndCopy(*compilationEnv, codeDesc) == false) { return false; } return true; } -void BaselineCompiler::CollectBLInfo(RelocMap &relocInfo) -{ - relocInfo = GetBaselineAssembler().GetRelocInfo(); -} - void BaselineCompiler::GetJumpToOffsets(const uint8_t *start, const uint8_t *end, std::unordered_set &jumpToOffsets) const { diff --git a/ecmascript/compiler/baseline/baseline_compiler.h b/ecmascript/compiler/baseline/baseline_compiler.h index 6378ef5205..6b9fcbc56c 100644 --- a/ecmascript/compiler/baseline/baseline_compiler.h +++ b/ecmascript/compiler/baseline/baseline_compiler.h @@ -83,8 +83,6 @@ public: bool CollectMemoryCodeInfos(MachineCodeDesc &codeDesc); - void CollectBLInfo(RelocMap &relocInfo); - void SetPfHeaderAddr(const JSPandaFile *jsPandaFile); void GetJumpToOffsets(const uint8_t *start, const uint8_t *end, std::unordered_set &jumpToOffsets) const; diff --git a/ecmascript/compiler/file_generators.cpp b/ecmascript/compiler/file_generators.cpp index a7b3e3dfd2..88fe3b815a 100644 --- a/ecmascript/compiler/file_generators.cpp +++ b/ecmascript/compiler/file_generators.cpp @@ -761,16 +761,9 @@ bool AOTFileGenerator::GetMemoryCodeInfos(MachineCodeDesc &machineCodeDesc) machineCodeDesc.stackMapOrOffsetTableAddr = stackMapPtr; machineCodeDesc.stackMapOrOffsetTableSize = stackMapSize; machineCodeDesc.codeType = MachineCodeType::FAST_JIT_CODE; - if (cfg_.IsAArch64()) { - machineCodeDesc.archType = MachineCodeArchType::AArch64; - } else { - machineCodeDesc.archType = MachineCodeArchType::X86; - } - // modify relocating is only used in baselinjit. - RelocMap relocInfo = {}; if (Jit::GetInstance()->IsEnableJitFort() && Jit::GetInstance()->IsEnableAsyncCopyToFort() && - JitCompiler::AllocFromFortAndCopy(*compilationEnv_, machineCodeDesc, relocInfo) == false) { + JitCompiler::AllocFromFortAndCopy(*compilationEnv_, machineCodeDesc) == false) { return false; } return true; diff --git a/ecmascript/compiler/jit_compiler.cpp b/ecmascript/compiler/jit_compiler.cpp index 3f12222ff3..28c91bd330 100644 --- a/ecmascript/compiler/jit_compiler.cpp +++ b/ecmascript/compiler/jit_compiler.cpp @@ -15,8 +15,6 @@ #include "ecmascript/compiler/jit_compiler.h" -#include "ecmascript/jit/rewriter/reloc_rewriter.h" -#include "ecmascript/jit/rewriter/reloc_rewriter_aarch64.h" namespace panda::ecmascript::kungfu { @@ -158,7 +156,6 @@ bool JitCompilerTask::Finalize(JitTask *jitTask) return false; } if (compilerTier_.IsBaseLine()) { - baselineCompiler_->CollectBLInfo(jitTask->GetRelocInfo()); return baselineCompiler_->CollectMemoryCodeInfos(jitTask->GetMachineCodeDesc()); } jitCodeGenerator_->JitCreateLitecgModule(); @@ -208,8 +205,7 @@ static ARK_INLINE bool CopyCodeToFort(MachineCodeDesc &desc) return true; } -ARK_INLINE bool JitCompiler::AllocFromFortAndCopy(CompilationEnv &compilationEnv, - MachineCodeDesc &desc, RelocMap &relocInfo) +ARK_INLINE bool JitCompiler::AllocFromFortAndCopy(CompilationEnv &compilationEnv, MachineCodeDesc &desc) { ASSERT(compilationEnv.IsJitCompiler()); std::unique_ptr lock ; @@ -247,11 +243,6 @@ ARK_INLINE bool JitCompiler::AllocFromFortAndCopy(CompilationEnv &compilationEnv desc.instructionsAddr = mem; } - if (desc.archType == MachineCodeArchType::AArch64) { - kungfu::RelocWriterAArch64 reWriter; - reWriter.RewriteRelocInfo((uint8_t*)desc.codeAddr, (uint8_t*)desc.instructionsAddr, relocInfo); - } - if (!CopyCodeToFort(desc)) { return false; } diff --git a/ecmascript/compiler/jit_compiler.h b/ecmascript/compiler/jit_compiler.h index 305f87f66b..4eb6431e43 100644 --- a/ecmascript/compiler/jit_compiler.h +++ b/ecmascript/compiler/jit_compiler.h @@ -129,8 +129,7 @@ public: } void UpdatePassOptions(CompilationEnv *env); - static ARK_INLINE bool AllocFromFortAndCopy(CompilationEnv &compilationEnv, - MachineCodeDesc &desc, RelocMap &relocInfo); + static ARK_INLINE bool AllocFromFortAndCopy(CompilationEnv &compilationEnv, MachineCodeDesc &desc); private: JitCompilationOptions jitOptions_; CompilerLog log_; diff --git a/ecmascript/jit/jit_task.cpp b/ecmascript/jit/jit_task.cpp index 5b060a9bc8..56b3ebc309 100644 --- a/ecmascript/jit/jit_task.cpp +++ b/ecmascript/jit/jit_task.cpp @@ -310,10 +310,10 @@ void JitTask::InstallCode() return; } machineCodeObj = hostThread_->GetEcmaVM()->GetFactory()->SetMachineCodeObjectData( - machineCode, size, codeDesc_, methodHandle, relocInfo_); + machineCode, size, codeDesc_, methodHandle); } else { machineCodeObj = hostThread_->GetEcmaVM()->GetFactory()->NewMachineCodeObject( - size, codeDesc_, methodHandle, relocInfo_); + size, codeDesc_, methodHandle); } if (machineCodeObj.GetAddress() == ToUintPtr(nullptr)) { // skip install diff --git a/ecmascript/jit/jit_task.h b/ecmascript/jit/jit_task.h index 946583cdaa..60bf79a28b 100644 --- a/ecmascript/jit/jit_task.h +++ b/ecmascript/jit/jit_task.h @@ -128,11 +128,6 @@ public: return codeDesc_; } - RelocMap &GetRelocInfo() - { - return relocInfo_; - } - JSHandle GetJsFunction() const { return jsFunction_; @@ -319,7 +314,6 @@ private: std::atomic runState_; Mutex runStateMutex_; ConditionVariable runStateCondition_; - RelocMap relocInfo_; }; } // namespace panda::ecmascript #endif // ECMASCRIPT_JIT_TASK_H diff --git a/ecmascript/jit/rewriter/reloc_rewriter.h b/ecmascript/jit/rewriter/reloc_rewriter.h deleted file mode 100644 index 0be776355c..0000000000 --- a/ecmascript/jit/rewriter/reloc_rewriter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_COMPILER_RELOC_REWRITER_H -#define ECMASCRIPT_COMPILER_RELOC_REWRITER_H - -#include "ecmascript/ecma_vm.h" -#include "ecmascript/mem/native_area_allocator.h" - -namespace panda::ecmascript::kungfu { - -class RelocWriter { -public: - RelocWriter() {} - virtual ~RelocWriter() = default; -}; - -} // namespace panda::ecmascript::kungfu -#endif // ECMASCRIPT_COMPILER_RELOC_REWRITER_H \ No newline at end of file diff --git a/ecmascript/jit/rewriter/reloc_rewriter_aarch64.cpp b/ecmascript/jit/rewriter/reloc_rewriter_aarch64.cpp deleted file mode 100644 index e49420025e..0000000000 --- a/ecmascript/jit/rewriter/reloc_rewriter_aarch64.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ecmascript/jit/rewriter/reloc_rewriter_aarch64.h" -#include "ecmascript/compiler/assembler/aarch64/assembler_aarch64_constants.h" -#include - -namespace panda::ecmascript::kungfu { -using namespace panda::ecmascript; - -bool RelocWriterAArch64::RewriteRelocInfo(uint8_t *codeAddr, uint8_t *jitAllocAddr, RelocMap &relocInfo) -{ - for (auto [startPc, endPc, dest] : relocInfo) { - intptr_t distance = dest - (intptr_t) jitAllocAddr - endPc; - intptr_t imm = distance / 4; - if (distance > MAX_JUMP_SIZE || distance < -MAX_JUMP_SIZE) { - continue; - } else { - size_t numMovInstr = (endPc - startPc) / INSTRUCT_SIZE; - for (size_t i = 0; i < numMovInstr; i++) { - uint32_t nopInstr = aarch64::NopOpCode::Nop; - memcpy_s(codeAddr + startPc + i * INSTRUCT_SIZE, - INSTRUCT_SIZE, reinterpret_cast(&nopInstr), INSTRUCT_SIZE); - } - uint32_t blInstr = aarch64::CallOpCode::BL | ((imm << aarch64::BRANCH_Imm26_LOWBITS) & - aarch64::BRANCH_Imm26_MASK); - memcpy_s(codeAddr + endPc, INSTRUCT_SIZE, reinterpret_cast(&blInstr), INSTRUCT_SIZE); - } - } - return true; -} -} // namespace panda::ecmascript::kungfu diff --git a/ecmascript/jit/rewriter/reloc_rewriter_aarch64.h b/ecmascript/jit/rewriter/reloc_rewriter_aarch64.h deleted file mode 100644 index ab6081ddae..0000000000 --- a/ecmascript/jit/rewriter/reloc_rewriter_aarch64.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_COECMASCRIPT_COMPILER_ASSEMBLER_RELOC_REWRITER_AARCH64_RELOC_REWRITER_H -#define ECMASCRIPT_COECMASCRIPT_COMPILER_ASSEMBLER_RELOC_REWRITER_AARCH64_RELOC_REWRITER_H - -#include "ecmascript/compiler/assembler/assembler.h" -#include "ecmascript/ecma_vm.h" -#include "ecmascript/mem/native_area_allocator.h" -#include "ecmascript/jit/rewriter/reloc_rewriter.h" - -namespace panda::ecmascript::kungfu { - -class PUBLIC_API RelocWriterAArch64 : public RelocWriter { - static const int INSTRUCT_SIZE = 4; - static const int MAX_JUMP_SIZE = 128 * 1024 * 1024; - public: - bool PUBLIC_API RewriteRelocInfo(uint8_t *codeAddr, uint8_t *jitAllocAddr, RelocMap &relocInfo); - virtual ~RelocWriterAArch64() = default; -}; - -} // namespace panda::ecmascript::kungfu -#endif // ECMASCRIPT_COECMASCRIPT_COMPILER_ASSEMBLER_RELOC_REWRITER_AARCH64_RELOC_REWRITER_H \ No newline at end of file diff --git a/ecmascript/mem/dyn_chunk.h b/ecmascript/mem/dyn_chunk.h index 83d8b4d82b..632f98ce7a 100644 --- a/ecmascript/mem/dyn_chunk.h +++ b/ecmascript/mem/dyn_chunk.h @@ -137,11 +137,6 @@ public: return buf_; } - size_t GetCurrPos() const - { - return size_; - } - private: static constexpr size_t ALLOCATE_MULTIPLIER = 2; static constexpr size_t U16_SIZE = 2; diff --git a/ecmascript/mem/machine_code.cpp b/ecmascript/mem/machine_code.cpp index 79d31a7113..926b2ae940 100644 --- a/ecmascript/mem/machine_code.cpp +++ b/ecmascript/mem/machine_code.cpp @@ -17,8 +17,6 @@ #include "ecmascript/base/config.h" #include "ecmascript/compiler/aot_file/func_entry_des.h" #include "ecmascript/jit/jit.h" -#include "ecmascript/jit/rewriter/reloc_rewriter_aarch64.h" -#include "ecmascript/jit/rewriter/reloc_rewriter.h" #include "ecmascript/compiler/jit_compilation_env.h" #if ECMASCRIPT_ENABLE_CAST_CHECK #include "ecmascript/js_tagged_value-inl.h" @@ -140,12 +138,11 @@ bool MachineCode::SetNonText(const MachineCodeDesc &desc, EntityId methodId) return true; } -bool MachineCode::SetData(JSThread *thread, const MachineCodeDesc &desc, JSHandle &method, size_t dataSize, - RelocMap &relocInfo) +bool MachineCode::SetData(JSThread *thread, const MachineCodeDesc &desc, JSHandle &method, size_t dataSize) { DISALLOW_GARBAGE_COLLECTION; if (desc.codeType == MachineCodeType::BASELINE_CODE) { - return SetBaselineCodeData(thread, desc, method, dataSize, relocInfo); + return SetBaselineCodeData(thread, desc, method, dataSize); } if (desc.isHugeObj) { @@ -198,7 +195,7 @@ bool MachineCode::SetData(JSThread *thread, const MachineCodeDesc &desc, JSHandl } bool MachineCode::SetBaselineCodeData(JSThread *thread, const MachineCodeDesc &desc, - JSHandle &method, size_t dataSize, RelocMap &relocInfo) + JSHandle &method, size_t dataSize) { DISALLOW_GARBAGE_COLLECTION; @@ -226,12 +223,6 @@ bool MachineCode::SetBaselineCodeData(JSThread *thread, const MachineCodeDesc &d } uint8_t *pText = textStart; - // relocating for baselinejit opt - if (desc.archType == MachineCodeArchType::AArch64 && desc.codeType == MachineCodeType::BASELINE_CODE) { - kungfu::RelocWriterAArch64 reWriter; - reWriter.RewriteRelocInfo((uint8_t*)desc.codeAddr, pText, relocInfo); - } - if (!Jit::GetInstance()->IsEnableJitFort() || !Jit::GetInstance()->IsEnableAsyncCopyToFort() || !desc.isAsyncCompileMode) { if (MachineCodeCopyToCache(desc, pText) == false) { diff --git a/ecmascript/mem/machine_code.h b/ecmascript/mem/machine_code.h index ae0c9e1bc7..43777264dc 100644 --- a/ecmascript/mem/machine_code.h +++ b/ecmascript/mem/machine_code.h @@ -34,11 +34,6 @@ enum class MachineCodeType : uint8_t { FAST_JIT_CODE, }; -enum class MachineCodeArchType : uint8_t { - AArch64, - X86, -}; - struct MachineCodeDesc { uintptr_t rodataAddrBeforeText {0}; size_t rodataSizeBeforeText {0}; @@ -54,7 +49,6 @@ struct MachineCodeDesc { uintptr_t heapConstantTableAddr {0}; size_t heapConstantTableSize {0}; MachineCodeType codeType {MachineCodeType::FAST_JIT_CODE}; - MachineCodeArchType archType {MachineCodeArchType::X86}; #ifdef JIT_ENABLE_CODE_SIGN uintptr_t codeSigner {0}; #endif @@ -262,8 +256,7 @@ public: return GetInstructionsSize(); } - bool SetData(JSThread *thread, const MachineCodeDesc &desc, JSHandle &method, size_t dataSize, - RelocMap &relocInfo); + bool SetData(JSThread *thread, const MachineCodeDesc &desc, JSHandle &method, size_t dataSize); bool SetText(const MachineCodeDesc &desc); bool SetNonText(const MachineCodeDesc &desc, EntityId methodId); @@ -316,8 +309,7 @@ public: Barriers::SetPrimitive(this, OSR_EXECUTE_CNT_OFFSET, count); } private: - bool SetBaselineCodeData(JSThread *thread, const MachineCodeDesc &desc, JSHandle &method, - size_t dataSize, RelocMap &relocInfo); + bool SetBaselineCodeData(JSThread *thread, const MachineCodeDesc &desc, JSHandle &method, size_t dataSize); }; } // namespace panda::ecmascript #endif // ECMASCRIPT_MEM_MACHINE_CODE_H diff --git a/ecmascript/object_factory.cpp b/ecmascript/object_factory.cpp index 17ddd0bc90..511271546a 100644 --- a/ecmascript/object_factory.cpp +++ b/ecmascript/object_factory.cpp @@ -4345,24 +4345,24 @@ TaggedObject *ObjectFactory::NewMachineCodeObject(size_t length, } JSHandle ObjectFactory::NewMachineCodeObject(size_t length, - const MachineCodeDesc &desc, JSHandle &method, RelocMap &relocInfo) + const MachineCodeDesc &desc, JSHandle &method) { NewObjectHook(); TaggedObject *obj = heap_->AllocateMachineCodeObject( JSHClass::Cast(thread_->GlobalConstants()->GetMachineCodeClass().GetTaggedObject()), length + MachineCode::SIZE); - return SetMachineCodeObjectData(obj, length, desc, method, relocInfo); + return SetMachineCodeObjectData(obj, length, desc, method); } JSHandle ObjectFactory::SetMachineCodeObjectData(TaggedObject *obj, size_t length, - const MachineCodeDesc &desc, JSHandle &method, RelocMap &relocInfo) + const MachineCodeDesc &desc, JSHandle &method) { MachineCode *code = MachineCode::Cast(obj); if (code == nullptr) { LOG_FULL(FATAL) << "machine code cast failed"; UNREACHABLE(); } - if (code->SetData(thread_, desc, method, length, relocInfo)) { + if (code->SetData(thread_, desc, method, length)) { JSHandle codeObj(thread_, code); if (g_isEnableCMCGC) { uintptr_t start = code->GetText(); diff --git a/ecmascript/object_factory.h b/ecmascript/object_factory.h index 6460f3594b..f87895d5b2 100644 --- a/ecmascript/object_factory.h +++ b/ecmascript/object_factory.h @@ -615,9 +615,8 @@ public: uintptr_t NewSpaceBySnapshotAllocator(size_t size); TaggedObject *NewMachineCodeObject(size_t length, MachineCodeDesc &desc); JSHandle SetMachineCodeObjectData(TaggedObject *obj, size_t length, - const MachineCodeDesc &desc, JSHandle &method, RelocMap &relocInfo); - JSHandle NewMachineCodeObject(size_t length, const MachineCodeDesc &desc, - JSHandle &method, RelocMap &relocInfo); + const MachineCodeDesc &desc, JSHandle &method); + JSHandle NewMachineCodeObject(size_t length, const MachineCodeDesc &desc, JSHandle &method); JSHandle NewClassInfoExtractor(JSHandle method); JSHandle NewClassLiteral(); diff --git a/ecmascript/tests/machine_code_test.cpp b/ecmascript/tests/machine_code_test.cpp index 66487489f9..fcbaa557f7 100644 --- a/ecmascript/tests/machine_code_test.cpp +++ b/ecmascript/tests/machine_code_test.cpp @@ -50,14 +50,13 @@ HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest001) ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle func(thread->GetEcmaVM()->GetGlobalEnv()->GetArrayFunction()); JSHandle method(thread, func->GetMethod(thread)); - RelocMap relocInfo; MachineCodeDesc desc; desc.codeType = MachineCodeType::BASELINE_CODE; desc.instructionsSize = 100; desc.instructionsAddr = 1000; desc.stackMapSizeAlign = 100; TaggedObject *machineCode = factory->NewMachineCodeObject(100, desc); - factory->SetMachineCodeObjectData(machineCode, 100, desc, method, relocInfo); + factory->SetMachineCodeObjectData(machineCode, 100, desc, method); } HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest004) @@ -65,7 +64,6 @@ HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest004) ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle func(thread->GetEcmaVM()->GetGlobalEnv()->GetArrayFunction()); JSHandle method(thread, func->GetMethod(thread)); - RelocMap relocInfo; MachineCodeDesc desc; desc.codeType = MachineCodeType::FAST_JIT_CODE; desc.instructionsSize = 100; @@ -78,7 +76,7 @@ HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest004) Jit::GetInstance()->SetEnableJitFort(true); ASSERT_EQ(Jit::GetInstance()->IsEnableAsyncCopyToFort(), true); TaggedObject *machineCode = factory->NewMachineCodeObject(100, desc); - factory->SetMachineCodeObjectData(machineCode, 100, desc, method, relocInfo); + factory->SetMachineCodeObjectData(machineCode, 100, desc, method); } HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest006) @@ -86,7 +84,6 @@ HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest006) ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle func(thread->GetEcmaVM()->GetGlobalEnv()->GetArrayFunction()); JSHandle method(thread, func->GetMethod(thread)); - RelocMap relocInfo; MachineCodeDesc desc; desc.codeType = MachineCodeType::FAST_JIT_CODE; desc.instructionsSize = 100; @@ -107,7 +104,7 @@ HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest006) desc.stackMapOrOffsetTableAddr = reinterpret_cast(src); desc.funcEntryDesAddr = reinterpret_cast(src2); desc.funcEntryDesSize = 100; - ASSERT_EQ(code->SetData(thread, desc, method, 100, relocInfo), true); + ASSERT_EQ(code->SetData(thread, desc, method, 100), true); } HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest007) @@ -116,7 +113,6 @@ HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest007) JSHandle func(thread->GetEcmaVM()->GetGlobalEnv()->GetArrayFunction()); JSHandle method(thread, func->GetMethod(thread)); MachineCodeDesc desc; - RelocMap relocInfo; desc.codeType = MachineCodeType::FAST_JIT_CODE; desc.instructionsSize = 100; desc.instructionsAddr = 1000; @@ -136,7 +132,7 @@ HWTEST_F_L0(MachineCodeTest, SetMachineCodeObjectDataTest007) desc.stackMapOrOffsetTableAddr = reinterpret_cast(src); desc.funcEntryDesAddr = reinterpret_cast(src2); desc.funcEntryDesSize = 100; - ASSERT_EQ(code->SetData(thread, desc, method, -100, relocInfo), true); + ASSERT_EQ(code->SetData(thread, desc, method, -100), true); } HWTEST_F_L0(MachineCodeTest, SetText001) diff --git a/libark_jsruntime.map b/libark_jsruntime.map index 4afae32246..95c48e5bbc 100644 --- a/libark_jsruntime.map +++ b/libark_jsruntime.map @@ -366,7 +366,6 @@ panda::ecmascript::kungfu::ArkStackMapBuilder::Run*; panda::ecmascript::kungfu::PGOBCInfo::Record*; panda::ecmascript::SharedModuleManager::GetInstance*; - panda::ecmascript::kungfu::RelocWriterAArch64::*; panda::ecmascript::SharedModuleManager::TransferSModule*; panda::ecmascript::kungfu::PGOTypeManager::GetConstantPoolIDByMethodOffset*; panda::ecmascript::kungfu::PGOTypeManager::GetConstantPoolByMethodOffset*; -- Gitee