• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "common_components/heap/collector/task_queue.h"
17 
18 #include "common_components/heap/collector/collector_proxy.h"
19 
20 namespace common {
Execute(void * owner)21 bool GCRunner::Execute(void* owner)
22 {
23     ASSERT_LOGF(owner != nullptr, "task queue owner ptr should not be null!");
24     CollectorProxy* collectorProxy = reinterpret_cast<CollectorProxy*>(owner);
25 
26     switch (taskType_) {
27         case GCTask::GCTaskType::GC_TASK_TERMINATE_GC: {
28             return false;
29         }
30         case GCTask::GCTaskType::GC_TASK_INVOKE_GC: {
31             GCStats::SetPrevGCStartTime(TimeUtil::NanoSeconds());
32             collectorProxy->RunGarbageCollection(taskIndex_, gcReason_, gcType_);
33             GCStats::SetPrevGCFinishTime(TimeUtil::NanoSeconds());
34             break;
35         }
36         case GCTask::GCTaskType::GC_TASK_DUMP_HEAP: { //LCOV_EXCL_BR_LINE
37             LOG_COMMON(FATAL) << "Don't know how to dump heap";
38             UNREACHABLE_CC();
39             break;
40         }
41         case GCTask::GCTaskType::GC_TASK_DUMP_HEAP_IDE: { //LCOV_EXCL_BR_LINE
42             LOG_COMMON(FATAL) << "Don't know how to dump heap OOM";
43             UNREACHABLE_CC();
44             break;
45         }
46 
47         case GCTask::GCTaskType::GC_TASK_DUMP_HEAP_OOM: { //LCOV_EXCL_BR_LINE
48             LOG_COMMON(FATAL) << "Don't know how to dump heap OOM";
49             UNREACHABLE_CC();
50             break;
51         }
52         default:
53             LOG_COMMON(ERROR) << "[GC] Error task type: " << static_cast<uint32_t>(taskType_) << " ignored!";
54             break;
55     }
56     return true;
57 }
58 } // namespace common
59