!8661 arkcompiler_ets_runtime增加虚拟机参数获取

Merge pull request !8661 from jao_liu/local_branch
This commit is contained in:
openharmony_ci 2024-08-16 08:30:07 +00:00 committed by Gitee
commit 27457ce7e9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 28 additions and 3 deletions

View File

@ -41,10 +41,18 @@ public:
{
switch (heapType) {
case HeapType::WORKER_HEAP:
maxHeapSize_ = DEFAULT_WORKER_HEAP_SIZE;
if (heapSize > LOW_MEMORY && heapSize < DEFAULT_WORKER_HEAP_SIZE) {
maxHeapSize_ = heapSize;
} else {
maxHeapSize_ = DEFAULT_WORKER_HEAP_SIZE;
}
break;
case HeapType::SHARED_HEAP:
maxHeapSize_ = DEFAULT_SHARED_HEAP_SIZE;
if (heapSize > LOW_MEMORY && heapSize < DEFAULT_SHARED_HEAP_SIZE) {
maxHeapSize_ = heapSize;
} else {
maxHeapSize_ = DEFAULT_SHARED_HEAP_SIZE;
};
break;
default:
if (poolSize >= DEFAULT_HEAP_SIZE) {
@ -52,6 +60,9 @@ public:
} else {
maxHeapSize_ = poolSize; // pool is too small, no memory left for worker
}
if (heapSize > LOW_MEMORY && heapSize < DEFAULT_HEAP_SIZE) {
maxHeapSize_ = heapSize;
}
if (heapSize >= DEFAULT_HEAP_SIZE && heapSize <= MAX_HEAP_SIZE) {
maxHeapSize_ = heapSize;
}

View File

@ -63,6 +63,16 @@ EcmaVM *EcmaVM::Create(const JSRuntimeOptions &options)
auto heapType = options.IsWorker() ? EcmaParamConfiguration::HeapType::WORKER_HEAP :
EcmaParamConfiguration::HeapType::DEFAULT_HEAP;
size_t heapSize = options.GetHeapSize();
#if defined(PANDA_TARGET_OHOS) && !defined(STANDALONE_MODE)
switch (heapType) {
case EcmaParamConfiguration::HeapType::WORKER_HEAP:
heapSize = OHOS::system::GetUintParameter<size_t>("persist.ark.heap.workersize", 0) * 1_MB;
break;
default:
heapSize = OHOS::system::GetUintParameter<size_t>("persist.ark.heap.defaultsize", 0) * 1_MB;
break;
}
#endif
auto config = EcmaParamConfiguration(heapType,
MemMapAllocator::GetInstance()->GetCapacity(),
heapSize);

View File

@ -87,8 +87,12 @@ SharedHeap *SharedHeap::instance_ = nullptr;
void SharedHeap::CreateNewInstance()
{
ASSERT(instance_ == nullptr);
size_t heapShared = 0;
#if defined(ECMASCRIPT_SUPPORT_SNAPSHOT) && defined(PANDA_TARGET_OHOS) && defined(ENABLE_HISYSEVENT)
heapShared = OHOS::system::GetUintParameter<size_t>("persist.ark.heap.sharedsize", 0) * 1_MB;
#endif
EcmaParamConfiguration config(EcmaParamConfiguration::HeapType::SHARED_HEAP,
MemMapAllocator::GetInstance()->GetCapacity());
MemMapAllocator::GetInstance()->GetCapacity(), heapShared);
instance_ = new SharedHeap(config);
}