JitFort space changed from singleton to instance per VM.

JitFort instance is created when a VM actually makes machine code
space allocation.

Signed-off-by: eching <edward.k.ching@gmail.com>
This commit is contained in:
eching 2024-06-25 12:45:58 +08:00
parent 63eab1965c
commit e4958d194f
16 changed files with 156 additions and 135 deletions

View File

@ -384,14 +384,16 @@ ohos_source_set("libark_jsoptimizer_set_with_maple") {
]
defines = []
external_deps = [ "zlib:libz" ]
if (enable_jit_code_sign) {
defines += [ "CODE_SIGN_ENABLE" ]
external_deps += [ "code_signature:libjit_code_sign" ]
if (disable_fort_switch) {
defines += [ "JIT_FORT_DISABLE" ]
}
}
external_deps = [ "zlib:libz" ]
deps = []
if (!is_arkui_x) {
external_deps += [ "runtime_core:arkfile_header_deps" ]
@ -401,9 +403,6 @@ ohos_source_set("libark_jsoptimizer_set_with_maple") {
# hiviewdfx libraries
external_deps += hiviewdfx_ext_deps
if (enable_jit_code_sign) {
external_deps += [ "code_signature:libjit_code_sign" ]
}
part_name = "ets_runtime"
subsystem_name = "arkcompiler"

View File

@ -31,11 +31,7 @@ include_directories = [
"${MAPLEALL_ROOT}/maple_phase/include",
]
if (enable_jit_code_sign) {
include_directories += [
"$code_sign_root/common/include",
"$code_sign_root/jit_code_sign/include",
"$js_root/ecmascript/compiler",
]
include_directories += [ "$js_root/ecmascript/compiler" ]
}
deps_libcg = [
@ -325,16 +321,14 @@ ohos_source_set("libcgaarch64") {
sources = src_libcgaarch64
include_dirs = include_directories
defines = []
external_deps = [ "bounds_checking_function:libsec_static" ]
if (enable_jit_code_sign) {
defines += [ "CODE_SIGN_ENABLE" ]
external_deps += [ "code_signature:libjit_code_sign" ]
if (disable_fort_switch) {
defines += [ "JIT_FORT_DISABLE" ]
}
}
external_deps = [ "bounds_checking_function:libsec_static" ]
if (enable_jit_code_sign) {
external_deps += [ "code_signature:libjit_code_sign" ]
}
part_name = "ets_runtime"
subsystem_name = "arkcompiler"
}

View File

@ -24,6 +24,7 @@
namespace panda::ecmascript {
class Region;
class BaseHeap;
class JitFort;
class Allocator {
public:
@ -91,6 +92,9 @@ public:
NO_MOVE_SEMANTIC(FreeListAllocator);
inline explicit FreeListAllocator(BaseHeap *heap);
#ifdef ENABLE_JITFORT
inline explicit FreeListAllocator(BaseHeap *heap, MemDescPool *pool, JitFort *fort);
#endif
inline void Initialize(Region *region);
inline void Reset(BaseHeap *heap);
@ -136,6 +140,7 @@ private:
#ifdef ENABLE_JITFORT
inline uintptr_t Allocate(T *object, size_t size);
std::unique_ptr<FreeObjectList<T>> freeList_ {nullptr};
MemDescPool *memDescPool_ {nullptr};
#else
inline uintptr_t Allocate(FreeObject *object, size_t size);
std::unique_ptr<FreeObjectList> freeList_ {nullptr};

View File

@ -39,6 +39,19 @@ FreeObjectList::FreeObjectList() : sets_(new FreeObjectSet *[NUMBER_OF_SETS](),
#ifdef ENABLE_JITFORT
template FreeObjectList<FreeObject>::FreeObjectList();
template FreeObjectList<MemDesc>::FreeObjectList();
template <>
FreeObjectList<MemDesc>::FreeObjectList(JitFort *fort)
: sets_(new FreeObjectSet<MemDesc> *[NUMBER_OF_SETS](), NUMBER_OF_SETS),
lastSets_(new FreeObjectSet<MemDesc> *[NUMBER_OF_SETS](), NUMBER_OF_SETS),
jitFort_(fort)
{
for (int i = 0; i < NUMBER_OF_SETS; i++) {
sets_[i] = nullptr;
lastSets_[i] = nullptr;
}
noneEmptySetBitMap_ = 0;
}
#endif
#ifdef ENABLE_JITFORT
@ -228,6 +241,7 @@ void FreeObjectList::Free(uintptr_t start, size_t size, bool isAdd)
}
}
}
#ifdef ENABLE_JITFORT
// template class instance for non JitFort space uses FreeObject and Region.
template void FreeObjectList<FreeObject>::Free(uintptr_t, size_t, bool);
@ -239,7 +253,7 @@ void FreeObjectList<MemDesc>::Free(uintptr_t start, size_t size, bool isAdd)
return;
}
if (UNLIKELY(size < MIN_SIZE)) {
JitFortRegion *region = JitFortRegion::ObjectAddressToRange(start);
JitFortRegion *region = jitFort_->ObjectAddressToRange(start);
region->IncreaseWasted(size);
if (isAdd) {
wasted_ += size;
@ -251,7 +265,7 @@ void FreeObjectList<MemDesc>::Free(uintptr_t start, size_t size, bool isAdd)
return;
}
JitFortRegion *region = JitFortRegion::ObjectAddressToRange(start);
JitFortRegion *region = jitFort_->ObjectAddressToRange(start);
auto set = region->GetFreeObjectSet(type);
if (set == nullptr) {
LOG_FULL(FATAL) << "The set of region is nullptr";

View File

@ -25,11 +25,15 @@
namespace panda::ecmascript {
#ifdef ENABLE_JITFORT
class JitFort;
template <typename T>
#endif
class FreeObjectList {
public:
FreeObjectList();
#ifdef ENABLE_JITFORT
FreeObjectList(JitFort *fort);
#endif
~FreeObjectList();
#ifdef ENABLE_JITFORT
@ -153,6 +157,7 @@ private:
#ifdef ENABLE_JITFORT
Span<FreeObjectSet<T> *> sets_ {};
Span<FreeObjectSet<T> *> lastSets_ {};
JitFort *jitFort_ {nullptr};
#else
Span<FreeObjectSet *> sets_ {};
Span<FreeObjectSet *> lastSets_ {};

View File

@ -43,10 +43,10 @@ template void FreeObjectSet<FreeObject>::Free(uintptr_t, size_t);
template <>
void FreeObjectSet<MemDesc>::Free(uintptr_t begin, size_t size)
{
ASSERT(begin >= JitFort::GetInstance()->JitFortBegin() &&
size <= JitFort::GetInstance()->JitFortSize());
ASSERT(begin >= memDescPool_->JitFortBegin() &&
size <= memDescPool_->JitFortSize());
auto freeObject = JitFort::GetInstance()->GetMemDescFromPool();
auto freeObject = memDescPool_->GetDescFromPool();
freeObject->SetMem(begin);
freeObject->SetSize(size);
freeObject->SetNext(freeObject_);
@ -81,7 +81,7 @@ void FreeObjectSet<MemDesc>::Rebuild()
while (!MemDescPool::IsEmpty(current)) {
// put desc back to free pool
auto next = current->GetNext();
JitFort::GetInstance()->ReturnMemDescToPool(current);
memDescPool_->ReturnDescToPool(current);
current = next;
}
freeObject_ = MemDesc::Cast(INVALID_OBJPTR);

View File

@ -40,6 +40,12 @@ public:
{
Rebuild();
}
#ifdef ENABLE_JITFORT
explicit FreeObjectSet(SetType type, MemDescPool *pool) : setType_(type), memDescPool_(pool)
{
Rebuild();
}
#endif
~FreeObjectSet() = default;
inline bool Empty() const
@ -81,7 +87,7 @@ private:
bool isAdded_ = false;
#ifdef ENABLE_JITFORT
T *freeObject_ = nullptr;
MemDescPool *memDescPool_ {nullptr};
friend class FreeObjectList<T>;
#else
FreeObject *freeObject_ = nullptr;

View File

@ -464,12 +464,6 @@ TaggedObject *Heap::AllocateMachineCodeObject(JSHClass *hclass, size_t size)
desc.instructionsAddr = 0;
if (size <= MAX_REGULAR_HEAP_OBJECT_SIZE) {
// for non huge code cache obj, allocate fort space before allocating the code object
if (machineCodeSpace_->sweepState_ == SweepState::SWEEPING) {
GetSweeper()->EnsureTaskFinished(MACHINE_CODE_SPACE);
LOG_JIT(DEBUG) << "Heap::AllocateMachineCode: MachineCode space sweep state = "
<< machineCodeSpace_->GetSweepState();
JitFort::GetInstance()->UpdateFreeSpace();
}
uintptr_t mem = machineCodeSpace_->JitFortAllocate(desc.instructionsSize);
if (mem == ToUintPtr(nullptr)) {
SetMachineCodeOutOfMemoryError(GetJSThread(), size, "Heap::JitFortAllocate");
@ -618,7 +612,7 @@ void Heap::ReclaimRegions(TriggerGCType gcType)
#ifdef ENABLE_JITFORT
// machinecode space is not sweeped in young GC
if (machineCodeSpace_->sweepState_ != SweepState::NO_SWEEP) {
JitFort::GetInstance()->UpdateFreeSpace();
machineCodeSpace_->UpdateFortSpace();
}
#endif
EnumerateNonNewSpaceRegionsWithRecord([] (Region *region) {

View File

@ -20,6 +20,13 @@
namespace panda::ecmascript {
template <>
FreeListAllocator<MemDesc>::FreeListAllocator(BaseHeap *heap, MemDescPool *pool, JitFort *fort)
: memDescPool_(pool), heap_(heap)
{
freeList_ = std::make_unique<FreeObjectList<MemDesc>>(fort);
}
template <>
uintptr_t FreeListAllocator<MemDesc>::Allocate(MemDesc *object, size_t size)
{
@ -27,7 +34,7 @@ uintptr_t FreeListAllocator<MemDesc>::Allocate(MemDesc *object, size_t size)
uintptr_t end = object->GetEnd();
uintptr_t remainSize = end - begin - size;
ASSERT(remainSize >= 0);
JitFort::GetInstance()->ReturnMemDescToPool(object);
memDescPool_->ReturnDescToPool(object);
// Keep a longest freeObject between bump-pointer and free object that just allocated
allocationSizeAccumulator_ += size;
@ -64,8 +71,8 @@ JitFort::JitFort()
jitFortMem_ = PageMap(JIT_FORT_REG_SPACE_MAX, PAGE_PROT_EXEC_READWRITE, DEFAULT_REGION_SIZE, nullptr, MAP_JITFORT);
jitFortBegin_ = reinterpret_cast<uintptr_t>(jitFortMem_.GetMem());
jitFortSize_ = JIT_FORT_REG_SPACE_MAX;
memDescPool_ = new MemDescPool();
allocator_ = new FreeListAllocator<MemDesc>(nullptr);
memDescPool_ = new MemDescPool(jitFortBegin_, jitFortSize_);
allocator_ = new FreeListAllocator<MemDesc>(nullptr, memDescPool_, this);
InitRegions();
LOG_JIT(DEBUG) << "JitFort Begin " << (void *)JitFortBegin() << " end " << (void *)(JitFortBegin() + JitFortSize());
}
@ -83,7 +90,8 @@ void JitFort::InitRegions()
for (auto i = 0; i < numRegions; i++) {
uintptr_t mem = reinterpret_cast<uintptr_t>(jitFortMem_.GetMem()) + i*DEFAULT_REGION_SIZE;
uintptr_t end = mem + DEFAULT_REGION_SIZE;
JitFortRegion *region = new JitFortRegion(nullptr, mem, end, RegionSpaceFlag::IN_MACHINE_CODE_SPACE);
JitFortRegion *region = new JitFortRegion(nullptr, mem, end, RegionSpaceFlag::IN_MACHINE_CODE_SPACE,
memDescPool_);
region->InitializeFreeObjectSets();
regions_[i] = region;
}
@ -103,6 +111,8 @@ bool JitFort::AddRegion()
uintptr_t JitFort::Allocate(size_t size)
{
LockHolder lock(mutex_);
auto ret = allocator_->Allocate(size);
if (ret == ToUintPtr(nullptr)) {
if (AddRegion()) {
@ -118,7 +128,14 @@ uintptr_t JitFort::Allocate(size_t size)
void JitFort::RecordLiveJitCode(uintptr_t addr, size_t size)
{
LockHolder lock(liveJitCodeBlksLock_);
MemDesc *desc = GetMemDescFromPool();
// check duplicate
for (size_t i = 0; i < liveJitCodeBlks_.size(); ++i) {
if (liveJitCodeBlks_[i]->GetBegin() == addr && liveJitCodeBlks_[i]->Available() == size) {
LOG_JIT(DEBUG) << "RecordLiveJitCode duplicate " << (void *)addr << " size " << size;
return;
}
}
MemDesc *desc = memDescPool_->GetDescFromPool();
desc->SetMem(addr);
desc->SetSize(size);
liveJitCodeBlks_.emplace_back(desc);
@ -133,16 +150,6 @@ void JitFort::SortLiveMemDescList()
}
}
// Called by concurrent sweep in PrepareSweep() and non-concurent sweep in Sweep()
void JitFort::RebuildFreeList()
{
// disable Fort collection for now - temporary until collection bug fixed
return;
freeListUpdated_ = false;
allocator_->RebuildFreeList();
}
/*
* UpdateFreeSpace updates JitFort allocator free object list by go through mem blocks
* in use (liveJitCodeBlks_) in Jit fort space and putting free space in between into
@ -159,25 +166,23 @@ void JitFort::RebuildFreeList()
*/
void JitFort::UpdateFreeSpace()
{
LockHolder lock(mutex_);
if (!regionList_.GetLength()) {
return;
}
// disable Fort collection for now - temporary until collection bug fixed
return;
LockHolder lock(mutex_);
if (freeListUpdated_) {
LOG_JIT(DEBUG) << "FreeFortSpace already done for current GC Sweep";
if (!IsMachineCodeGC()) {
return;
} else {
freeListUpdated_ = true;
}
SortLiveMemDescList();
SetMachineCodeGC(false);
LOG_JIT(DEBUG) << "UpdateFreeSpace enter: " << "Fort space allocated: "
<< JitFort::GetInstance()->allocator_->GetAllocatedSize()
<< " available: " << JitFort::GetInstance()->allocator_->GetAvailableSize()
<< allocator_->GetAllocatedSize()
<< " available: " << allocator_->GetAvailableSize()
<< " liveJitCodeBlks: " << liveJitCodeBlks_.size();
allocator_->RebuildFreeList();
SortLiveMemDescList();
auto region = regionList_.GetFirst();
while (region) {
CollectFreeRanges(region);
@ -185,7 +190,7 @@ void JitFort::UpdateFreeSpace()
}
liveJitCodeBlks_.clear();
LOG_JIT(DEBUG) << "UpdateFreeSpace exit: allocator_->GetAvailableSize "
<< JitFort::GetInstance()->allocator_->GetAvailableSize();
<< allocator_->GetAvailableSize();
}
void JitFort::CollectFreeRanges(JitFortRegion *region)
@ -204,7 +209,7 @@ void JitFort::CollectFreeRanges(JitFortRegion *region)
allocator_->Free(freeStart, freeEnd - freeStart, true);
}
freeStart = freeEnd + desc->Available();
ReturnMemDescToPool(desc);
memDescPool_->ReturnDescToPool(desc);
liveJitCodeBlks_.pop_back();
} else {
break;
@ -219,9 +224,9 @@ void JitFort::CollectFreeRanges(JitFortRegion *region)
// Used by JitFort::UpdateFreeSpace call path to find corresponding
// JitFortRegion for a free block in JitFort space, in order to put the blk into
// the corresponding free set of the JitFortRegion the free block belongs.
JitFortRegion *JitFortRegion::ObjectAddressToRange(uintptr_t objAddress)
JitFortRegion *JitFort::ObjectAddressToRange(uintptr_t objAddress)
{
JitFortRegion *region = JitFort::GetInstance()->GetRegionList();
JitFortRegion *region = GetRegionList();
while (region != nullptr) {
if (objAddress >= region->GetBegin() && objAddress < region->GetEnd()) {
return region;
@ -231,7 +236,8 @@ JitFortRegion *JitFortRegion::ObjectAddressToRange(uintptr_t objAddress)
return region;
}
MemDescPool::MemDescPool()
MemDescPool::MemDescPool(uintptr_t fortBegin, size_t fortSize)
: fortBegin_(fortBegin), fortSize_(fortSize)
{
Expand();
}

View File

@ -34,12 +34,6 @@ public:
bool AddRegion();
uintptr_t Allocate(size_t size);
inline static JitFort *GetInstance()
{
static JitFort instance;
return &instance;
}
inline JitFortRegion *GetRegionList()
{
return regionList_.GetFirst();
@ -55,28 +49,29 @@ public:
return jitFortSize_;
}
inline MemDesc *GetMemDescFromPool()
inline bool IsMachineCodeGC()
{
return memDescPool_->GetDescFromPool();
return isMachineCodeGC_;
}
inline void ReturnMemDescToPool(MemDesc *desc)
inline void SetMachineCodeGC(bool flag)
{
memDescPool_->ReturnDescToPool(desc);
LOG_JIT(DEBUG) << "SetMachineCodeGC " << flag;
isMachineCodeGC_ = flag;
}
void RecordLiveJitCode(uintptr_t addr, size_t size);
void CollectFreeRanges(JitFortRegion *region);
void SortLiveMemDescList();
void UpdateFreeSpace();
void RebuildFreeList();
JitFortRegion *ObjectAddressToRange(uintptr_t objAddress);
private:
FreeListAllocator<MemDesc> *allocator_ {nullptr};
// Fort memory space
static constexpr int MAP_JITFORT = 0x1000;
static constexpr size_t JIT_FORT_REG_SPACE_MAX = 8_MB;
static constexpr size_t JIT_FORT_REG_SPACE_MAX = 4_MB;
static constexpr size_t JIT_FORT_HUGE_SPACE_MAX = 2_MB;
static constexpr size_t JIT_FORT_MEM_DESC_MAX = 40_KB;
MemMap jitFortMem_;
@ -96,6 +91,7 @@ private:
bool freeListUpdated_ {false}; // use atomic if not mutext protected
Mutex mutex_;
Mutex liveJitCodeBlksLock_;
bool isMachineCodeGC_ {false};
friend class HugeMachineCodeSpace;
};
@ -103,7 +99,8 @@ private:
class JitFortRegion : public Region {
public:
JitFortRegion(NativeAreaAllocator *allocator, uintptr_t allocateBase, uintptr_t end,
RegionSpaceFlag spaceType) : Region(allocator, allocateBase, end, spaceType) {}
RegionSpaceFlag spaceType, MemDescPool *pool) : Region(allocator, allocateBase, end, spaceType),
memDescPool_(pool) {}
void InitializeFreeObjectSets()
{
@ -123,7 +120,7 @@ public:
{
// Thread safe
if (fortFreeObjectSets_[type] == nullptr) {
fortFreeObjectSets_[type] = new FreeObjectSet<MemDesc>(type);
fortFreeObjectSets_[type] = new FreeObjectSet<MemDesc>(type, memDescPool_);
}
return fortFreeObjectSets_[type];
}
@ -148,11 +145,11 @@ public:
return prev_;
}
static JitFortRegion *ObjectAddressToRange(uintptr_t objAddress);
private:
Span<FreeObjectSet<MemDesc> *> fortFreeObjectSets_;
JitFortRegion *next_ {nullptr};
JitFortRegion *prev_ {nullptr};
MemDescPool *memDescPool_ {nullptr};
};
} // namespace panda::ecmascript

View File

@ -121,7 +121,7 @@ private:
class MemDescPool {
public:
MemDescPool();
MemDescPool(uintptr_t fortBegin, size_t fortSize);
~MemDescPool();
static inline bool IsEmpty(MemDesc* list)
@ -141,6 +141,17 @@ public:
Add(desc);
returned_++;
}
inline uintptr_t JitFortBegin()
{
return fortBegin_;
}
inline size_t JitFortSize()
{
return fortSize_;
}
private:
MemDesc *GetDesc();
void Add(MemDesc *);
@ -153,6 +164,9 @@ private:
size_t returned_ {0};
size_t highwater_ {0};
Mutex lock_;
uintptr_t fortBegin_;
size_t fortSize_;
};
} // namespace panda::ecmascript

View File

@ -91,10 +91,6 @@ inline void NonMovableMarker::MarkObject(uint32_t threadId, TaggedObject *object
((MachineCode*)object)->GetInstructionsSize())
<< " size " <<((MachineCode *)object)->GetInstructionsSize();
}
#else
if (objectRegion->InMachineCodeSpace()) {
LOG_JIT(DEBUG) << "MarkObject MachineCode " << object;
}
#endif
if (objectRegion->AtomicMark(object)) {
workManager_->Push(threadId, object);
@ -449,6 +445,15 @@ inline SlotStatus CompressGCMarker::MarkObject(uint32_t threadId, TaggedObject *
Region *objectRegion = Region::ObjectAddressToRange(object);
if (!NeedEvacuate(objectRegion)) {
if (!objectRegion->InSharedHeap() && objectRegion->AtomicMark(object)) {
#ifdef ENABLE_JITFORT
if (objectRegion->InMachineCodeSpace()) {
LOG_JIT(DEBUG) << "CompressGC MarkObject MachineCode " << object
<< " instructionsAddr " << (void *)((MachineCode*)object)->GetInstructionsAddr()
<< " end " << (void *)(((MachineCode*)object)->GetInstructionsAddr() +
((MachineCode*)object)->GetInstructionsSize())
<< " size " <<((MachineCode *)object)->GetInstructionsSize();
}
#endif
workManager_->Push(threadId, object);
}
return SlotStatus::CLEAR_SLOT;

View File

@ -53,7 +53,6 @@ void PartialGC::RunPhases()
Taskpool::GetCurrentTaskpool()->SetThreadPriority(PriorityMode::STW);
}
markingInProgress_ = heap_->CheckOngoingConcurrentMarking();
LOG_GC(DEBUG) << "markingInProgress_" << markingInProgress_;
Initialize();
Mark();

View File

@ -624,55 +624,30 @@ uintptr_t LocalSpace::Allocate(size_t size, bool isExpand)
MachineCodeSpace::MachineCodeSpace(Heap *heap, size_t initialCapacity, size_t maximumCapacity)
: SparseSpace(heap, MemSpaceType::MACHINE_CODE_SPACE, initialCapacity, maximumCapacity)
{
}
MachineCodeSpace::~MachineCodeSpace()
{
#ifdef ENABLE_JITFORT
jitFort_ = JitFort::GetInstance();
if (jitFort_) {
delete jitFort_;
jitFort_ = nullptr;
}
#endif
}
#ifdef ENABLE_JITFORT
inline void MachineCodeSpace::RecordLiveJitCode(MachineCode *obj)
{
jitFort_->RecordLiveJitCode(obj->GetInstructionsAddr(), obj->GetInstructionsSize());
}
// Non concurrent Sweep.
void MachineCodeSpace::Sweep()
{
liveObjectSize_ = 0;
allocator_->RebuildFreeList();
jitFort_->RebuildFreeList();
EnumerateRegions([this](Region *current) {
if (!current->InCollectSet()) {
IncreaseLiveObjectSize(current->AliveObject());
current->ResetWasted();
FreeRegion(current);
}
});
jitFort_->UpdateFreeSpace();
}
// Concurrent Sweep.
void MachineCodeSpace::PrepareSweeping()
{
liveObjectSize_ = 0;
EnumerateRegions([this](Region *current) {
if (!current->InCollectSet()) {
IncreaseLiveObjectSize(current->AliveObject());
current->ResetWasted();
current->SwapOldToNewRSetForCS();
current->SwapLocalToShareRSetForCS();
AddSweepingRegion(current);
}
});
SortSweepingRegion();
sweepState_ = SweepState::SWEEPING;
allocator_->RebuildFreeList();
jitFort_->RebuildFreeList();
if (jitFort_) {
jitFort_->RecordLiveJitCode(obj->GetInstructionsAddr(), obj->GetInstructionsSize());
}
}
// Record info on JitFort mem allocated to live MachineCode objects
void MachineCodeSpace::FreeRegion(Region *current, bool isMain)
{
LOG_JIT(DEBUG) << "MachineCodeSpace FreeRegion: " << current << " isMain " << isMain;
uintptr_t freeStart = current->GetBegin();
current->IterateAllMarkedBits([this, &current, &freeStart, isMain](void *mem) {
ASSERT(current->InRange(ToUintPtr(mem)));
@ -691,6 +666,9 @@ void MachineCodeSpace::FreeRegion(Region *current, bool isMain)
if (freeStart != freeEnd) {
FreeLiveRange(current, freeStart, freeEnd, isMain);
}
if (jitFort_) {
jitFort_->SetMachineCodeGC(true);
}
}
uintptr_t MachineCodeSpace::Allocate(size_t size, MachineCodeDesc &desc, bool allowGC)

View File

@ -70,13 +70,8 @@ public:
bool Expand();
// For sweeping
#ifdef ENABLE_JITFORT
virtual void PrepareSweeping();
virtual void Sweep();
#else
void PrepareSweeping();
void Sweep();
#endif
void AsyncSweep(bool isMain);
bool TryFillSweptRegion();
@ -292,27 +287,41 @@ struct MachineCodeDesc;
class MachineCodeSpace : public SparseSpace {
public:
MachineCodeSpace(Heap *heap, size_t initialCapacity, size_t maximumCapacity);
~MachineCodeSpace() override = default;
~MachineCodeSpace() override;
NO_COPY_SEMANTIC(MachineCodeSpace);
NO_MOVE_SEMANTIC(MachineCodeSpace); // Note: Expand() left for define
#ifdef ENABLE_JITFORT
void Sweep() override;
void PrepareSweeping() override;
void FreeRegion(Region *current, bool isMain = true) override;
uintptr_t Allocate(size_t size, MachineCodeDesc &desc, bool allowGC = true);
inline void RecordLiveJitCode(MachineCode *obj);
uintptr_t JitFortAllocate(size_t size)
{
return jitFort_->Allocate(size);
}
inline bool IsSweeping()
{
return sweepState_ == SweepState::SWEEPING ;
}
inline JitFort *GetJitFort()
{
return jitFort_;
}
void UpdateFortSpace()
{
if (jitFort_) {
jitFort_->UpdateFreeSpace();
}
}
uintptr_t JitFortAllocate(size_t size)
{
if (!jitFort_) {
jitFort_ = new JitFort();
}
return jitFort_->Allocate(size);
}
private:
JitFort *jitFort_;
JitFort *jitFort_ {nullptr};
friend class Heap;
friend class ConcurrentSweeper;
#endif

View File

@ -63,7 +63,6 @@ js_root = "//arkcompiler/ets_runtime"
global_root = "//base/global/i18n"
hilog_root = "//base/hiviewdfx/hilog/interfaces/native/innerkits"
qos_root = "//foundation/resourceschedule/qos_manager"
code_sign_root = "//base/security/code_signature/interfaces/innerkits"
compile_llvm_online = false
run_with_asan = false
if (enable_fuzz_option) {
@ -264,13 +263,10 @@ template("libark_jsruntime_common_set") {
include_dirs = []
if (enable_jit_code_sign) {
defines += [ "CODE_SIGN_ENABLE" ]
external_deps += [ "code_signature:libjit_code_sign" ]
if (disable_fort_switch) {
defines += [ "JIT_FORT_DISABLE" ]
}
include_dirs += [
"$code_sign_root/common/include",
"$code_sign_root/jit_code_sign/include",
]
}
if (enable_target_compilation) {