• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #include "ecmascript/mem/heap.h"
16 #include "ecmascript/mem/incremental_marker.h"
17 #include "ecmascript/mem/concurrent_marker.h"
18 #include "ecmascript/mem/mem_controller.h"
19 #include "ecmascript/tests/ecma_test_common.h"
20 
21 using namespace panda::ecmascript;
22 
23 namespace panda::test {
24 
25 class HeapTest :  public BaseTestWithScope<false> {
26 public:
SetUp()27     void SetUp() override
28     {
29         JSRuntimeOptions options;
30         instance = JSNApi::CreateEcmaVM(options);
31         ASSERT_TRUE(instance != nullptr) << "Cannot create EcmaVM";
32         thread = instance->GetJSThread();
33         thread->ManagedCodeBegin();
34     }
35 };
36 
37 class HeapTestHelper {
38 public:
HeapTestHelper(Heap * heap)39     explicit HeapTestHelper(Heap *heap) : heap_(heap) {}
40 
41     ~HeapTestHelper() = default;
42 
SetIdleGCState(bool flag)43     void SetIdleGCState(bool flag)
44     {
45         ASSERT_NE(heap_, nullptr);
46         heap_->enableIdleGC_ = flag;
47     }
48 
GetHeap()49     Heap *GetHeap()
50     {
51         return heap_;
52     }
53 
54 private:
55     Heap *heap_{nullptr};
56 };
57 
58 }