!9511 Fix cocurrent mark trigger problem in cold start

Merge pull request !9511 from xiongluo/mark_trigger_fix_cold
This commit is contained in:
openharmony_ci 2024-09-25 03:54:08 +00:00 committed by Gitee
commit fd401c22e5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 23 additions and 1 deletions

View File

@ -2248,7 +2248,7 @@ bool Heap::HandleExitHighSensitiveEvent()
{
AppSensitiveStatus status = GetSensitiveStatus();
if (status == AppSensitiveStatus::EXIT_HIGH_SENSITIVE
&& CASSensitiveStatus(status, AppSensitiveStatus::NORMAL_SCENE)) {
&& CASSensitiveStatus(status, AppSensitiveStatus::NORMAL_SCENE) && !OnStartupEvent()) {
// Set record heap obj size 0 after exit high senstive
SetRecordHeapObjectSizeBeforeSensitive(0);
// set overshoot size to increase gc threashold larger 8MB than current heap size.

View File

@ -158,6 +158,28 @@ HWTEST_F_L0(GCTest, HighSensitiveExceedMaxHeapSize)
EXPECT_TRUE(commitSize < thread->GetEcmaVM()->GetEcmaParamConfiguration().GetMaxHeapSize());
}
HWTEST_F_L0(GCTest, ColdStartNoConcurrentMark)
{
auto heap = const_cast<Heap *>(thread->GetEcmaVM()->GetHeap());
heap->NotifyPostFork();
heap->NotifyHighSensitive(true);
{
[[maybe_unused]] ecmascript::EcmaHandleScope baseScope(thread);
for (int i = 0; i < 500; i++) {
[[maybe_unused]] JSHandle<TaggedArray> array = thread->GetEcmaVM()->GetFactory()->NewTaggedArray(
10 * 1024, JSTaggedValue::Hole(), MemSpaceType::SEMI_SPACE);
}
}
EXPECT_FALSE(heap->HandleExitHighSensitiveEvent());
heap->NotifyHighSensitive(false);
EXPECT_FALSE(heap->HandleExitHighSensitiveEvent());
heap->FinishStartupEvent();
heap->NotifyHighSensitive(true);
heap->NotifyHighSensitive(false);
EXPECT_TRUE(heap->HandleExitHighSensitiveEvent());
}
HWTEST_F_L0(GCTest, CallbackTask)
{
auto vm = thread->GetEcmaVM();