• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "runtime/include/gc_task.h"
17 
18 #include "runtime/mem/gc/gc.h"
19 
20 namespace panda {
21 
Run(mem::GC & gc)22 void GCTask::Run(mem::GC &gc)
23 {
24     gc.WaitForGC(*this);
25     gc.SetCanAddGCTask(true);
26 }
27 
Release(mem::InternalAllocatorPtr allocator)28 void GCTask::Release(mem::InternalAllocatorPtr allocator)
29 {
30     allocator->Delete(this);
31 }
32 
operator <<(std::ostream & os,const GCTaskCause & cause)33 std::ostream &operator<<(std::ostream &os, const GCTaskCause &cause)
34 {
35     switch (cause) {
36         case GCTaskCause::INVALID_CAUSE:
37             os << "Invalid";
38             break;
39         case GCTaskCause::PYGOTE_FORK_CAUSE:
40             os << "PygoteFork";
41             break;
42         case GCTaskCause::STARTUP_COMPLETE_CAUSE:
43             os << "StartupComplete";
44             break;
45         case GCTaskCause::NATIVE_ALLOC_CAUSE:
46             os << "NativeAlloc";
47             break;
48         case GCTaskCause::EXPLICIT_CAUSE:
49             os << "Explicit";
50             break;
51         case GCTaskCause::HEAP_USAGE_THRESHOLD_CAUSE:
52             os << "Threshold";
53             break;
54         case GCTaskCause::YOUNG_GC_CAUSE:
55             os << "Young";
56             break;
57         case GCTaskCause::OOM_CAUSE:
58             os << "OOM";
59             break;
60         default:
61             LOG(FATAL, GC) << "Unknown gc cause";
62             break;
63     }
64     return os;
65 }
66 
67 }  // namespace panda
68